Jump to content
  • Advertisement
Sign in to follow this  
nielzzz

OpenGL glNormal

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

So I made a square composed of triangle strips and now I want to give it some lighting/shading. Can someone please explain to me why the heck I need to explicitly define the normals for every surface of my square? OpenGL already knows what is the front and backside of the triangles else it would not be able to do the backside culling. Also a triangle is ALWAYS in a plane. Can't it calculate the normals based on that information? Basicly why do i need to provide double information in this case. Its not a curved surface. Is there an easier way?

Share this post


Link to post
Share on other sites
Advertisement
Two examples:

A square, which has sharp edges. Lighting on this should be sharp and clear.

A sphere, which is rounded. Lighting on this should be smooth and continuous. There should be no jumping from light to dark.

Now, if openGL just assumes that all verticies should have a normal pointing directly away from the face, then the square will look right, but the sphere will also have sharp, discontinuous lighting (particularly if it has few triangles). On the other hand, if you specify the normals of the spheres so that OpenGL interpolates between the different normals for the verticies, it gets rid of the sharpness. You do this by giving verticies on the same triangle multiple, different normals. And, in the case of the sphere (and most other things), you give each vertex, regardless of which face it's being used as a corner of, the same normal. On the square, you give the same vertex different normals depending on which face you are using it in.

To sum it up, if you couldn't specify normals, then everything would look much more like Darwinia. (Which is fine, if you want that look!)

[Edited by - Ezbez on November 1, 2008 1:53:54 PM]

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!