godot
godot copied to clipboard
Import of gltf with blendshapes without tangents fails
Tested versions
- Not reproducible in 4.2beta5
- Reproducible in 4.2beta6 through 4.2.1
System information
Godot v4.2.beta6 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3090 (NVIDIA; 31.0.15.3713) - Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (16 Threads)
Issue description
Importing a gltf file without tangents in the editor with Ensure Tangents unchecked will fail for all meshes containing blend shapes with the following error log:
Blend shape format must match the main array format for Vertex, Normal and Tangent arrays.
scene/resources/mesh.cpp:1802 - Condition "err != OK" is true.
scene/resources/mesh.cpp:1923 - Index p_idx = -1 is out of bounds (surfaces.size() = 0).
scene/resources/mesh.cpp:1943 - Index p_idx = -1 is out of bounds (surfaces.size() = 0).
servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp:891 - Index p_shape = 0 is out of bounds ((int)mi->blend_weights.size() = 0).
The same thing happens at runtime. Since there is no option to enable Ensure Tangents for runtime that I can find, this is not possible to workaround for runtime import.
The issue affects the https://github.com/V-Sekai/godot-vrm/ project, however it happens with these models in the builtin gltf importer.
issues may be related:
- #84875
- #85406 I filed this issue since it is easy to reproduce and leads to a missing mesh during import, but maybe solving those issues will also address this one.
Steps to reproduce
- Open the attached project.
- Clear the console and reimport Godette_vrm_v4.glb - this will produce errors.
- Open sample_scene.tscn and notice the models are all missing faces.
- Click play to run the project. This will run
load_at_runtime_scene.tscn
which loads a gltf at runtime. this is also missing the face and produces errors in the Debugger -> Errors tab. - Optional: enable "Ensure Tangents" in the import dock and notice that the glb files now contain a face in the editor. This does not solve the runtime case.
Minimal reproduction project (MRP)
Adding an additional MRP from a companion issue #85960: https://github.com/godotengine/godot/files/13623984/resource_loader_test.zip
for runtime import, we found that using gltf_document.append_from_file(path, gltf_state, 8)
works around the issue:
8 is the constant for EditorSceneFormatImporter.IMPORT_GENERATE_TANGENT_ARRAYS
Even though there is a workaround, I still think this is a bug: it only affects models with blend shapes.
I think this is related to another issue I raised in #86698 Perhaps we could close the one I opened and add the MRP from it to this issue?
I think this is related to another issue I raised in #86698 Perhaps we could close the one I opened and add the MRP from it to this issue?
https://github.com/godotengine/godot/issues/86698 is a different issue unfortunately, so we should leave it open