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

Vulkan: Incorrect glTF mesh rendering due to automatic LOD kicking in too early with scaled bones #57895

Closed
Tracked by #57416
lucasabbas opened this issue Feb 10, 2022 · 16 comments · Fixed by #65493
Closed
Tracked by #57416

Comments

@lucasabbas
Copy link

lucasabbas commented Feb 10, 2022

Godot version

4.0 Alpha 2

System information

Windows 11, Vulkan, AMD Radeon RX 5700 XT

Issue description

Screenshot 2022-02-09 175650
Screenshot 2022-02-09 175628

Steps to reproduce

Import a GLTF Mesh into a 3D Scene

Minimal reproduction project

(https://drive.google.com/file/d/1-CfrKX1gIe6pAInUdzXSVZg63TRjLkzU/view?usp=sharing)

@fire
Copy link
Member

fire commented Feb 10, 2022

The Google drive is not public.

@mrjustaguy
Copy link
Contributor

This is Mesh LOD related.

@Calinou
Copy link
Member

Calinou commented Feb 10, 2022

As a workaround, set rendering/mesh_lod/lod_change/threshold_pixels to 0.0 in the Project Settings to disable the rendering of automatic mesh LOD. To disable LOD temporarily in the editor, click the Perspective menu in the top-left corner of the 3D viewport and select Display Advanced… > Disable LOD. You can also use the Display Wireframe debug draw mode to check how different LOD levels look.

You can also disable LOD generation on specifc imported 3D scenes in the Import dock:

image

@Calinou
Copy link
Member

Calinou commented Feb 12, 2022

Reopening, as this issue should still be fixed 🙂

I can confirm this on master a0558b8. All the LOD settings are at their default, so I don't know why this is happening. Object scales are also set to their defaults, though I don't know if you used a very large (or small) scale in your 3D DCC (such as Blender) for the character model. cc @fire

For easier reproduction, I edited the MRP to only include essential files: Mesh Rendering Bug_1.zip

@Calinou Calinou reopened this Feb 12, 2022
@Calinou Calinou changed the title GLTF Mesh Rendering Bugs Vulkan: Incorrect glTF mesh rendering due to automatic LOD kicking in too early (with default settings) Feb 12, 2022
@reduz
Copy link
Member

reduz commented Feb 12, 2022

@JFonS

@fire
Copy link
Member

fire commented Feb 12, 2022

The scale is weird.

editor_screenshot_2022-02-12T034043

The parent node of the skeleton has a 0.01 scale node and then the skins are 100 times bigger.

@Zireael07
Copy link
Contributor

Zireael07 commented Feb 12, 2022

@fire: I had some meshes like that - I had to manually change scales and/or reexport, a quirk of export/import from Blender maybe? (Besides, Blender export/import could really stand a better documentation so that people don't get those weird size issues)

@Calinou Calinou changed the title Vulkan: Incorrect glTF mesh rendering due to automatic LOD kicking in too early (with default settings) Vulkan: Incorrect glTF mesh rendering due to automatic LOD kicking in too early with scaled bones Feb 14, 2022
@YuriSizov YuriSizov moved this to To Assess in 4.x Priority Issues Feb 17, 2022
@akien-mga
Copy link
Member

As per #59147 (comment) it seems the problem might be a bug in the mesh itself.

@Calinou
Copy link
Member

Calinou commented Mar 18, 2022

Is there a way to detect such meshes and warn on import that the mesh itself should be fixed?

@fire
Copy link
Member

fire commented Mar 19, 2022

Typically I see this problem happen when the scale is different from Vector(1,1,1). Maybe warn on this. Sign is important too.

The most common case of lod failing is the mesh Ref having Vector3(0.01, 0.01, 0.01).

The global scale of the skeleton node is then set to Vector3(100, 100, 100).

@reduz
Copy link
Member

reduz commented Apr 2, 2022

Maybe we could detect a scale in the armature and apply this to the LOD process, or apply the armature before doing the LOD? (since we mostly care about the resulting indices anyway).

@mrjustaguy
Copy link
Contributor

The problem is probably with the AABB being incorrect for skinned meshes when any scaling/rotation/translation is done on the bones, be it rest or pose. This is why it's aggressively scaling, because the AABB it's using to determine scale is tiny compared to the mesh.

I've noticed this when I was working with MakeHuman Rigged meshes with the wrong settings used on export that caused the AABB to be rotated by 90 degrees and 10x smaller compared to what it actually was.. Fixing said settings on export fixed the rig so that it wasn't scaled and rotated anymore, and suddenly ALOD was working fine. the LOD meshes haven't changed, just their sensitivity.

@fire
Copy link
Member

fire commented Jun 15, 2022

May be resolved by #60115. Importer option for permanent scaling of the scene.

Settings

Scene scale set to 0.01.

Root scale set to 100.

Still has problems > 100m.

2022-06-15_06-49-58.mp4

@nathanfranke
Copy link
Contributor

Was this resolved in #65493?

@clayjohn
Copy link
Member

Was this resolved in #65493?

@fire says it does in #65493 (comment)

Closing as fixed by #65493

Repository owner moved this from Todo to Done in 4.x Priority Issues Sep 14, 2022
@fire
Copy link
Member

fire commented Sep 14, 2022

I tested #65493 and manually confirmed it is fixed.

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