I am trying to get shadowmapping right for my animated models. It works perfectly for static meshes but the animated models are just wiggeling a bit
here's the vertex shader for rendering to the depth texture:
#version 400 core
in vec4 inputPosition;
in vec3 inputNormal;
in vec2 inputTexCoord;
in vec4 weights;
in vec4 joint_index;
uniform mat4 bone_matrix[65];
uniform int animate;
uniform mat4 depthMVP;
void main(){
vec4 pos = inputPosition;
if(animate != 0) {
pos = vec4(0);
vec4 post = inputPosition;
for(int i=0;i<4;i++) {
if(weights[i]>0) {
pos += (bone_matrix[int(joint_index[i])] * post) * weights[i];
}
}
}
gl_Position = depthMVP*vec4(pos.xyz, 1);
}
The animation works fine in the second pass but during the first using the vertex shader above the model vertices don't get transformed instead the whole model rotates a little so i get a depth texture with my model in binding pose rotating around the y-axis a little. Weird because i use the exact same bone transformation code as in the second pass shader. So i'm wondering am i missing something crucial in the vertex shader above