View Full Version : Camera altering the lighting?(No specular)
11-25-2006, 02:26 PM
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"?
11-25-2006, 03:08 PM
Position or direction of the light is multiplied by modelview matrix that was active at time when the light position or direction was specified.
11-25-2006, 03:47 PM
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.
---update game and camera state
11-25-2006, 05:51 PM
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:
// Load view part of the matrix.
// Respecify the lights.
glLightfv( GL_POSITION, world space position )
// Apply model transformations and render geometry.
12-02-2006, 10:49 PM
Ok I fiddled with code with your help in mind and got it working.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.