godot icon indicating copy to clipboard operation
godot copied to clipboard

.blend files import vertex colors inconsistently

Open Knairda0 opened this issue 1 year ago • 1 comments

Tested versions

  • Godot 4.3.stable
  • Blender 4.2.2 LTS

System information

MacOS 15.0.1 - M1 Pro - Vulkan (Forward+)

Issue description

Godot's Blender file importer inconsistently imports vertex colors on a per-mesh basis.

You CAN get around this by using the .glb exporter in Blender, and selecting "Use Vertex Color: Active," however, there is no such setting or default behavior for importing .blend files. image

Advanced import view for the example .blend file (note the white meshes with missing color) Screenshot 2024-10-07 at 4 10 19 PM

Advanced import view for an .glb export of the example .blend file (with colors working as intended): Screenshot 2024-10-07 at 4 19 01 PM

Steps to reproduce

After countless hours of testing and troubleshooting, I honestly don't know how to get around this without that .glb export setting. My guesses have been:

  • Separate meshes that share the same material, thus trying to access the "same" color attribute across multiple meshes, wouldn't import
  • Materials with specified OR unspecified color attributes using the Color Attribute material node
  • Specifying "Color Attribute Domain/Data Type" in Blender, (trying combos of Vertex Color, Face Corner, Byte Color)

However, I haven't been able to identify any consistent behaviors.

Minimal reproduction project (MRP)

The MRP contains the .blend file, .glb export, and a basic 3D scene with the models placed down.

blender-vertex-color-mrp.zip

Knairda0 avatar Oct 07 '24 20:10 Knairda0

We need to add that setting into the godot blend importer. I will be away next week so others may be able to review pull requests.

fire avatar Oct 07 '24 21:10 fire

In modules\gltf\editor\editor_scene_importer_blend.cpp we get parameters_map["export_vertex_color"] = "MATERIAL"; if Mesh colour export is set to true in the Editor.

However, if you check the documentation: https://docs.blender.org/api/current/bpy.ops.export_scene.html you'll see that this option means Export vertex color when used by material, hence why Vertex colours aren't being exported if there isn't a material attached.

TheSofox avatar Oct 08 '24 17:10 TheSofox

image

Switched the option from MATERIAL to ACTIVE in code and that seems to fix it. (Note, had to edit Blender file to update links to image files for textures).

TheSofox avatar Oct 08 '24 17:10 TheSofox

I've created a new PR that implements the full Enum dropdown in Godot Editor: https://github.com/godotengine/godot/pull/113129 and resolves this. It properly addresses the problem by doing what several here have suggested, rather than my previous PR that was a simplistic quick fix.

TheSofox avatar Nov 24 '25 21:11 TheSofox

Any thoughts on Default value for the implemented Dropdown? Right now, my PR defaults to Material which gives the same behaviour as the initial screenshot, but its easily changed to Active which resolves this issue.

TheSofox avatar Nov 25 '25 11:11 TheSofox

Typically we use the old value by default on existing files and use the new value on new files via a property

fire avatar Nov 25 '25 15:11 fire

So, that would be use Material on existing files that use colors=true, but use Active on any fresh new files? I can do that easily. EDIT: And done, pushed to PR.

TheSofox avatar Nov 25 '25 16:11 TheSofox