diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index b30ea9af30..73299084d6 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -498,7 +498,7 @@ pub fn prepare_view_targets( _ => Some(clear_color_global.0), }; - let (a, b, sampled) = textures + let (a, b, sampled, main_texture) = textures .entry((camera.target.clone(), view.hdr)) .or_insert_with(|| { let descriptor = TextureDescriptor { @@ -547,13 +547,14 @@ pub fn prepare_view_targets( } else { None }; - (a, b, sampled) + let main_texture = Arc::new(AtomicUsize::new(0)); + (a, b, sampled, main_texture) }); let main_textures = MainTargetTextures { a: ColorAttachment::new(a.clone(), sampled.clone(), clear_color), b: ColorAttachment::new(b.clone(), sampled.clone(), clear_color), - main_texture: Arc::new(AtomicUsize::new(0)), + main_texture: main_texture.clone(), }; commands.entity(entity).insert(ViewTarget {