From a3563b335df28bd681646e66fd19420f73b53107 Mon Sep 17 00:00:00 2001 From: Charlotte McElwain Date: Sun, 6 Oct 2024 17:35:03 -0700 Subject: [PATCH 1/2] Use global clear color for camera driver node. --- crates/bevy_render/src/camera/camera_driver_node.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_render/src/camera/camera_driver_node.rs b/crates/bevy_render/src/camera/camera_driver_node.rs index 5845f216bb1bc..0e61606e0ed9d 100644 --- a/crates/bevy_render/src/camera/camera_driver_node.rs +++ b/crates/bevy_render/src/camera/camera_driver_node.rs @@ -1,5 +1,5 @@ use crate::{ - camera::{ExtractedCamera, NormalizedRenderTarget, SortedCameras}, + camera::{ClearColor, ExtractedCamera, NormalizedRenderTarget, SortedCameras}, render_graph::{Node, NodeRunError, RenderGraphContext}, renderer::RenderContext, view::ExtractedWindows, @@ -53,6 +53,8 @@ impl Node for CameraDriverNode { } } + let clear_color_global = world.get_resource::().unwrap(); + // wgpu (and some backends) require doing work for swap chains if you call `get_current_texture()` and `present()` // This ensures that Bevy doesn't crash, even when there are no cameras (and therefore no work submitted). for (id, window) in world.resource::().iter() { @@ -72,7 +74,7 @@ impl Node for CameraDriverNode { view: swap_chain_texture, resolve_target: None, ops: Operations { - load: LoadOp::Clear(wgpu::Color::BLACK), + load: LoadOp::Clear(clear_color_global.to_linear().into()), store: StoreOp::Store, }, })], From 9a7b81e9aa430139e1b9d6002e10b86ae1388cd6 Mon Sep 17 00:00:00 2001 From: Charlotte McElwain Date: Sun, 6 Oct 2024 18:40:41 -0700 Subject: [PATCH 2/2] Respond to feedback. --- crates/bevy_render/src/camera/camera_driver_node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_render/src/camera/camera_driver_node.rs b/crates/bevy_render/src/camera/camera_driver_node.rs index 0e61606e0ed9d..2548c416ce185 100644 --- a/crates/bevy_render/src/camera/camera_driver_node.rs +++ b/crates/bevy_render/src/camera/camera_driver_node.rs @@ -53,7 +53,7 @@ impl Node for CameraDriverNode { } } - let clear_color_global = world.get_resource::().unwrap(); + let clear_color_global = world.resource::(); // wgpu (and some backends) require doing work for swap chains if you call `get_current_texture()` and `present()` // This ensures that Bevy doesn't crash, even when there are no cameras (and therefore no work submitted).