Skeletal animation - Rotations seem to be inverted

Started by
3 comments, last by bjorkdennis 2 years, 8 months ago

Hey!

For the last weeks I've been working on parsing collada files for use in my personal project. Quite recently I managed to get GPU skinning kind of working, there is only one flaw.

The mesh and the rig seems to load correctly and the model does not become deformed in the way it usually would if there was any fundamental errors in the math or shader.

The problem is that the animations I load seem to play correctly although the rotations that are applied seem to be inverted somehow. The animations work fine in Blender(which is where I create both model, rig, and exported .dae file). Here is a picture of the same keyframe side by side, one in Blender and one in my engine:

(Edit: The only bones that seem to transform correctly are both of the upper-legs which makes this whole thing even more strange)

An animation where the character bends forwards. After importing it to my engine it bends backwards instead.

At this point my limited knowledge in matrix math crumbles. I have tried to invert every axis in every way in the animation-transform that is applied to the joint, but the result were mostly extreme deformations.

I use Directx11 and to my knowledge they use row-major system. I make sure to Transpose the skinning matrices before I pass them to the vertex shader. Feel free to ask if you need any more info on the implementation part.

Any hints or thoughts are greatly appreciated!

Advertisement

Nice to see others suffer from this as well : ) I'm already working 4 days to remove dependency on Havok math lib from an old project, and such bugs is all i see.

bjorkdennis said:
The mesh and the rig seems to load correctly

It's really astonishing how things can look like seemingly ok, but in reality it's all broken. Seems especially true for character stuff.
So i would not be 100% sure.

bjorkdennis said:
I use Directx11 and to my knowledge they use row-major system. I make sure to Transpose the skinning matrices before I pass them to the vertex shader.

Beside that, there are many other such convention issues:
* Multiplication order. You may need to rewrite a x b with b x a if you use different math libs.
* Euler angles order. If you use them, make sure you use the same order as assumed from the DCC tools. Sometimes there are different orders mixed in the same skeleton, and order is specified per bone.
* To use w or not. Often all vec3 data is provided as vec4, and the last w component is often ignored and can be just wrong. Using such data in another application which does involve w in calculations can then break the data.

But what bugs me the most usually is resolving indirections wrongly. I have multiple mappings of bones, rigid bodies, joints, etc. Initial Havok data has a different order than my own data structures, and it's easy to confuse those things.

Likely nothing of this helps, but at least i can confirm it's common to fail and invest more time than wanted with this crap :D

@JoeJ Thank you for your reply! It does indeed confirm that I gotta go crunch a few matrix math lessons and go at it some more ?

But these hints will definitely help me along the way!

I'll make sure to post if I do come up with a solution, I'm betting it's something minor that has been glossed over by me a bunch of times :p

@joej So.. scrolling through my geometry loader I found an innocent looking line of code I had forgotten about.

finalVertex.z *= -1;

POOF everything is now working fine ?

Will go cry for a bit, I'll be fine.

This topic is closed to new replies.

Advertisement