Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoneMap retarget on FBX files or FBX2glTF conversions cause broken LODs #76892

Open
Tracked by #57416
lyuma opened this issue May 10, 2023 · 5 comments
Open
Tracked by #57416

BoneMap retarget on FBX files or FBX2glTF conversions cause broken LODs #76892

lyuma opened this issue May 10, 2023 · 5 comments

Comments

@lyuma
Copy link
Contributor

lyuma commented May 10, 2023

Godot version

4.1.dev 6980b2b

System information

Windows 10

Issue description

By default, Blender exports .fbx models at 100x scale. If an FBX model is converted into gltf by hand or imported to Godot with automatic FBX2glTF conversion, it handles this 100x scale by applying it directly onto the root nodes of the scene, such as Armature:
screenshot showing Armature at 100,100,100 scale

I now adjust the import settings to have a BoneMap and a SkeletonProfileHumanoid:
screenshot showing Aradvanced importer with BoneMap and SkeletonProfileHumanoid

and now the scale of Armature is 1,1,1, and the LODs are broken (due to Godot expecting a 100x scale difference):
screenshot showing Armature at 1,1,1 scale and LOD artifacts
You can see here that the scale was instead propagated into the skin bind pose:
screenshot showing mesh Skin at 100,100,100 scale

Steps to reproduce

  1. make a new scene and drag the the _rotated.fbx model or the _rotated_fbx2gltf.gltf models in.
  2. Change advanced import settings of the _rotated.fbx model or the _rotated_fbx2gltf.gltf model Skeleton3D node to have A BoneMap and assign a SkeletonProfileHumanoid inside the BoneMap.
  3. see these models in the scene.
  4. Observe the LOD artifacts (can be confirmed by disabling LOD)

Minimal reproduction project

https://github.com/godotengine/godot/files/11437148/BoneMap_non_skinned.zip
(Model is permissively licensed and available from https://booth.pm/ja/items/2019040 "2A-7-4 / XXXX Coolk")

@lyuma
Copy link
Contributor Author

lyuma commented May 10, 2023

This is related to #76891 and uses the same reproduction project, but it's a different problem.

Solving #76891 might help address some of the mesh scaling issues that cause this LOD issue.

Either the skin adjustment during retarget needs to lead to different LOD settings, or else there's still a bug when skin has 100x scale in bind poses.

@lyuma
Copy link
Contributor Author

lyuma commented May 16, 2023

I did some investigating. here is the cause of this bug:
unused_bone_incorrect_aabb

The issue is with bone_aabbs in RendererRD::MeshStorage::Mesh::Surface ... It seems that unused bones in this have a size of -1,-1,-1 instead of 0,0,0 as the code expects. Is this intentional?

To fix we either need to

  1. change unused bones to have size of 0,0,0 instead of an invalid AABB?
  2. Or detect an invalid AABB with -1,-1,-1 and avoid adding it to the laabb in the above code.

Now, as for why this matters, some meshes are scaled, so -1,-1,-1 can easily blow up to large bounding boxes like 100,100,100 as seen in the screenshot.

Due to another possible bug, the way LOD system chooses the lod_distance is the distance to the border of the AABB...... so if you're at the middle of a 100x100x100 AABB, the lod_distance will be 100, which makes Godot pick a very low quality LOD.
ideally, Godot would always pick the best LOD if the camera is within the mesh AABB, but that's a different bug / problem / design decision.

@lyuma
Copy link
Contributor Author

lyuma commented May 16, 2023

#76184 should also contain the fix for this bug.. didn't test it yet.

@fire
Copy link
Member

fire commented May 16, 2023

What is the test plan for this? How can I tell it works?

Can paper review too.

@fire
Copy link
Member

fire commented Jun 13, 2023

May be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants