uniform mat4 projectionMatrix;
uniform mat4 modelMatrix;
uniform mat4 viewMatrix;
uniform mat4 bonesMatrix[64];
in vec4 vertex;
in vec3 weights;
in vec3 joints;
void main(void){
mat4 animationMatrix =
weights[0] * bonesMatrix[int(joints[0])] + weights[1] * bonesMatrix[int(joints[1])] + weights[2] * bonesMatrix[int(joints[2])];
gl_Position = projectionMatrix*viewMatrix*modelMatrix*animationMatrix*vertex;
}
Notice which ones are uniforms. These are updated every draw(), while the others are the same every time from a VBO.
bonesMatrix: Up to 64 joints can be used in a model. It is a uniform, as the same list of bones are used for all vertices.
vertex: This is a vertex from the mesh that is going to be animated by 0 to 3 bones.
joints: The index of three joints for the current vertex.
weights: The weights to be used for the three joints. There is one set of weights for each vertex.