Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Lighting problems, please help.

  1. #1
    Intern Contributor
    Join Date
    Sep 2000
    Location
    Copenhagen, Denmark
    Posts
    61

    Lighting problems, please help.

    Hi,
    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

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,651

    Re: Lighting problems, please help.

    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...

    Mikael

  3. #3
    Intern Contributor
    Join Date
    Sep 2000
    Location
    Copenhagen, Denmark
    Posts
    61

    Re: Lighting problems, please help.

    This what my rendering code looks like:
    Code :
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	
    	glLoadIdentity();
     
    	// 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
    	glPushMatrix();
    	glLightfv(LightID, GL_POSITION, Position);
    	glPopMatrix();
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •