PDA

View Full Version : lighting problems or artifacts



cragwolf
04-17-2003, 02:08 AM
This screenshot...
http://home.iprimus.com.au/cragwolf/3dpics/test.jpg

...shows a terrain that I randomly generated using a fractal brownian motion algorithm, and then rendered using OpenGL with diffuse and ambient lighting. It's made up of 64x64 vertices, and was constructed using GL_TRIANGLE_STRIP. If you look at the screenshot you'll notice on the slopes of the hills some dark criss-cross banding, which seems to follow the edges of the original grid.

Anybody know why this might happen? I'm pretty sure that my normals are OK. I'm calculating them by averaging normals from the surrounding 8 triangles. I've heard of Mach banding, but I'm not sure if this is it. When I apply textures this banding tends to disappear or become much less noticeable, especially when the textures are darker. But I would like to get rid of it or minimise it as much as I can before applying textures.

marcus256
04-17-2003, 02:45 AM
This is an unfortunate result of the fact that OpenGL uses per vertex lighting. In other words all lighting calculations are carried out per vertex, NOT per pixel. The banding that you are seeing is a result of bilinear interpolation between the vertices.

To improve your results, either increase your grid density (easy solution), or go for per pixel lighting using fragment programs or similar (difficult solution).

vincoof
04-17-2003, 10:56 AM
marcus is absolutely right.

One thing you could try actually is the diamond rendering order.

cragwolf
04-17-2003, 02:19 PM
Thanks guys.