Crash when spawning a gltf mesh with morph targets
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
0.11.2
## Relevant system information
Windows 10
```
AdapterInfo { name: "NVIDIA GeForce GTX 1650", vendor: 4318, device: 8081, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "537.58", backend: Vulkan }
```
## What you did
I have a gltf model with shape keys/morph targets that I made in Blender. Previously I was spawning it as a Scene without any issues, using `#Scene0` syntax. Yesterday I've tried spawning it as a Mesh, using `#Mesh0/Primitive0` syntax. It results in a crash.
## What went wrong
### What was I expecting?
Expected it to work the same way it worked when it was just a Scene. Other models (that do not have shape keys/morph targets) don't crash when they are spawned as Meshes.
### What actually happened?
```
2023-11-05T13:35:46.833577Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread '' panicked at C:\Users\x\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.16.3\src\backend\direct.rs:3019:5:
wgpu error: Validation Error
Caused by:
In a RenderPass
note: encoder = ``
In a draw command, indexed:true indirect:false
note: render pipeline = `pbr_prepass_pipeline`
The pipeline layout, associated with the current render pipeline, contains a bind group layout at index 2 which is incompatible with the bind group layout associated with the bind group at 2
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in exclusive system `bevy_render::renderer::render_system`!
thread 'Compute Task Pool (3)' panicked at C:\Users\x\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_render-0.11.2\src\pipelined_rendering.rs:143:45:
called `Result::unwrap()` on an `Err` value: RecvError
error: process didn't exit successfully: `D:\dev\bevy_workspace\target\debug\morph_mre.exe` (exit code: 101)
```
## Additional information
### Minimal reproducible example
https://github.com/5tr1k3r/morph_mre
Run with `cargo run --features bevy/dynamic_linking`
### Theories about what might be going wrong
Spawning a Scene results in four entities in a hierarchy. When I spawn a mesh without morph targets as a Scene, most of the time three higher level entities (parents) are useless to me: I just want the innermost entity (mesh).
When I spawn a mesh with morph targets, though, the direct parent of the innermost mesh entity seems to be involved as well: it contains `MorphWeights` component:

When I try spawning it as just a Mesh, it results in one entity only, which is why I think that's directly related to the crash. But I wasn't able to find any workarounds.
### Suggestion
I think having just `MeshMorphWeights` on the innermost mesh entity should be supported, without needing to have the parent entity with `MorphWeights`.
Contributor guide
Research direction
Run the linked morph_mre with `cargo run --features bevy/dynamic_linking` and reproduce the validation error when spawning `#Mesh0/Primitive0`. Start with `bevy_render::renderer::render_system` and the reported `pipelined_rendering.rs:143` panic, then trace mesh morph-target handling. Done means the glTF mesh with morph targets can spawn without the bind-group validation crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100