Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use global clear color for camera driver node. #15688

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/bevy_render/src/camera/camera_driver_node.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
camera::{ExtractedCamera, NormalizedRenderTarget, SortedCameras},
camera::{ClearColor, ExtractedCamera, NormalizedRenderTarget, SortedCameras},
render_graph::{Node, NodeRunError, RenderGraphContext},
renderer::RenderContext,
view::ExtractedWindows,
Expand Down Expand Up @@ -53,6 +53,8 @@ impl Node for CameraDriverNode {
}
}

let clear_color_global = world.resource::<ClearColor>();

// 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::<ExtractedWindows>().iter() {
Expand All @@ -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,
},
})],
Expand Down