use bevy_camera::Camera;1use bevy_color::Color;2use bevy_ecs::prelude::*;3use bevy_reflect::prelude::*;45/// An ambient light, which lights the entire scene equally.6///7/// It can be added to a camera to override [`GlobalAmbientLight`], which is the default that is otherwise used.8#[derive(Component, Clone, Debug, Reflect)]9#[reflect(Component, Debug, Default, Clone)]10#[require(Camera)]11pub struct AmbientLight {12/// The color of the ambient light.13pub color: Color,1415/// A direct scale factor multiplied with `color` before being passed to the shader.16///17/// After applying this multiplier, the resulting value should be in units of [cd/m^2].18///19/// [cd/m^2]: https://en.wikipedia.org/wiki/Candela_per_square_metre20pub brightness: f32,2122/// Whether this ambient light has an effect on meshes with lightmaps.23///24/// Set this to false if your lightmap baking tool bakes the ambient light25/// into the lightmaps, to avoid rendering that light twice.26///27/// By default, this is set to true.28pub affects_lightmapped_meshes: bool,29}3031impl Default for AmbientLight {32fn default() -> Self {33Self {34color: Color::WHITE,35brightness: 80.0,36affects_lightmapped_meshes: true,37}38}39}4041/// The global ambient light, which lights the entire scene equally.42///43/// This resource is inserted by the [`LightPlugin`] and by default it is set to a low ambient light.44/// Inserting an [`AmbientLight`] on a camera will override this default.45///46/// # Examples47///48/// Make ambient light slightly brighter:49///50/// ```51/// # use bevy_ecs::system::ResMut;52/// # use bevy_light::GlobalAmbientLight;53/// fn setup_ambient_light(mut ambient_light: ResMut<GlobalAmbientLight>) {54/// ambient_light.brightness = 100.0;55/// }56/// ```57///58/// [`LightPlugin`]: crate::LightPlugin59#[derive(Resource, Clone, Debug, Reflect)]60#[reflect(Resource, Debug, Default, Clone)]61pub struct GlobalAmbientLight {62/// The color of the ambient light.63pub color: Color,6465/// A direct scale factor multiplied with `color` before being passed to the shader.66///67/// After applying this multiplier, the resulting value should be in units of [cd/m^2].68///69/// [cd/m^2]: https://en.wikipedia.org/wiki/Candela_per_square_metre70pub brightness: f32,7172/// Whether this ambient light has an effect on meshes with lightmaps.73///74/// Set this to false if your lightmap baking tool bakes the ambient light75/// into the lightmaps, to avoid rendering that light twice.76///77/// By default, this is set to true.78pub affects_lightmapped_meshes: bool,79}8081impl Default for GlobalAmbientLight {82fn default() -> Self {83Self {84color: Color::WHITE,85brightness: 80.0,86affects_lightmapped_meshes: true,87}88}89}9091impl GlobalAmbientLight {92/// Convenience constant for turning off global ambient light.93pub const NONE: GlobalAmbientLight = GlobalAmbientLight {94color: Color::WHITE,95brightness: 0.0,96affects_lightmapped_meshes: true,97};98}99100101