PDA

View Full Version : light



jyoung77
03-19-2003, 10:42 AM
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

JustHanging
03-19-2003, 10:56 AM
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

rgpc
03-19-2003, 04:09 PM
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.

jyoung77
03-19-2003, 05:54 PM
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

rgpc
03-19-2003, 10:44 PM
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 (http://nehe.gamedev.net)