light

Hi,

I am appending some rendering to a 3rd party drawing (i.e. I have no way to know their setting). I can see their models with shadow, and some faces opposite to the light are darker. But my appended model, say a cube, has all faces equally light. What commands am I missing? I disable GL_CULL_FACE, GL_BLEND, enable GL_COLOR_MATERIAL, GL_LIGHTING, and call glPolygonMode(GL_FRONT_AND_BACK, GL_FILL). Could you help? Thanks.

Tony

Hi,

Do you use textures? Maybe you have a wrong texture enviroment, it should be GL_MODULATE. Or maybe you have too much ambient or emissive light.

-Ilkka

Originally posted by jyoung77:
I disable GL_CULL_FACE, GL_BLEND, enable GL_COLOR_MATERIAL, GL_LIGHTING, and call glPolygonMode(GL_FRONT_AND_BACK, GL_FILL). Could you help?

With all those enabled, I smell dodgy normals.

Hi,

The following is how I set up my texture environment. It makes no difference with or w/o them. If the problem is
too much ambient or emissive light, the 3rd party software should have the same problem (but they don’t), right? Do I have to set up normals for my objects’ faces? Please help. Thanks.

glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glTexParameteri (GL_TEXTURE_1D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri (GL_TEXTURE_1D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glTexParameteri (GL_TEXTURE_1D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri (GL_TEXTURE_1D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexEnvi (GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);

Tony

If you don’t specify normals they default to 0,0,1 (I think thats right). The shading of faces due to lighting is calculated using the dot product of the light vector and the face normal. If all your faces have the same normal, they will be shaded (lit) in the same way. So yes, you do need to supply a normal for your vertices.

This is a pretty basic 3D/opengl fundamental. Can I suggest you look at the tutorials here