godotengine / godot

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

Gltf bones do not import with correct positions, causing animations to break. #66479

Open prominentdetail opened 2 years ago

prominentdetail commented 2 years ago

Godot version

3.4.5

System information

windows 10

Issue description

Importing gltf with bones will position them incorrectly. This causes the animations to be incorrect and the model to morph weirdly. The top of the picture shows the incorrect bones, and the bottom shows the correct bones. godotbonebug

In other programs, the gltf opens just fine with the corrrect bone positions and animates correctly, However, when it comes to Godot, godot fails to load them correctly.

Here's another example, You can see clearly how the bones in godot don't have the correct angle. godotbonebug2

Steps to reproduce

Here is the simple box example gltf. boxgltf.zip

Minimal reproduction project

No response

TokageItLab commented 2 years ago

At least half of this issue is not a bug.

Blender uses the Head-Tail format, while most other 3D software uses the Node format; in the Node format, the Tail is not existed and is treated as just an angle without position, so it is not visualized in Godot 3.x (it is visualized as bone axis in 4.0).

In other words, Blender allows the octahedron to be oriented in a direction that has nothing to do with parent-child relationships, while other 3D software forces the octahedron to be oriented from parent to child. Consequently, in Blender the octahedron orientation and BoneAxis synced, but in other software the octahedron and BoneAxis are treated as separate concepts. This is just a difference in visualization methods, and it does not cause the animation to break.

I don't know why the mesh and bones are offset, it could be something wrong with the EditBone bindings in Blender, or it could be that the Rest is set up corruptly when Godot imports it.

prominentdetail commented 2 years ago

@TokageItLab , I'm not using Blender. The gltf files weren't exported from Blender. I'm not sure what you mean. I just know that when importing into Godot, godot changes the positions and angles of the bones, causing the animations to become inaccurate. Importing it into other programs work fine though, so I assume it is a problem with Godot.

TokageItLab commented 2 years ago

@prominentdetail If you have imported an external gltf into Blender and seen it work, it may be due to a problem with Blender's gltf importer changing the axis of the bone by default, see also https://github.com/KhronosGroup/glTF-Blender-IO/issues/1662. Has the animation been included in the gltf before you imported it into the other application? If the animation was created in Blender, it may not work since the bone axes change between the gltf imported into Blender and the gltf imported into godot. In this case, the bone dir settings for importing models into Blender must be changed from Temperance to Blender. Then check that the animation is working properly. Or, check it in an environment other than Blender that can render a plain gltf, such as three-js not unity.

prominentdetail commented 2 years ago

@TokageItLab , I didn't use Blender to create the gltf or animation. It was created in another program. I tested importing it into Blender, and it imported fine. I tested in an online gltf viewer, and it loads everything fine (https://gltf-viewer.donmccurdy.com/). Importing into any program works except Godot. Godot messes up the bones. I'll repeat, I'm NOT using Blender. This isn't a Blender issue.

TokageItLab commented 2 years ago

@prominentdetail Can you confirm the problem with Godot 4? This may be a 3.x specific bug, and may be related #60345 or #49974.

prominentdetail commented 2 years ago

@prominentdetail Can you confirm the problem with Godot 4? This may be a 3.x specific bug, and may be related #60345 or #49974.

I just tested 4.0 and It looks like it imports the animations fine in 4.0

TokageItLab commented 2 years ago

cc @fire

fire commented 2 years ago

We did a gltf upgrade in summer 2021, maybe a fix got lost.

TokageItLab commented 2 years ago

Also may be related by https://github.com/godotengine/godot/issues/62403.

prominentdetail commented 2 years ago

Thanks for looking into this! 👍

aaronfranke commented 2 months ago

Does this issue occur in Godot 4.x, such as Godot 4.3 stable, or is it only in Godot 3.x?

prominentdetail commented 2 months ago

@aaronfranke I just tested importing animations in 4.3 stable and there are still bugs with importing. I will create a new report.

edit: I'm not sure if the 4.3 issue is related to this specific issue though or if it is a new one.

fire commented 2 months ago

image

The positions of Godot Engine 4.3 and Blender 4.2.1 match. There is no animation.