-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Replace Ambient Lights with Environment Map Lights #17482
base: main
Are you sure you want to change the base?
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
@@ -522,6 +523,26 @@ pub enum SimulationLightSystems { | |||
CheckLightVisibility, | |||
} | |||
|
|||
pub fn map_ambient_lights( |
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.
I think we may want to add a deprecation notice to the AmbientLight component and remove it after 0.16. For this PR I think this is fine as is though.
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.
This is great, thank you!
The PR is simple enough that you could add this in too I think. Up to you, but I would approve it either way. |
Might as well add it in then. |
code looks good. simplifying the shaders is nice, but is the cost of binding an extra texture per view and looking up for every pixel really worth the saving of 7-8 lines of shader code? |
Found a bug with user-provided environment maps being overridden by the default ambient light, so I had to complicate the sync system a bit. Not sure if what I did was the most optimal.
The lighting example does go from about 0.51 ms to 0.55 ms on my machine (and enabling deferred makes that 0.46 ms to 0.49 ms), but I do doubt the usage of ambient light will be widespread enough that this matters, especially after the new procedural sky rolls around. |
I guess what we could do is keep the constructor thing in this PR and do the ambient light thing separately? I can see why that part could be a bit more controversial and that people might still want that around. |
It's not just about simplifying the shader code: it's that the interaction between ambient and environment map light never made any sense. They should be considered basically mutually exclusive (strictly speaking, ambient should be considered a type of light probe, which this PR moves us toward). |
.into_iter() | ||
.flat_map(Srgba::to_u8_array) | ||
.collect(), | ||
TextureFormat::Rgba8UnormSrgb, |
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.
This does not need to be a HDR texture right, since the user is defining the color in sRGB and an intensity?
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.
Yeah, it's an 8-bit sRGB texture.
is that in release? if so then i'd argue a ~10% fps reduction is not justified, but it's surprising how large the impact is.
makes sense. if the impact is really this big then perhaps we need some investigation into env map perf before going further though? |
Objective
Transparently uses simple
EnvironmentMapLight
s to mimicAmbientLight
s. Implements the first part of #17468, but I can implement hemispherical lights in this PR too if needed.Solution
EnvironmentMapLight::solid_color(&mut Assets<Image>, Color)
is provided to make an environment light with a solid color.SimulationLightSystems
that mapsAmbientLight
s on views or the world to a correspondingEnvironmentMapLight
.I have never worked with (or on) Bevy before, so nitpicky comments on how I did things are appreciated :).
Testing
Testing was done on a modified version of the
3d/lighting
example, where I removed all lights except the ambient light. I have not included the example, but can if required.