diff --git a/crates/render_frontend/src/prepare/scene/smodel_lighting.rs b/crates/render_frontend/src/prepare/scene/smodel_lighting.rs index df1f949..8849833 100644 --- a/crates/render_frontend/src/prepare/scene/smodel_lighting.rs +++ b/crates/render_frontend/src/prepare/scene/smodel_lighting.rs @@ -10,6 +10,7 @@ use crate::prepare::scene::cull::smodel_cull_dist_skips_slot; use crate::prepare::scene::model_lighting_atlas::{ WorldModelLightingAtlas, model_lighting_atlas_write_tile, }; +use crate::prepare::scene::model_lighting_cache::ModelLightingAtlasTileWrites; use crate::prepare::scene::smodel_geom_cache::LodRampDvar; use crate::prepare::scene::view_parms::PreparedSceneView; use crate::prepare::scene::world::{WorldScene, WorldSmodelLightingSample}; @@ -184,6 +185,7 @@ pub(crate) fn update_smodel_lighting( atlas: Option>, scene: Res, mut images: ResMut>, + mut tile_writes: ResMut, prepared: Res, lock_pvs: Res, lod_ramp: Res, @@ -339,7 +341,8 @@ pub(crate) fn update_smodel_lighting( if !dirty_slots.is_empty() { let dims = atlas.dims; let atlas_handle = atlas.image.clone(); - if let Some(mut atlas) = images.get_mut(&atlas_handle) { + // Untracked: only `tile_writes` carries the tiles to the GPU. + if let Some(atlas) = images.get_mut_untracked(&atlas_handle) { for &(slot, handle) in &dirty_slots { let Some(Some(tile)) = lighting.tiles.get(slot) else { continue; @@ -347,7 +350,9 @@ pub(crate) fn update_smodel_lighting( let Some(entry) = ModelLightingTileIndex::from_handle(handle) else { continue; }; - if !model_lighting_atlas_write_tile(&mut atlas, dims, entry, tile) { + if model_lighting_atlas_write_tile(atlas, dims, entry, tile) { + tile_writes.push(atlas_handle.id(), entry, tile); + } else { diag::error!( World, "smodel lighting: tile for slot {slot} handle {handle} refused by atlas write"