godot icon indicating copy to clipboard operation
godot copied to clipboard

Blender/GLTF vertex coloring is changed on import.

Open bertodelrio256 opened this issue 1 year ago • 4 comments
trafficstars

Tested versions

reproducible in v4.3.dev6.mono.official [89850d553]

System information

Godot v4.3.dev6.mono - Windows 10.0.19044 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 31.0.15.5161) - AMD Ryzen 9 5950X 16-Core Processor (32 Threads)

Issue description

issue possible related to https://github.com/godotengine/godot/issues/87486.

when exporting a mesh from blender 4.0 to using gltf, the vertex colors are not imported correctly and appear different in godot. attach is a screenshot of the vertex colors in blender and the imported result in godot. the data has been changed as you see jagged edges / harder transitions in the colors as well as slighter darker colors. (is vertex color being compressed?). if you export from blender to gltf and then reimport, you will see there is no change in the colors. (blend file attached)

vc issue

Steps to reproduce

-create a mesh in blender 4.0 with a range of vertex colors (colors near black seem to be problematic the most) -export the mesh using the gltf exporter in blender -import the glb file in godot and apply an unshaded material which displays the vertex color to albedo

Minimal reproduction project (MRP)

vc issue MRP.zip

bertodelrio256 avatar May 26 '24 23:05 bertodelrio256

Is this potentially related to what this asset is trying to fix? https://godotengine.org/asset-library/asset/2905 changed behaviour in Blender 4.1.

tiloc avatar May 27 '24 06:05 tiloc

Is this potentially related to what this asset is trying to fix? https://godotengine.org/asset-library/asset/2905 changed behaviour in Blender 4.1.

No, thats an issue with the gltf exporter not exporting vertex color at all in 4.1 (which was fixed in 4.2 here btw https://github.com/KhronosGroup/glTF-Blender-IO/pull/2233). oops sorry this actually applies to blender 4.0 i meant. I will update the description.

bertodelrio256 avatar May 27 '24 13:05 bertodelrio256

I was about to open a new issue with a problem importing a GLB model with color attributes. I have almost zero experience with Blender but I think vertex coloring is the same as using color attributes in Blender (with domain set to Vertex). Since this is a voxel based model with a clearly defined texture (the eyes in the face and other details) it is easy to see that the colors are incorrectly applied. But if you open the advanced importer dialog in Godot then it looks fine so Godot is reading the format without issues. image image assets.zip I attach the assets in case they make easy to debug this or to see if I am dong something wrong on my end.

diegopau avatar Aug 17 '24 15:08 diegopau

This may be caused by mesh LOD generation, which can have trouble with vertex colors if they're designed to have hard edges (by having vertices be very close to each other). Try disabling Meshes > Generate LODs in the import options.

Calinou avatar Aug 17 '24 20:08 Calinou

@Calinou That worked for my case, thanks!! so then my issue was a different one than the described in the first post.

diegopau avatar Aug 18 '24 09:08 diegopau

Untitled-1 I just wanted to show this comparison which shows that there is way more saturated red in the imported colors in godot as seen here. This is was just done in godot 4.3 where the issue remains.

bertodelrio256 avatar Aug 30 '24 17:08 bertodelrio256

just a thought but, is it possible the vertex colors are being compressed somehow by godot on import?

bertodelrio256 avatar Nov 30 '24 22:11 bertodelrio256

just a thought but, is it possible the vertex colors are being compressed somehow by godot on import?

You can force disabling mesh compression in the Import options (Force Disable Compression).

Calinou avatar Dec 04 '24 00:12 Calinou

just a thought but, is it possible the vertex colors are being compressed somehow by godot on import?

You can force disabling mesh compression in the Import options (Force Disable Compression).

oh? I thought that mesh compression only compressed the vertex positions. it does colors and uvs as well?

bertodelrio256 avatar Dec 04 '24 16:12 bertodelrio256

oh? I thought that mesh compression only compressed the vertex positions. it does colors and uvs as well?

According to its description, it compresses normals and UVs at least.

Calinou avatar Dec 05 '24 09:12 Calinou

this is resolved. the problem was that I was passing COLOR.rgb into a varying in vertex then using that in fragment (causing it to change for some reason). when using COLOR.rgb directly in fragment that issue is gone.

bertodelrio256 avatar Jan 15 '25 00:01 bertodelrio256