PDA

View Full Version : GL_AUTO_NORMAL cause lighting problem



ahbear
03-21-2004, 10:19 AM
I'm using openGL to interpolate a large 3D map. I used two different ways to interpolate the data: use lots of small quads, and lots of small bezier patches.

When using lots of small quads (about 250000 of them), I calculate the average normal for each vertex from the adjacent 4 quads, it works fine, lighting is correct.

But when I use bezier patches, I used glEnable(GL_AUTO_NORMAL), the lighting turns out to be correct on one single big patch (bright, as in polygon mode), but not correct on all small patches (only lit a few surfaces, very dim and weak, if I change the position of light, it is the same). I changed the camera position, look from "under ground" and up, the map is much brighter than looking from the sky.

The possible reason is that openGL does not calculate the normal for each small patch everytime, or it does not calculate the right normal.

I enabled GL_AUTO_NORMAL in my init function, also does glEnable(GL_MAP2_VERTEX_3), glMapGrid2f(9, 0.0, 1.0, 9, 0.0, 1.0), And put glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &ctrlPoints[0][0][0]), glEvalMesh2(GL_FILL, 0, 9, 0, 9) in a loop which generate lots of bezier patches.

Any suggestion will be greatly appreciated!

[This message has been edited by ahbear (edited 03-21-2004).]

Mazy
03-22-2004, 02:44 AM
Im not sure, but is auto_normal normalized? try glEnable(GL_NORMALIZE) and see if that fixes anything.