AdapterInfo { name: "Apple M1 Max", vendor: 0, device: 0, device_type: IntegratedGpu, device_pci_bus_id: "", driver: "", driver_info: "", backend: Metal, subgroup_min_size: 4, subgroup_max_size: 64, transient_saves_memory: Some(true), limit_bucket: None }
A pink screen appears on startup when a Camera2d configured without a clear color op is composited on top of a camera with HDR. Resizing the window (or redraw) fixes the issue. Found while trying out hanabi examples. Related #18901
use bevy::{
camera::{CameraOutputMode, Hdr},
core_pipeline::tonemapping::Tonemapping,
prelude::*,
render::render_resource::BlendState,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn((
Camera3d::default(),
Hdr,
Tonemapping::None,
Transform::from_xyz(3.0, 2.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
));
commands.spawn((
PointLight {
intensity: 2_000_000.0,
shadow_maps_enabled: true,
..default()
},
Transform::from_xyz(4.0, 8.0, 4.0),
));
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(2.0, 2.0, 2.0))),
MeshMaterial3d(materials.add(Color::WHITE)),
));
let ui_camera = commands
.spawn((
Camera2d,
Camera {
order: 1,
clear_color: ClearColorConfig::None, // workaround: clear_color: ClearColorConfig::Custom(Color::NONE),
output_mode: CameraOutputMode::Write {
blend_state: Some(BlendState::ALPHA_BLENDING),
clear_color: ClearColorConfig::None, // workaround: clear_color: ClearColorConfig::Custom(Color::NONE),
},
..default()
},
))
.id();
commands.spawn((
UiTargetCamera(ui_camera),
BackgroundColor(Color::srgba(0.0, 0.0, 0.0, 1.0)),
));
}
Bevy version and features
commit e8b3598
adapter:
Bug
A pink screen appears on startup when a Camera2d configured without a clear color op is composited on top of a camera with HDR. Resizing the window (or redraw) fixes the issue. Found while trying out hanabi examples. Related #18901
Additional information
Related pink screen Metal bug #25176 #20318 but looks like the issue is still present in specific camera configurations.
A dumb "workaround" is to use
ClearColorConfig::Custom(Color::NONE)on the 2d camera, but not a real fix since this will actually clear the render target whereasClearColorConfig::Noneshouldn't clear anything. Repro: