Skeletal Animation

Again, can you please point us to where you are undoing the bindpose? I don’t see that in your code.

I personally do it in the shader.

Code has been snipped.

#version 400 core

layout (location = 0) in vec4 vert_pos;
layout (location = 5) in float matrix_index;
layout (location = 7) in vec4 joint_indices;
layout (location = 8) in vec4 joint_weights;

layout(std140) uniform model_matrix_buff { uniform mat4 model_matrix[32]; };
layout(std140) uniform anim_joint_buff { uniform mat4 joint_matrix[1024]; };
layout(std140) uniform inv_bind_buff { uniform mat4 inv_bind_matrix[1024]; };

uniform mat4 projection_matrix = mat4(1.0);
uniform mat4 view_matrix = mat4(1.0);

void main()
{
	vec4 t_pos = 
	    ((vert_pos * inv_bind_matrix[int(joint_indices.x)] * joint_matrix[int(joint_indices.x)]) * joint_weights.x) +
	    ((vert_pos * inv_bind_matrix[int(joint_indices.y)] * joint_matrix[int(joint_indices.y)]) * joint_weights.y) +
	    ((vert_pos * inv_bind_matrix[int(joint_indices.z)] * joint_matrix[int(joint_indices.z)]) * joint_weights.z) +
	    ((vert_pos * inv_bind_matrix[int(joint_indices.w)] * joint_matrix[int(joint_indices.w)]) * joint_weights.w);
        
	gl_Position = projection_matrix * view_matrix * model_matrix[int(matrix_index)] * t_pos;
}

You have to undo the bind position, that’s what the inverse bind pose is for, I don’t see you actually using it.

I really want to fix this problem, but the hours I’ve spent scrutinizing my code hasn’t paid off one bit. Did you figure anything out on your end?

EDIT: I suggest you check the part where you build the frame skeletons while loading the .md5anim file.

Just to ensure we’re talking about the same things here:

Skinning equation:

for i to n
v += {[(v * BSM) * IBMi * JMi] * JW}

[i]n[/i]:     The number of joints that influence vertex v
[i]BSM[/i]: Bind-shape matrix
[i]IBMi[/i]: Inverse bind-pose matrix of joint i
[i]JMi[/i]:   Transformation matrix of joint i
[i]JW[/i]:   Weight of the influence of joint i on vertex v

We should precompute (v * BSM) and (IBMi * JMi) since they are constants.

Yes, we’ve already established that.

I really want to find some way to fix this, because skeletal animation is one of the more difficult techniques to understand and it’s a lot more difficult to implement. Lots of people who do OGL development and plan to do 3D game development in OGL get discouraged when they get to skeletal animation.

I created a GIF of my animation. You can tell it’s the Bob model, but it doesn’t…look right. Here ya’ go:

https://anuj-rao.tinytake.com/sf/ODUxODQxXzM3MDUxMzY

Yeah, sorry, it isn’t textured. I just set the colour to be the vertex positions.

stupid question but … can this be a matrix column-row major or Y/Z up mix-up ?

I forget to say that my code implements the multimesh model animation.

And maybe obsolete advice from http://www.gamedev.net/topic/665992-collada-animation-leads-to-distorted-model/?view=findpost&p=5212149

I’m using JOML, so it’s not a column-row major problem. I’m aware that there’s a Y/Z up mix-up, I’m fixing that right now.