Jump to content
  • Advertisement
Sign in to follow this  
CRACK123

OpenGL lighting in opengl orthographics mode

This topic is 4327 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 have a gluSphere in orthographics mode and I am trying to light it. But I am not sure how the lighting works in orthographic mode. For example if I am trying to light a sphere position at 20, 20, -10 in an orthographics projection x = 0-612, y = 0-612, z = -1 -> 10 would I do it the same way as in perspective mode or would I use the position of light as 20, 30, -10. Thanks

Share this post


Link to post
Share on other sites
Advertisement
There's no difference between orthographic and perpsective projection. To OpenGL, the projection matrix is... well... just another matrix. So you setup your lighting exactly the same in both cases, cause there is no difference as far as OpenGL concerns.

Share this post


Link to post
Share on other sites
Also be careful not to use glScalef to scale your scene, since it will affect the length of the normals. The normal has to be unit length (ie. 1.0), so if you do scale your world, be sure to take that in consideration when supplying the normals for your geometry, or at the very least do glEnable(GL_NORMALIZE) if you wanna let OpenGL do it for you (probably not a good idea as it's slower).

Note that is also applies to perspective projection, of course. As Brother Bob said, it makes no difference to OpenGL what projection matrix you have. It's just that people are much more likely to use glScale on the modelview matrix when using an ortho projection than when using a perspective one (since it screws up the perspective).

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!