Skip to content

Commit

Permalink
Add MeshPipelineKey::LIGHTMAPPED as applicable during the shadow ma…
Browse files Browse the repository at this point in the history
…p pass. (#11910)

I did this during the prepass, but I neglected to do it during the
shadow map pass, causing a panic when directional lights with shadows
were enabled with lightmapped meshes present. This patch fixes the
issue.

Closes #11898.
  • Loading branch information
pcwalton authored Feb 17, 2024
1 parent 4f87024 commit 5ce0d36
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,7 @@ pub fn queue_shadows<M: Material>(
render_material_instances: Res<RenderMaterialInstances<M>>,
mut pipelines: ResMut<SpecializedMeshPipelines<PrepassPipeline<M>>>,
pipeline_cache: Res<PipelineCache>,
render_lightmaps: Res<RenderLightmaps>,
view_lights: Query<(Entity, &ViewLightEntities)>,
mut view_light_shadow_phases: Query<(&LightEntity, &mut RenderPhase<Shadow>)>,
point_light_entities: Query<&CubemapVisibleEntities, With<ExtractedPointLight>>,
Expand Down Expand Up @@ -1661,6 +1662,16 @@ pub fn queue_shadows<M: Material>(
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
Expand Down

0 comments on commit 5ce0d36

Please sign in to comment.