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

[Merged by Bors] - Add separate brightness field to AmbientLight #1605

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion crates/bevy_pbr/src/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ impl LightRaw {
#[derive(Debug)]
pub struct AmbientLight {
pub color: Color,
/// Color is premultiplied by brightness before being passed to the shader
pub brightness: f32,
}

impl Default for AmbientLight {
fn default() -> Self {
Self {
color: Color::rgb(0.05, 0.05, 0.05),
color: Color::rgb(1.0, 1.0, 1.0),
brightness: 0.05,
}
}
}
4 changes: 3 additions & 1 deletion crates/bevy_pbr/src/render_graph/lights_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ pub fn lights_node_system(
let state = &mut state;
let render_resource_context = &**render_resource_context;

let ambient_light: [f32; 4] = ambient_light_resource.color.into();
// premultiply ambient brightness
let ambient_light: [f32; 4] =
(ambient_light_resource.color * ambient_light_resource.brightness).into();
let ambient_light_size = std::mem::size_of::<[f32; 4]>();
let light_count = query.iter().count();
let size = std::mem::size_of::<LightRaw>();
Expand Down