bevy_pbr/light/ambient_light.rs
1use super::*;
2
3/// An ambient light, which lights the entire scene equally.
4///
5/// This resource is inserted by the [`PbrPlugin`] and by default it is set to a low ambient light.
6///
7/// # Examples
8///
9/// Make ambient light slightly brighter:
10///
11/// ```
12/// # use bevy_ecs::system::ResMut;
13/// # use bevy_pbr::AmbientLight;
14/// fn setup_ambient_light(mut ambient_light: ResMut<AmbientLight>) {
15/// ambient_light.brightness = 100.0;
16/// }
17/// ```
18#[derive(Resource, Clone, Debug, ExtractResource, Reflect)]
19#[reflect(Resource, Debug, Default)]
20pub struct AmbientLight {
21 pub color: Color,
22 /// A direct scale factor multiplied with `color` before being passed to the shader.
23 ///
24 /// After applying this multiplier, the resulting value should be in units of [cd/m^2].
25 ///
26 /// [cd/m^2]: https://en.wikipedia.org/wiki/Candela_per_square_metre
27 pub brightness: f32,
28}
29
30impl Default for AmbientLight {
31 fn default() -> Self {
32 Self {
33 color: Color::WHITE,
34 brightness: 80.0,
35 }
36 }
37}
38impl AmbientLight {
39 pub const NONE: AmbientLight = AmbientLight {
40 color: Color::WHITE,
41 brightness: 0.0,
42 };
43}