godotengine / godot

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

Vulkan: Vertex colors glitch on 3D model due to automatic mesh LOD #57608

Open kevinloustau opened 2 years ago

kevinloustau commented 2 years ago

Godot version

v4.0.alpha.custom_build [2aee84c75]

System information

Windows 11

Issue description

https://user-images.githubusercontent.com/4235617/152444746-6d3e3279-3056-4ccc-a528-b92741715a07.mp4

Using vertex painting on a model. If I zoom/de-zoom on my model, there is a glitch as you can see above. It is working well in 3.4.2.

(Is it a LOD issue?)

Steps to reproduce

Files: cube vertex paint .blend + gltf.zip

Minimal reproduction project

vertex painting 3.4.2.zip vertex painting 4.0.zip

Calinou commented 2 years ago

I can confirm this on master fc09d783f.

(Is it a LOD issue?)

Yes, it's very likely. The automatic mesh LOD does support vertex colors, but it's possible that your particular mesh isn't well handled.

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

https://user-images.githubusercontent.com/180032/152448665-5d27d678-40ac-4cd1-9e6a-a077c62be587.mp4

fire commented 2 years ago

If there are not enough vertices for the vertex color to look correct, do we interpolate?, do we disable lod?, do we do some magical mesh processing?

If we want to disable LOD, how do we scan it?

If there are any non-white data in the vertex color channel do we disable lod? This doesn't feel like the right design.

One way to improve the current situation is to post a documentation note explaining due to the nature of removing vertex indices the index colors will be incorrect.

kevinloustau commented 2 years ago

From a user point of view, do this use case (low poly + vertex color) is a niche? If yes, to disable LOD in settings seems ok. As @fire said, to post a documentation note seems enough.

Calinou commented 2 years ago

From a user point of view, do this use case (low poly + vertex color) is a niche?

When working with low-poly meshes, automatic mesh LOD won't benefit you much. For your use case, it makes sense to disable LOD for all your imported low-poly meshes in the Import Defaults tab of the Project Settings.

If there are any non-white data in the vertex color channel do we disable lod? This doesn't feel like the right design.

LOD on vertex-colored meshes should definitely be kept in. I wonder if meshoptimizer could be modified to take vertex colors into account (essentially treating significant vertex color differences as sharp edges for the purposes of simplification). See also https://github.com/godotengine/godot/issues/53818.

fire commented 2 years ago

I think you can assign the 4 rgba channels to the attribute simplifier. Unknown worth.

fire commented 2 years ago

I think we can resolve this with a documentation entry.

lyuma commented 1 year ago

Can we investigate if it's possible to quickly mitigate this problem by passing vertex colors to meshopt?

RadiantUwU commented 3 weeks ago

Any updates? This issue has not been looked at in over 2 years.

fire commented 3 weeks ago

We've upgraded the LOD tooling in meshoptimizer but haven't tested the original cases.