The right way to calculate Per Vertex Normal

Started by
2 comments, last by StealthNinja 16 years, 4 months ago
Hi, I understand from the various past post that one of the ways to calculate the per-vertex normal is to add-up the faces normals that is related to this vertex and then normalize it. However won't the normals calculated be abit off? For example a cube:

Side 1    Side2

3    2    4    3
*----*    *----*
|\   |    |\   |
|  \ |    |  \ |
*----*    *----*
0    1    5    0

Side1 Normal = 1.0, 0.0, 0.0
Side2 Normal = 0.0, -1.0, 0.0

Looking at Vertex 3, if I am to use the sum of face normals, I would get: (1.0, 0.0, 0.0) + (1.0, 0.0, 0.0,) + (0.0, -1.0, 0.0) = (2.0, -1.0, 0.0) which yield (2.0, -1.0, 0.0) as a normal for vertex 3. However logically, shouldn't vertex 3 normal be (1.0, -1.0, 0.0) instead? Which should be the correct normal for the vertex 3? Thanks
Advertisement
Averaged normals only work for 'smoothing groups' - that is surfaces that should be smooth and have no seams. Since the edges of the cube are actually seams the calculation breaks down. There are multiple strategies for handling this:

i) Duplicate vertices (one set for each smooth mesh)
ii) Multiple normals per vertex (probably a bad idea)
iii) Normal maps

And probably others I can't think of right now :)
There are a number of correct ways to calculate vertex normals -- they're an approximation by nature, so you can use a variety of methods to obtain them and they will still be "correct" in some sense. Not all methods produce good looking normals for all surfaces (note that a cube is a pretty pathological case for vertex normal generation, unless the cube is composed of six discrete faces that don't share vertices).
When averaging, you should weigh the contributions of the face normals by the angle that the vertex makes in that face.
If you don't do this, you may get different results in cases that you wouldn't expect to, like when comparing a mesh of quads to the same mesh using triangles.

This topic is closed to new replies.

Advertisement