Odd Normals and Lighting
ok i have been programming in OpenGL for about 10 months and this problem has been driving me nuts for a while. i have a VERY simple scene with a light, a white triangle and a white sphere with generated normals. also in my scene you can move the camera around just like a first-person game. now whats happening is when you look at the lighted front of the objects they light up okay. when you move the camera to the back the sphere is lit up but the triangle is darkened. another problem im seeing is when the camera is moved to the right side of the objects the triangle is lit up. now this is really bugging me. when the camera is moved to the left side the triangle is darkened. does anybody know what is going on? i have made sure that the normal on the triangle is pointing straight out and in the correct orientation.
thanks ahead of time
after reading my last post over it seems a little confusing to me. basically the sphere''s lighting does not change. you can notice a bit of falloff on the sides but when you move the falloff moves too. now with the triangle if you rotate the camera left or right the lighting changes on it. is there a certain order polygons, textures and lights need to be drawn?
Yea, lighting can be problematic, i can''t really say i know what''s wrong with it, but i can give you a few pointers.
1. make shure the normals are ok if your calcylating them manualy or automaticly, sometimes when you rotate an object the normals are not rotating with them - this is bad.
2.kill all specular lighting until everything works ok, it can confuse you as it moves relative to you, the light and the object''s normals.
3. the light may not move the way you want it to when rotating.
1. make shure the normals are ok if your calcylating them manualy or automaticly, sometimes when you rotate an object the normals are not rotating with them - this is bad.
2.kill all specular lighting until everything works ok, it can confuse you as it moves relative to you, the light and the object''s normals.
3. the light may not move the way you want it to when rotating.
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
I solved some troubles with this
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
Dont really know what first line means... maybe some kind of ligth positioning viewer vs univers ?
Hope it will help
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
Dont really know what first line means... maybe some kind of ligth positioning viewer vs univers ?
Hope it will help
You must transform the light to it''s position *after* you transform to your camera frame, otherwise the light will effectively follow you around.
Death of one is a tragedy, death of a million is just a statistic.
Death of one is a tragedy, death of a million is just a statistic.

If at first you don't succeed, redefine success.
excuse me, this topic made me a trouble...
i have a display list with all glNormal3f /glvertex3f calls...
if i rotate the disp list normals are rotated too isn''t it?
There aren''''t problems that can''''t be solved with a gun...
i have a display list with all glNormal3f /glvertex3f calls...
if i rotate the disp list normals are rotated too isn''t it?
There aren''''t problems that can''''t be solved with a gun...
There aren''t problems that can''t be solved with a gun...
python_regious : what do you mean ?
Aren''t ligth positions defined in world coordinate system ?
Aren''t ligth positions defined in world coordinate system ?
Thor:
Normals are rotated with the model. There is no reason for lighting to break due to bad normals when you use a glRotate command. Scaling however does affect the normals.
MV:
Light positions get transformed. Therefore, you want to specify their position after you transform, otherwise they''ll get transformed too ( and hence, follow you around ).
Death of one is a tragedy, death of a million is just a statistic.
Normals are rotated with the model. There is no reason for lighting to break due to bad normals when you use a glRotate command. Scaling however does affect the normals.
MV:
Light positions get transformed. Therefore, you want to specify their position after you transform, otherwise they''ll get transformed too ( and hence, follow you around ).
Death of one is a tragedy, death of a million is just a statistic.

If at first you don't succeed, redefine success.
you make an interesting point of the light "following" you around but in my draw function the light has a static position... i think. in other words i dont have a function or a call to change the light''s position. the only time i call use the light is when i initialize it. any ideas?
July 18, 2003 01:15 PM
If you''ve done a light position initialization at the scene initialization, it doesn''t mean that the light position won''t get changed with the world transformation, does it?
I mean, when you transform the camera, the world could be transformed too, and that could change the light position.
May be you should add glPushMatrix before any transfomation, and glPopMatrix after them.
I mean, when you transform the camera, the world could be transformed too, and that could change the light position.
May be you should add glPushMatrix before any transfomation, and glPopMatrix after them.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement