Skip to content

Commit 0374648

Browse files
authored
Use global clear color for camera driver node. (#15688)
When no cameras are configured, the `ClearColor` resource has no effect on the default window. Fixes https://discord.com/channels/691052431525675048/866787577687310356/1292601838075379796 ![image](https://github.com/user-attachments/assets/f42479c0-b239-4660-acd0-daa859b1f815) ![image](https://github.com/user-attachments/assets/4d625960-f105-4a29-91a3-44f4baadac30)
1 parent 4357539 commit 0374648

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/bevy_render/src/camera/camera_driver_node.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
camera::{ExtractedCamera, NormalizedRenderTarget, SortedCameras},
2+
camera::{ClearColor, ExtractedCamera, NormalizedRenderTarget, SortedCameras},
33
render_graph::{Node, NodeRunError, RenderGraphContext},
44
renderer::RenderContext,
55
view::ExtractedWindows,
@@ -53,6 +53,8 @@ impl Node for CameraDriverNode {
5353
}
5454
}
5555

56+
let clear_color_global = world.resource::<ClearColor>();
57+
5658
// wgpu (and some backends) require doing work for swap chains if you call `get_current_texture()` and `present()`
5759
// This ensures that Bevy doesn't crash, even when there are no cameras (and therefore no work submitted).
5860
for (id, window) in world.resource::<ExtractedWindows>().iter() {
@@ -72,7 +74,7 @@ impl Node for CameraDriverNode {
7274
view: swap_chain_texture,
7375
resolve_target: None,
7476
ops: Operations {
75-
load: LoadOp::Clear(wgpu::Color::BLACK),
77+
load: LoadOp::Clear(clear_color_global.to_linear().into()),
7678
store: StoreOp::Store,
7779
},
7880
})],

0 commit comments

Comments
 (0)