diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index d97ab7a5cd..e57dd38f4a 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -1596,6 +1596,7 @@ pub fn queue_shadows( render_material_instances: Res>, mut pipelines: ResMut>>, pipeline_cache: Res, + render_lightmaps: Res, view_lights: Query<(Entity, &ViewLightEntities)>, mut view_light_shadow_phases: Query<(&LightEntity, &mut RenderPhase)>, point_light_entities: Query<&CubemapVisibleEntities, With>, @@ -1661,6 +1662,16 @@ pub fn queue_shadows( if is_directional_light { mesh_key |= MeshPipelineKey::DEPTH_CLAMP_ORTHO; } + + // Even though we don't use the lightmap in the shadow map, the + // `SetMeshBindGroup` render command will bind the data for it. So + // we need to include the appropriate flag in the mesh pipeline key + // to ensure that the necessary bind group layout entries are + // present. + if render_lightmaps.render_lightmaps.contains_key(&entity) { + mesh_key |= MeshPipelineKey::LIGHTMAPPED; + } + mesh_key |= match material.properties.alpha_mode { AlphaMode::Mask(_) | AlphaMode::Blend