godotengine / FBX2glTF

A command-line tool for the conversion of 3D model assets on the FBX file format to the glTF file format.
Other
350 stars 91 forks source link

Fbx GeometricTransformation support is problematic #56

Open hu-xd opened 6 months ago

hu-xd commented 6 months ago

Godot version

Fbx2Gltf commit 6154391

System information

Windows 11

Issue description

Fbx GeometricTransformation support is problematic See Code, current logic is "Apply the geometric transform to the mesh geometry (vertices, normal etc.)"

but this is problematic since a mesh can be shared by several nodes with different GeometricTransformation, so in this scenario, effectively only 1 node will actually use its GeometricTransformation, other nodes' GeometricTransformation-s will be ignored, since the mesh/surface will only be loaded once.

Steps to reproduce

Build an model in 3DMax with several nodes that share the same mesh/instance but with different object-offset, export it as FBX. Convert the FBX file to GLTF/GLB with Fbx2Gltf. View the GLB file and see those geometries are incorrect.

Minimal reproduction project

N/A

hu-xd commented 6 months ago

Fix proposal: Do not apply the GeometricTransformation to the vertices/normals, instead, if GeometricTransformation exists, create another GltfNode as the child of current node, use the GeometricTransformation as the transformation of that child node, and attach the GltfMesh to that child node.

fire commented 6 months ago

We don't have an approach to solving geometric transformations in fbx2gltf.

We have a private test case for geometric transformations that passes with the new https://github.com/godotengine/godot/pull/81746 ufbx implementation. Godot Engine is moving to a new ufbx implementation so FBX2gltf will have less enhancements done for it.

If you wish to provide a pull request for fixing geometric transforms we can review.

hu-xd commented 6 months ago

What do you think of the fix proposal above ? I see OpenSceneGraph has a similiar solution: insert a layer in the node hierachy to hold the geometric transform. See Here

fire commented 6 months ago

It might work.

fire commented 2 months ago

We added geometric helpers to ufbx support. https://godotengine.org/article/introducing-the-improved-ufbx-importer-in-godot-4-3/