godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.05k stars 21.18k forks source link

Armature transforms break root motion #39942

Open Cwiiis opened 4 years ago

Cwiiis commented 4 years ago

Godot version: 3.2.2

OS/device including version: Windows 10, GLES3

Issue description: When exporting models from Blender that include root motion, often the root motion only works with specific export formats, presumably depending on the armature orientation. I have a model that only works with FBX export (but unfortunately has glitches when using FBX) and doesn't work with Collada or gltf, where as models from Mixamo work using Collada, but exhibit the same issue as my problem model when exported as FBX. The animations always display correctly, so I presume that the root motion calculations are missing a transform somewhere? I would expect root motion to always work if the visualisation of the bone displays correctly (which it does).

Steps to reproduce: Export a model with an armature that has a root motion bone and animations that rely on it, using BetterCollada and Blender's native FBX export. Import in Godot and add an AnimationTree and RootMotionView with the correct parameters. Play an animation via the AnimationTree that relies on root motion and inspect the RootMotionView visualisation. With default settings, likelihood is that root motion will only work on one of these exports. FBX export gives you the option to change the primary and secondary bone axis, but no such option exists with BetterCollada or Blender's gltf export (which functionally acts the same as BetterCollada).

Minimal reproduction project: This minimal reproduction project uses a model from Mixamo. In this situation, the model renders correctly in either format so there's an easy work-around, but in my actual situation, the model (which I can't distribute) exhibits artifacts when exported as FBX, but root motion only works with FBX. Root motion bug.zip

Calinou commented 4 years ago

cc @RevoluPowered

fire commented 4 years ago

@Cwiiis gltf import from Blender has the ability to change the bone direction. We've added "Fortune" and "Temperance" bone direction processing in Blender. However, it doesn't show the option on export.

Will look at your export in a bit.

Cwiiis commented 4 years ago

@Cwiiis gltf import from Blender has the ability to change the bone direction. We've added "Fortune" and "Temperance" bone direction processing in Blender. However, it doesn't show the option on export.

Will look at your export in a bit.

Thanks - with my actual problem model (which I'm happy to talk about privately on Discord/via e-mail), I've tried all sorts of combinations of importing and changing the primary/secondary bone axis, before re-exporting as dae format, but I've not managed to get Godot to do anything sensible. With that model, root motion only seems to work with an FBX export, but then it seems some vertices are affected by the wrong bone and at least one animation appears with some corrupt vertex positions. Worth noting that the same FBX export re-imports fine with Blender and works fine with Unity, so that appears to be a separate issue with Godot's FBX import.

Cwiiis commented 4 years ago

Ah, I finally noticed the real difference between my models that work in FBX but not with DAE and vice-versa - if the root bone is rotated by 90 degrees on the x axis, it will work as FBX but not as DAE, and if it's unrotated, vice-versa. I guess this is because of how FBX exports from Blender? I notice the rotation disappears when imported in Godot when using FBX. Hopefully I can fix my model with this knowledge...

Cwiiis commented 4 years ago

Ok, the real problem is that transforms on the armature appear to be ignored, so applying the transform before export fixes the issue.

fire commented 4 years ago

How do you expect Godot to fix this? Documentation?

Cwiiis commented 4 years ago

The armature transform shouldn't affect root motion, surely? I expect Godot to multiply the inverse of the armature transform when calculating the root motion transform, but perhaps that's a bad expectation(?)

akien-mga commented 2 years ago

Is this still reproducible in the latest Godot releases? (3.5 beta 3, 4.0 alpha 6)