A glTF file defines, for each skin, an array of inverse bind matrices and a list of joints.
Let's assume the list of joints is:
{2,5,7,4,3,6}
If we shift it so that the indices start at 0 we get
{0,3,5,2,1,4}
In this scenario inverse_matrix[2]
can refer to one of two things. It can either refer to the second joint in the array, that is to say, joint 5, or to joint 2.
This exact same question applies to the weights array.
Put in a different way. If one takes the data as is from the gltf file and loads the buffers into a shader. I need to figure out how to map a vertex index in the shader to its corresponding 4 skin matrices.
So if joints[2] maps to (3,1,0,0)
I need to know whether I am supposed to be fetching the inverse bind matrices at ibm[3]
and ibm[1]
or ibm[2]
and ibm[3]
(Since the value at joints[3]
is 2).
I hope this is not confusing.