Camera clear_color does not work with multiple cameras
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
0.15.1
## \[Optional\] Relevant system information
```
SystemInfo { os: "MacOS 15.2 ", kernel: "24.2.0", cpu: "Apple M2 Pro", core_count: "12", memory: "16.0 GiB" }
AdapterInfo { name: "Apple M2 Pro", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
```
## What you did
I have 2 Cameras, with different Viewports and a different clear_color per camera. Instead of each viewport rendering with it's own clear_color, both viewports are rendered with the clear_color of the camera with the lowest `order`.
```rust
use bevy::{
app::{App, Startup},
color::palettes::basic::{GREEN, RED},
prelude::*,
render::camera::Viewport,
DefaultPlugins,
};
fn main() {
App::new()
.add_plugins((DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
resolution: (400., 400.).into(),
..default()
}),
..default()
}),))
.add_systems(Startup, setup)
.run();
}
pub fn setup(mut commands: Commands, window: Single<&Window>) {
let size = window.physical_size();
commands.spawn((
Camera2d,
Camera {
order: 0,
clear_color: ClearColorConfig::Custom(RED.into()),
viewport: Some(Viewport {
physical_size: size / 2,
..default()
}),
..default()
},
));
commands.spawn((
Camera2d,
Camera {
order: 1,
clear_color: ClearColorConfig::Custom(GREEN.into()),
viewport: Some(Viewport {
physical_size: size / 2,
physical_position: size / 2,
..default()
}),
..default()
},
));
}
```
## What went wrong
In the above example, both viewports are rendered with red clear_color. If I then swap their `Camera.order`, then both are rendered with green clear_color.
They should each render with their specified clear_color.
## Additional information
Contributor guide
Assessment
This issue has not been assessed yet.