godotengine / godot

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

.blend files import vertex colors inconsistently #97953

Open Knairda0 opened 4 days ago

Knairda0 commented 4 days ago

Tested versions

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:

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

fire commented 4 days ago

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.

TheSofox commented 3 days ago

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 commented 3 days ago

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).