Jump to content
  • Advertisement
Sign in to follow this  
the_cyberlord

Calculating normals for vertexes in triangles

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

Advertisement
The canonical way is as follows.

1. Create a 'blank' normal (0, 0, 0) for each vertex.

2. Loop through each triangle. For each triangle, add the normal of that triangle to the normals of each of the three vertices that the triangle references.

3. Normalize all the vertex normals.

For each vert, this simply creates the normal as the average of the normals of all the faces incident upon it.

A more sophisticated implementation will weight the averages by the area of the faces. But you'll still get decent results without that step.

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
A more sophisticated implementation will weight the averages by the area of the faces.

in fact, with triangle faces, the _less_ sophisticated implementation weight averages by area of faces[grin].
Length of cross product of two edge vectors = area of face * 2 , so you just need to not normalize anything till step 3, and you'll get nice weighted average. except i don't sure it will really looks that better.

Share this post


Link to post
Share on other sites
Quote:
in fact, with triangle faces, the _less_ sophisticated implementation weights averages by area of faces


Oh yeah, I guess you're right :-) I was just assuming he would already have normalized normals and would use those...

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!