Panic when a mesh has morph target attributes but no `MeshMorphWeights` component.
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version and features
3ca7b5048af9ca5bfa5a57f5ddd5c47945ab4808 (18.0-dev, 2025/10/25)
## What you did
Loaded a mesh with morph targets, then spawned it on an entity with `Mesh3d` and `MeshMaterial3d` components but no `MeshMorphWeights` component.
Original Discord report: https://discord.com/channels/691052431525675048/1431281153918111836/1431281153918111836
For a minimal repro, open `examples/animation/morph_targets.rs` and paste this at the bottom of the `play_animation_when_ready` function:
```rust
for child in children.iter_descendants(scene_ready.entity) {
commands
.entity(child)
.remove::();
}
```
## What went wrong
```
ERROR wgpu::backend::wgpu_core: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (6)' panicked at .cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\backend\wgpu_core.rs:2391:18:
wgpu error: Validation Error
Caused by:
In a CommandEncoder
In a draw command, kind: MultiDrawIndirectCount
The BindGroupLayout with 'mesh_layout' label of current set BindGroup with 'model_only_mesh_bind_group' label at index 2 is not compatible with the corresponding BindGroupLayout with 'morphed_mesh_layout' label of RenderPipeline with 'pbr_opaque_mesh_pipeline' label
Expected entry with binding 2 not found in assigned bind group layout
Expected entry with binding 3 not found in assigned bind group layout
```
## Additional information
I'm fairly confident this issue is largely the same as #16929. See #18074 for more details.
- The gist of the skinning bug is that one part of the renderer picks the skinning bind group because the mesh has skinning attributes, while another part of the renderer picks the non-skinning bind group because the `SkinnedMesh` component is not present.
- So if one is present and the other is not then there's a bind group mismatch.
- This morph target bug is probably the same but with morph attributes and a missing `MeshMorphWeights` component.
- The morph attributes check is in `setup_morph_and_skinning_defs` (see `is_morphed`).
- The `MeshMorphWeights` check is in `extract_morphs`.
- The fix might be similar to #18074 - use `MeshMorphWeights` as the source of truth and ignore the morph attributes.
Contributor guide
Assessment
This issue has not been assessed yet.