So I have a nice animation blending system that allows me to transition from one animation to another seamlessly.

I was originally blending the position, rotation, scale individually but then I rewrote it to blend the matrices themselves, both as a slight optimization and as a fix for a horrible bug I won't go into.

Here's the code I use to blend two matrices from transform 0 to transform 1.

transform[0] = (transform[0] * (1.0f - m_transitionWeight)) + (transform[1] * m_transitionWeight);

This is very similar to the math inside the GLSL skinning shader so I'd think this would work.

//skinning mat4 transformedMat = bones[int(boneIndices[0])] * weights[0]; transformedMat += bones[int(boneIndices[1])] * weights[1]; transformedMat += bones[int(boneIndices[2])] * weights[2]; transformedMat += bones[int(boneIndices[3])] * weights[3];

Now my animation went from blending perfectly, to having my character's legs shrink a bit when it's part way in the animation. It's the Doom 3 space marine aiming up, then aiming straight. This blending system makes his body turn to positions in between aiming up and straight to let him aim in any direction, but with my matrix math tweak his legs randomly shrink a bit as well.

I did some reading and I guess this has something to do with the rotations needing to be properly slerped, which was happening when I was interpolating rotation, position, scale individually. But when I tried to blend matrices, the rotation slerping was gone. I'm still a bit fuzzy as to why this works properly for vertex skinning.

**Edited by ill, 23 February 2013 - 08:25 PM.**