Public Group

# vertex normal just checkin myself

This topic is 3872 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

##### Share on other sites
A common method for computing vertex normals is to compute each vertex normal as the sum of the normals of all the faces it touches, and then normalize it (if you leave the face normals un-normalized for this step, face area will automagically be factored in). Note that you don't 'average' the normal by dividing by the number of faces; just normalize it and you'll be good to go.

As far as figuring out which faces touch which vertices, you can brute-force it, or compute connectivity info in advance (this is assuming that your mesh is irregular - in a regular mesh such as that based on a heightmap, the connectivity is implicit).

The brute-force approach might go something like this:
for each vertex    zero the vertex normal    for each face        for each face index            if the index corresponds to the vertex in question                add the face normal to the vertex normal    normalize the normal

##### Share on other sites
thank you for the reply, i must go sleep a bit now, but will comment quickly,

i did not realize about normalizing face normals,
for each vertex    zero vertex normal (because going to add to later-yes?)         for each face              find face normal and normalize//i dont quite understand by "face area factored in", should i be normalizing face normal here?                  for each face points that are this vertex                      add face normal to vertex normal    normalize normal

your's is very nice example of workflow - if you can maybe explain just for interest sake what you mean by
face area will automagically be factored in[\quote]
maybe just a brief explanation as this is too brief for me to make something of.also not quite sure whether i should/shouldn't normalize face normal as you say autoMAGICally which also confuse me :)

##### Share on other sites
What I mean by 'face normals will automatically be factored in' is ('automagically' isn't a 'real' English word, so we'll just leave that out :):

- The length of the cross product of two vectors is proportional to the area of the parallelogram (and therefore triangle) formed by the vectors

- Therefore, the length of the (un-normalized) normal to a triangle face is proportional to the area of that triangle face

- Therefore, when adding together the (un-normalized) normals of triangle faces that share a vertex, triangles with larger areas will 'contribute' more to the vertex normal

- Therefore, the vertex normals will favor ('lean towards') faces with larger area

In most cases, I doubt the visual effect will differ much depending on whether you normalize the face normals before or after computing the vertex normals, so I'd just do what makes the most sense to you.

##### Share on other sites
yes thank you, after i read here yesterday, i go think about it some more, and i did understand that larger areas might have longer normals,
and sorry about confusion over auto-magic-ally, i just thought perhaps it was not typo,

thank you again, the advice you have shared is so appreciated. it is also nice to try write out what you think should happen, i find it helps me to make more sense of a situation-or find where not making sense.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634048
• Total Posts
3015236
×