Quote:Original post by dachande
I *think* I'm beginning to understand - does that mean that for all the 20 matrices that have been set as constants in the vertex shader, that only 3-4 of those matrices will actually be used on any one vertex?
Yes.
Quote:Setting all the matrices at the beginning of the render speeds things up, as setting constants before drawing each bone is too slow.
No.
It's not just an optimization, it's needed. First lets consider a simple case.
1---2| /|| / ||/ |3---4
Lets say vertex 1 uses bone 1, and vertex 2-4 use bone 2. How can you render that one bone at a time? You can't. You have to render full faces.
1--2,5--7| /| /|| / | / ||/ |/ |3--4,6--8
The middle vertices are split such that we can assign different bones (this isn't really done, this is just trying to make the faces use individual bones).
Now lets say vertices 1-4 use bone 1, and vertices 5-8 use bone 2. Now lets translate bone 2 to the side.
1---2 5---7| /| | /|| / | | / ||/ | |/ |3---4 6---8
Hmm. We've got a hole in the mesh. Unless different vertices of the same face use different bones, you cannot avoid holes. If a face uses more than 1 bone, then we can't possibly render one bone at a time.
Ok, so then how do you render them?
x..x.. . . .. a..x|\ .| \.b--c---d...x\ | /. .. \ | / . . . \|/ .. . e...x...x
Imagine this L shaped "elbow" joint... I've greyed out some vertices and faces to show the shape. The bone assignments here would be as this:
(single influence)
a,b,c = bone1
d,e = bone2
In this case, all three polys around the joint need 2 bones. Using a single bone per vertex can produce ugly artifacts though. Great for metal objects, like robot arms.
(2 influences)
a = bone1
b = bone1 70%, bone 2 30%
c = bone1 50%, bone 2 50%
d = bone2
e = bone1 30%, bone 2 70%
In this case, not only do the three polys require 2 bones, but most of the vertices require 2 bones. Extra influence, and gradually changing influences can produce nice curved joints. Great for organic fleshy objects that have a curve to their joints.