Skip to content

Panic when a mesh has morph target attributes but no MeshMorphWeights component. #21655

@greeble-dev

Description

@greeble-dev

Bevy version and features

3ca7b50 (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:

    for child in children.iter_descendants(scene_ready.entity) {
        commands
            .entity(child)
            .remove::<bevy::mesh::morph::MeshMorphWeights>();
    }

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 Fix panic when a mesh has skinning attributes but no SkinnedMesh component #18074 - use MeshMorphWeights as the source of truth and ignore the morph attributes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorP-CrashA sudden unexpected crashS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions