Advertisement

Short question about lights

Started by December 19, 2002 02:31 PM
1 comment, last by Roming22 22 years, 2 months ago
Hi, Why do I have to setup my light position every frame I render and not once for all? If I don't call glLightfv(GL_LIGHT0, GL_POSITION,LightPosition) every time, the lighting is just really weird. [edited by - Roming22 on December 19, 2002 3:32:58 PM]
The position of light is alocated on the scene based on the actual model view matrix. When you move the camera, if you don''t update the light to the new matrix, it will remin in the same place relative to the screen...To undertand better, is like that....in openGL, the camera don''t realy moves, how moves is the world in relation to the camera, is for that that exist the matrix....so, if you put a light in a position and you dont actualize her position, the world on moving will have some artefacts becausse of disalighne...undertand? Humm, I hope so, if you not, don''t worry, just update that every frame

Techno Grooves
Techno Grooves
Advertisement
The camera in OpenGL never moves. The camera is your screen, after all. It can''t move! So when you position a light, you say "this light is x,y,z from the screen". OpenGL will remember those values, and will not alter them with glTranslate, glRotate, or any other similar function . So all OpenGL knows is that the light is x,y,z from the screen every frame, while the world geometry moves around.
So you have to make sure OpenGL knows that your light is moving around with the world, by positioning it every frame.

------------
MSN: nmaster42@hotmail.com, AIM: LockePick42, ICQ: 74128155
"It''s all part of the conspiracy of conspirators conspiring to conspire their own conspiracies..."
_______________________________________Pixelante Game Studios - Fowl Language

This topic is closed to new replies.

Advertisement