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 5 of 5

Thread: Camera altering the lighting?(No specular)

  1. #1
    Intern Contributor
    Join Date
    Sep 2006
    Location
    US(California)
    Posts
    58

    Camera altering the lighting?(No specular)

    I just started working on implementing lights (direction) in my application. All is working ok except when I use gluLookAt to move the camera the lighting is affected by the movement even though there is no specular turned on. Is there any rule-of-thumb cause for this problem that a beginner should know?

    Could it have anything to do with PROJECTION matrix "abuse"?
    -Josh

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    924

    Re: Camera altering the lighting?(No specular)

    Position or direction of the light is multiplied by modelview matrix that was active at time when the light position or direction was specified.

  3. #3
    Intern Contributor
    Join Date
    Sep 2006
    Location
    US(California)
    Posts
    58

    Re: Camera altering the lighting?(No specular)

    Thank you for your quick response but I'm not sure I understand how that could be the problem. The first time I use gluLookAt is far after I instruct the light position and set the model view matrix.

    -init
    ---model view
    ---lighting direction
    -main loop
    ---update game and camera state
    ---gluLookAt
    ---draw geometry
    -Josh

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    924

    Re: Camera altering the lighting?(No specular)

    Entire OGL lighting operates in eye space (space after application of the modelview matrix) and light positions are also stored in this space. Because light positions are stored in eye space, they will remain in the same position relative to the camera even when the modelview matrix changes. This is what you are seeing.

    To keep them at fixed position in world space you need to respecify theirs position each time the position of the camera (the "view" part of the modelview matrix) changes so the main loop should look like:

    Code :
    // Load view part of the matrix.
     
    glLoadIdentity() ;
    gluLookAt(...)
     
    // Respecify the lights.
     
    glLightfv( GL_POSITION, world space position )
     
    // Apply model transformations and render geometry.

  5. #5
    Intern Contributor
    Join Date
    Sep 2006
    Location
    US(California)
    Posts
    58

    Re: Camera altering the lighting?(No specular)

    Ok I fiddled with code with your help in mind and got it working.
    -thank you!
    -Josh

Posting Permissions

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