Jump to content
  • Advertisement
Sign in to follow this  

OpenGL lighting + openGL state

This topic is 4554 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

hi i need to do lighting through pixel shaders. No problem this works. The problem is if i have an object on position 0,0,0 (a teapot for example) and the light is on 5,5,0, the object must be illuminated with a vector from 5,5,0 to 0,0,0. Now i move the teapot to 10,10,0. Now it must be illuminated from other side, but it is not, because when i use translation i translate the local coordinate system to 10,10,0 and then i apply the shader. But the light should have new coordinates -5,-5,0. I know that i have to calculate the vector from the teapot to the light to know where the light must be placed in the local coordinate system. I know how to do this - multiply the transformation matricies and then compute the location of point 0,0,0 and then i can compute that vector. So all i need to is apply some glTranslate, glRotate or glScale which will modify the modelview matrix. Then i should be able to calculate the 0,0,0 point from the modelview matrix. But i don't how to compute it. I have read the matrix as stated in openGL red book with glGetFloatv(GL_MODELVIEW_MATRIX, ...); and then with the values i computed the vector but it was wrong. Any idea, or some other approach? thanks in advace XorMultiPleXus

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!