Skip to content

Commit 32af4b7

Browse files
committed
Add separate brightness field to AmbientLight (#1605)
Idea being this would be easier to grasp for end-users. Problem with the logical defaults is this breaks current setups, because light will become 20 times less bright. But most folks won't have customized this resource or will not have used `..Default::default()` due to lack of other fields.
1 parent 8a9f475 commit 32af4b7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

crates/bevy_pbr/src/light.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,15 @@ impl LightRaw {
6060
#[derive(Debug)]
6161
pub struct AmbientLight {
6262
pub color: Color,
63+
/// Color is premultiplied by brightness before being passed to the shader
64+
pub brightness: f32,
6365
}
6466

6567
impl Default for AmbientLight {
6668
fn default() -> Self {
6769
Self {
68-
color: Color::rgb(0.05, 0.05, 0.05),
70+
color: Color::rgb(1.0, 1.0, 1.0),
71+
brightness: 0.05,
6972
}
7073
}
7174
}

crates/bevy_pbr/src/render_graph/lights_node.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ pub fn lights_node_system(
8787
let state = &mut state;
8888
let render_resource_context = &**render_resource_context;
8989

90-
let ambient_light: [f32; 4] = ambient_light_resource.color.into();
90+
// premultiply ambient brightness
91+
let ambient_light: [f32; 4] =
92+
(ambient_light_resource.color * ambient_light_resource.brightness).into();
9193
let ambient_light_size = std::mem::size_of::<[f32; 4]>();
9294
let light_count = query.iter().count();
9395
let size = std::mem::size_of::<LightRaw>();

0 commit comments

Comments
 (0)