World, Bone and Normal Matrices,
Members - Reputation: 208
Posted 12 December 2012 - 10:38 AM
I have been thinking for a while about the relationship between World, Bone and Normal matrices as they pertain to vertex processing. Assuming I have a mesh with position and normal data that needs to be transformed, it seems like I must do one of three things:
1) Send each matrix individually to the vertex shader, and have it transform the position and normal values multiple times. So the vertex shader would entail a multiplication of the position by the bone and then the world matrices, and a multiplication of the normal by the bone-normal and then the world-normal matrices.
2) Pre-multiply the matrices on the CPU so that the position and normal values only require a single transform. Then the vertex shader would only require a multiplication of the position by a combined matrix, and a multiplication of the normal by a combined matrix.
3) Some partial combination of 1) and 2).
So I'm wondering, is there some "tried and true" way of doing this or does it really just depend on my situation? If I am CPU bound and I am trying to draw lots of individually positioned meshes, then option 1) makes more sense. If I am GPU bound and I am trying to draw a few very complex meshes, then option 2) makes more sense. But I can't help wondering if there is some clever technique that tends to get the best of both worlds; this is surely something that has been tackled by many a graphics programmer.
Any advice? Thank you for reading!
Crossbones+ - Reputation: 7439
Posted 12 December 2012 - 12:09 PM
Crossbones+ - Reputation: 3857
Posted 12 December 2012 - 12:23 PM
Also, often in human animation you wouldn't be using non-uniform scaling factors anyway, so you could use the same matrices for normals as you do for vertex positions (just disable the translation part in the vertex shader).