Jump to content
  • Advertisement
Sign in to follow this  
dillonco

OpenGL Specular Highlight troubles

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

Hello, I'm having loads of trouble with specular highlights. With standard OpenGL lighting, I can get highlights when GL_LIGHT_MODEL_LOCAL_VIEWER is set to false, though they don't look good (because they're static). However when I enable local viewer they disapper, even if I place the camera along the z (so the vector would be about the same as without local viewer). On top of that, I've beem playing with a bump map shader (GLSL), and speculars don't work with that either. Every example I've seen says that the eye vector is is just given by -(glModelviewMatrix * gl_Vertex). That doesn't work at all. However if I do cam_pos-(glModelviewMatrix * gl_Vertex) I get the expected results. While that's now working (properly?), I still would like to get the standard lighting up too. The only thing I can think of is that my camera isn't set up right or something... The scene consists of a smoothed sphere on the origin with r=1, and an orbiting camera (gluPerspective + gluLookAt). Does anyone know what the problem is?

Share this post


Link to post
Share on other sites
Advertisement
What I can come up with is that you are putting the camera transform in the GL_PROJECTION matrix stack. You should put only the projection (gluPerspective) part there. The camera transform (gluLookAt) should go in GL_MODELVIEW, that's what the "VIEW" part means - the viewing transform.

Share this post


Link to post
Share on other sites
Ha, that was it. Thanks.

I now seem to have to update (re-set) the light positions every time the view changes though. Is this the way it should be?

Share this post


Link to post
Share on other sites
Quote:
Original post by dillonco
Ha, that was it. Thanks.

I now seem to have to update (re-set) the light positions every time the view changes though. Is this the way it should be?
Yes, the light position is affected by the modelview matrix when you set it, so if the view changes you need to update the light position. You should read the Lighting Chapter of the Red Book, specifically the "Controlling a Light's Position and Direction" section.

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!