View Full Version : Lighting problems, please help.

05-13-2002, 12:04 PM
I've build a simple scene with a single point light source. Now the light source should cast a constant light on the scene, but it seems, that the amount of light on surfaces parallel to the ground level (x/z-plane) changes with the movements of my camera. E.g. if I look at a specific point the ground seems to get a normal amount of light, but if I turn the camera a little, the ground darkens over. I do reposition the light source at every frame rendering, so why is this happening? I use gluLookAt to position the camera and of course glLightfv to set the position of the light. I've also tried to reset all the other light parameters, but it didn't change a thing. I've checked all my normals, and they seem to be pointing in the right directions, i.e. straight up the y-axis. Does anyone have any ideas what could be wrong? If you need more info or code samples to answer this question, please let me know.

Thanks Anders

05-13-2002, 10:46 PM
Hi !

Are you placing the glLightfv call at the right place in the code, when you call glLightfv() it is put through the modelview matrix also. just an idea...


05-14-2002, 02:59 AM
This what my rendering code looks like:


// Reposition camera
gluLookAt( g_Cam.m_Position.x, g_Cam.m_Position.y, g_Cam.m_Position.z,
g_Cam.m_Focus.x, g_Cam.m_Focus.y, g_Cam.m_Focus.z,
g_Cam.m_Up.x, g_Cam.m_Up.y, g_Cam.m_Up.z);

// Reposition light
glLightfv(LightID, GL_POSITION, Position);

I've tried repositioning the light both after and before calling gluLookAy (not at the same time btw.), but it changes nothing. I've also tried to call glLoadIdentity before repositioning the light, but that didn't do anything either. Does anyone have an idea what could be wrong?