-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Split AmbientLight into two
#21595
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
alice-i-cecile
merged 9 commits into
bevyengine:main
from
Trashtalk217:split-ambientlight-in-two
Oct 21, 2025
Merged
Split AmbientLight into two
#21595
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5e7bb7f
split AmbientLight into two
Trashtalk217 9bff50f
better names
Trashtalk217 3a4f97f
cargo fmt
Trashtalk217 bcf2f5a
fixed docs
Trashtalk217 7824f61
docs, rename, fmt
Trashtalk217 39a3c1a
migration guide
Trashtalk217 6f38802
docs mistake
Trashtalk217 3e2ae32
docs mistake
Trashtalk217 36a1bda
Apply suggestions from code review
Trashtalk217 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,27 +5,60 @@ use bevy_reflect::prelude::*; | |
|
|
||
| /// An ambient light, which lights the entire scene equally. | ||
| /// | ||
| /// This resource is inserted by the [`LightPlugin`] and by default it is set to a low ambient light. | ||
| /// It can be added to a camera to override [`GlobalAmbientLight`], which is the default that is otherwise used. | ||
| #[derive(Component, Clone, Debug, Reflect)] | ||
| #[reflect(Component, Debug, Default, Clone)] | ||
| #[require(Camera)] | ||
| pub struct AmbientLight { | ||
| pub color: Color, | ||
|
|
||
| /// A direct scale factor multiplied with `color` before being passed to the shader. | ||
| /// | ||
| /// After applying this multiplier, the resulting value should be in units of [cd/m^2]. | ||
| /// | ||
| /// [cd/m^2]: https://en.wikipedia.org/wiki/Candela_per_square_metre | ||
| pub brightness: f32, | ||
|
|
||
| /// Whether this ambient light has an effect on meshes with lightmaps. | ||
| /// | ||
| /// Set this to false if your lightmap baking tool bakes the ambient light | ||
| /// into the lightmaps, to avoid rendering that light twice. | ||
| /// | ||
| /// By default, this is set to true. | ||
| pub affects_lightmapped_meshes: bool, | ||
| } | ||
|
|
||
| impl Default for AmbientLight { | ||
| fn default() -> Self { | ||
| Self { | ||
| color: Color::WHITE, | ||
| brightness: 80.0, | ||
| affects_lightmapped_meshes: true, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// The global ambient light, which lights the entire scene equally. | ||
| /// | ||
| /// It can also be added to a camera to override the resource (or default) ambient for that camera only. | ||
| /// This resource is inserted by the [`LightPlugin`] and by default it is set to a low ambient light. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to crosslink to the override. |
||
| /// Inserting an [`AmbientLight`] on a camera will override this default. | ||
| /// | ||
| /// # Examples | ||
| /// | ||
| /// Make ambient light slightly brighter: | ||
| /// | ||
| /// ``` | ||
| /// # use bevy_ecs::system::ResMut; | ||
| /// # use bevy_light::AmbientLight; | ||
| /// fn setup_ambient_light(mut ambient_light: ResMut<AmbientLight>) { | ||
| /// # use bevy_light::GlobalAmbientLight; | ||
| /// fn setup_ambient_light(mut ambient_light: ResMut<GlobalAmbientLight>) { | ||
| /// ambient_light.brightness = 100.0; | ||
| /// } | ||
| /// ``` | ||
| /// | ||
| /// [`LightPlugin`]: crate::LightPlugin | ||
| #[derive(Resource, Component, Clone, Debug, Reflect)] | ||
| #[reflect(Resource, Component, Debug, Default, Clone)] | ||
| #[require(Camera)] | ||
| pub struct AmbientLight { | ||
| #[derive(Resource, Clone, Debug, Reflect)] | ||
| #[reflect(Resource, Debug, Default, Clone)] | ||
| pub struct GlobalAmbientLight { | ||
| pub color: Color, | ||
|
|
||
| /// A direct scale factor multiplied with `color` before being passed to the shader. | ||
|
|
@@ -44,7 +77,7 @@ pub struct AmbientLight { | |
| pub affects_lightmapped_meshes: bool, | ||
| } | ||
|
|
||
| impl Default for AmbientLight { | ||
| impl Default for GlobalAmbientLight { | ||
| fn default() -> Self { | ||
| Self { | ||
| color: Color::WHITE, | ||
|
|
@@ -54,8 +87,8 @@ impl Default for AmbientLight { | |
| } | ||
| } | ||
|
|
||
| impl AmbientLight { | ||
| pub const NONE: AmbientLight = AmbientLight { | ||
| impl GlobalAmbientLight { | ||
| pub const NONE: GlobalAmbientLight = GlobalAmbientLight { | ||
| color: Color::WHITE, | ||
| brightness: 0.0, | ||
| affects_lightmapped_meshes: true, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These docs need updating.