Jump to content
  • Advertisement
Sign in to follow this  
vidjogamer

OpenGL Scaling problem.

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

Hey guys. Im developing an opengl app for the ipad and for some reason when i scale my object down it gets brighter and brighter and when i scale it up it gets darker and darker. Any ideas for why this is happening and how to fix it? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Sounds like you aren't normalizing your normals. I assume you are using the default pipeline so just add this line at the start of your code:


glEnable(GL_NORMALIZE);

Share this post


Link to post
Share on other sites
That's not the problem.

When you scale your models, the normals get multiplied by the matrix so get scaled as well. glEnable(GL_NORMALIZE) tells OpenGL to normalize the normals after this transformation so they are normalized for the lighting equations.

Normalizing before hand is a good habbit but it wouldn't affect this problem.

Share this post


Link to post
Share on other sites
Just to throw in a tip:

If you are only performing uniform scaling (equally in all dimensions), then you may get higher performance by enabling GL_RESCALE_NORMALS instead of GL_NORMALIZE

With rescale normals the normals are simply divided by the model scale, instead of performing the more expensive normalization function for every vertex.

Source:
Avoiding Common OpenGL Pitfalls
Read section 1


Also if you are concerned with perf you should disable these when you are dealing with objects that you know are unscaled, as this will cause performance hit in your vertex shader.

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!