# Curious about calculating normals in an animated mesh...

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

## Recommended Posts

If I understand it correctly, most skeletal animation these days is done with vertex shaders. If that's the case, I wonder how the vertex normals are calculated for lighting purposes. If a vertex normal is typically the average of the face normals surrounding it, how is the vertex shader able modify the positions of the vertices without invalidating the vertex normals? And if it doesn't, how does the vertex shader know how to recalculate the vertex normals if it doesn't have access to information concerning the surrounding faces?

##### Share on other sites
Given a transformation matrix M applied to a vertex, all you have to do is transform that vertex's normal by the inverse transpose of M.

##### Share on other sites
I guess I should've learned more about skeletal animation before I asked this question. I know that each bone has a position, and that a full matrix can be calculate for each bone depending on its position relative to other bones in the hierarchy. I'm guessing that what you are suggesting is that I transform the vertex by that matrix, and then transform the normal by the inverse transpose of that matrix?

A lot of questions come to mind. For instance, even if the vertex in question is 100% weighted to a specific bone, isn't it true that a nearby vertex on an adjacent face might be assigned to a different bone, thereby messing up the normal even if I use the inverse transpose as you suggested?

##### Share on other sites
Quote:
 Original post by CDPropI'm guessing that what you are suggesting is that I transform the vertex by that matrix, and then transform the normal by the inverse transpose of that matrix?
Yes, that sounds right.

Quote:
 Original post by CDPropFor instance, even if the vertex in question is 100% weighted to a specific bone, isn't it true that a nearby vertex on an adjacent face might be assigned to a different bone, thereby messing up the normal even if I use the inverse transpose as you suggested?
Yes, that sounds like a possibility, but I suspect this situation would be an intentional 'crease' where you'd want a sudden change. If you want smooth skinning/normals then you'd have them assigned to the same bone with appropriate weights. Check with a modelling artist if you can [smile]

hth
Jack

1. 1
Rutin
26
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 10
• 9
• 9
• 46
• 41
• ### Forum Statistics

• Total Topics
631750
• Total Posts
3002067
×