glTF vertex colors break when using COMPONENT_TYPE_UNSIGNED_SHORT #44798
Description
Godot version: 3.2.3
I've also tested on the 3.2 branch @ 541bc18
OS/device including version: macOS 10.15.7, Intel 2.4GHz 8-Core i9, AMD Radeon Pro 5500M 8GB, GLES3
Issue description: When exporting a glTF scene from Blender that uses vertex colors they are not correctly imported in Godot. In particular this is due to a recent change in the Blender 2.91 glTF exporter that changes the vertex colors from a VEC4
w/ FLOAT
(5126) components to a VEC4
w/ UNSIGNED_SHORT
(5123) components.
There is no option in Blender to force the component type, and Blender does not set the normalized flag in the relevant accessors which would also fix this issue.
The glTF spec does require that UNSIGNED_BYTE
and UNSIGNED_SHORT
components for COLOR_0
should be normalized, but I'm not sure if that means Blender should be setting the accessor flag, or if the importer should handle this.
Steps to reproduce:
- Generate a simple scene in Blender 2.8 that uses vertex colors and export it to glTF 2.0.
- Update to Blender 2.91 and export the same scene in the same way.
- Import both scenes into a Godot project and assign a spatial material with the "Use As Albedo" flag set to all relevant meshes.
- See how the scene that was exported from 2.8 correctly displays the colors, while the scene from 2.91 is likely entirely white.
Minimal reproduction project: gltf-test.zip
This example project contains two scenes, ship-float.tscn
which uses vertex colors packed as COMPONENT_TYPE_FLOAT
, and ship-ushort.tscn
which uses vertex colors packed as COMPONENT_TYPE_UNSIGNED_SHORT
. Otherwise they are identical.
I also have a commit in my fork that "fixes" this, but I'm not sure if it would be better to just override the normalized
flag on the accessor before calling _decode_accessor
, or if really this should just be handled over in the Blender exporter by setting the normalized
flag when they set the component type.