From be37c22d89ecd6a4ee28020206d2144b6eedd0a4 Mon Sep 17 00:00:00 2001 From: mgi388 <135186256+mgi388@users.noreply.github.com> Date: Wed, 26 Nov 2025 10:52:16 +1100 Subject: [PATCH] Add `MeshPipelineKey::LIGHTMAPPED` as applicable during the wireframe pass --- crates/bevy_pbr/src/wireframe.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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 {