How do I properly render lines that looks nice in the distance?

I’ve created a grid using GL_LINES but if it’s large enough, the grid is unrecognizable in the distance. Here’s a sample:

Is there a way I can make this grid look nicer in the distance? Any ideas are greatly appreciated. I’m mainly using WebGL but also working on OpenGL 3 and > implementation. Thanks a lot!

possible options:

  1. dont render a very large grid, render near grid parts only
  2. lets the lines “fade” away in the distance (blending + distance-dependend alpha-component)
  3. use fog or nebula
  4. multisampling

[QUOTE=john_connor;1286971]possible options:

  1. dont render a very large grid, render near grid parts only
  2. lets the lines “fade” away in the distance (blending + distance-dependend alpha-component)
  3. use fog or nebula
  4. multisampling[/QUOTE]

John, thanks! I didn’t know what to look for, now I do. I’ll look into all options.

Another option is to render the grid as a texture-mapped quad with a mipmapped texture; the main issue is that the texture needs to be large enough to avoid getting thick lines close to the viewpoint.

Or you can use a fragment shader. This will give you greater control and avoid the need for a large texture; but for OpenGL ES, you’ll need the OES_standard_derivatives GLSL extension.

[QUOTE=GClements;1286978]Another option is to render the grid as a texture-mapped quad with a mipmapped texture; the main issue is that the texture needs to be large enough to avoid getting thick lines close to the viewpoint.

Or you can use a fragment shader. This will give you greater control and avoid the need for a large texture; but for OpenGL ES, you’ll need the OES_standard_derivatives GLSL extension.[/QUOTE]

Thanks GC, I made the grid smaller at the end, but I’m going to try making a texture mapped quad now :slight_smile: