Jump to content
  • Advertisement
Sign in to follow this  
eGamer

light position

This topic is 3443 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

what is the difference between: glLightfv(GL_LIGHT0,GL_POSITION,pos); gluLookAt(...); and: gluLookAt(...); glLightfv(GL_LIGHT0,GL_POSITION,pos); i get significant difference but i didn't know why. any help please. i also need an article that explains this.

Share this post


Link to post
Share on other sites
Advertisement
The position of the light is transformed by the modelview matrix. In the first code, the modelview matrix does not contain the lookat matrix, while in the second, it does.

Share this post


Link to post
Share on other sites
Given the following sequence of calls, the light is specified in world coordinates (i.e. relative to the origin):
glLoadIdentity()
glLightfv(GL_LIGHT0,GL_POSITION,pos)
gluLookAt(...)

And the following specifies the light in viewer/eye coordinates (i.e. relative to the camera):
glLoadIdentity()
gluLookAt(...)
glLightfv(GL_LIGHT0,GL_POSITION,pos)

Share this post


Link to post
Share on other sites
suppose we have a point p, then according to your answer,
which is first applied model matrix or view matrix

p = ModelMatrix * ViewMatrix * p

or

p = ViewMatrix * ModelMatrix * p

may this helps me in guessing what is happening.

Share this post


Link to post
Share on other sites
There is only one matrix, so the correct answer is p = ModelviewMatrix * p. What that matrix looks like depends entirely on how YOU make it in YOUR program.

Share this post


Link to post
Share on other sites
There is no "model matrix" and no "view matrix". In OpenGL you just have the ModelView matrix, which combines the model and the view matrix. The thing is that gluLookAt() changes this modelview matrix, while glLightfv() uses the modelview matrix. So the position of the light depends on the modelview matrix at the time of the call, but whether or not you have called gluLookAt() changes what that modelview matrix is.

Share this post


Link to post
Share on other sites
OpenGL Vertex pipeline:
Modelling : is the process of transforming objects from model coordinates
to world coordinates.

Viewing : is the process of transforming world coordinates to view coordinates.

which is applied first ?

MV = M * V
or
MV = V * M

Share this post


Link to post
Share on other sites
and from which side the multipication is done
P = M * V * P
or
P = P * M * V

???

Those Information are necessary in order to know the internal work of
Pipeline, so i can guess why the effect of light position differes ?

please help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!