PDA

View Full Version : How do I properly render lines that looks nice in the distance?



hashbrown
05-06-2017, 11:37 AM
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:

https://s18.postimg.org/3r9t336dx/grid.png (https://postimg.org/image/3r9t336dx/)

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!

john_connor
05-06-2017, 12:43 PM
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

hashbrown
05-06-2017, 02:04 PM
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

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

GClements
05-07-2017, 01:21 AM
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.

hashbrown
05-08-2017, 12:38 PM
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.

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