diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index 0468b7c0681ad..c4b19df63f09f 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -1,7 +1,7 @@ use crate::{ - DrawMesh, MeshPipeline, MeshPipelineKey, RenderMeshInstanceFlags, RenderMeshInstances, - SetMeshBindGroup, SetMeshViewBindGroup, SetMeshViewBindingArrayBindGroup, ViewKeyCache, - ViewSpecializationTicks, + DrawMesh, MeshPipeline, MeshPipelineKey, RenderLightmaps, RenderMeshInstanceFlags, + RenderMeshInstances, SetMeshBindGroup, SetMeshViewBindGroup, SetMeshViewBindingArrayBindGroup, + ViewKeyCache, ViewSpecializationTicks, }; use bevy_app::{App, Plugin, PostUpdate, Startup, Update}; use bevy_asset::{ @@ -757,6 +757,7 @@ pub fn specialize_wireframes( mut pipelines: ResMut>, pipeline: Res, pipeline_cache: Res, + render_lightmaps: Res, ticks: SystemChangeTick, ) { // Record the retained IDs of all views so that we can expire old @@ -827,6 +828,18 @@ pub fn specialize_wireframes( } } + // Even though we don't use the lightmap in the wireframe, 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(visible_entity) + { + mesh_key |= MeshPipelineKey::LIGHTMAPPED; + } + let pipeline_id = pipelines.specialize(&pipeline_cache, &pipeline, mesh_key, &mesh.layout); let pipeline_id = match pipeline_id {