-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Feature: 2d Point Lights. #19539
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
base: main
Are you sure you want to change the base?
Feature: 2d Point Lights. #19539
Conversation
- Point lights with configurable radius, color, and intensity; - Light falloff (linear or exponential); - Example 2dscene.rs to showcase and test the lights; - tests/light_render.rs tests Lights are directly integrated into the existing Sprite plugin. Signed-off-by: Adrian Graur <[email protected]> Co-authored-by: Daniel Fernandes <[email protected]>
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
Amazing progress! As I understand it, all sprites are lit without exception. Is it possible to add a component to ignore lighting for a specific sprite? I think this would be very useful and many may be waiting for this feature, thanks. |
@KurlykovDanila that is totally doable and it didn't cross my mind. I'll be working on that and on the CI errors. Thanks!! |
@@ -0,0 +1,152 @@ | |||
use bevy_color::Color; |
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.
Could we have some more documentation here please?
DrawSpriteBatch, | ||
); | ||
|
||
pub struct SetPointLightBindGroup<const I: usize>; |
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.
More docs would be helpful here please :)
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.
Sure, ill work on it!
@jbuehler23 should i turn this to draft while i work on things? |
Added some documentation and fixed warnings. Signed-off-by: Adrian Graur <[email protected]>
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
Signed-off-by: Adrian Graur <[email protected]>
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
Signed-off-by: Adrian Graur <[email protected]>
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
Signed-off-by: Adrian Graur <[email protected]>
Signed-off-by: Adrian Graur <[email protected]>
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
1 similar comment
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
/// This structure is sent to the GPU for lighting calculations. | ||
/// | ||
/// - `color_intensity`: RGBA color multiplied by intensity. | ||
/// - `position_radius`: XY position of the light, with Z as unused and W as radius. |
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.
Is there a reason why these doc comments shouldn't be on the members?
/// `_view` - The view uniform offset data (unused in this implementation) | ||
/// `_item_query` - The result of the item query (unused since ItemQuery is `()`) | ||
/// `lights_resource` - The GPU lights resource containing the bind group with light data | ||
/// `pass` - The tracked render pass used to record GPU commands |
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 just a hunch since I don't have a way to check but does this get formatted as a list correctly?
If not I would suggest something like:
* `_item` - The transparent 2D render item (unused in this implementation)
* `_view` - The view uniform offset data (unused in this implementation)
...
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.
The example should be move to examples/2d/2d_point_lights
The ColorMaterial
should be updated to also support point lights.
Objective
2d Point Light implementation and integration inside Sprite Plugin.
Solution
crates/bevy_sprite/src/light/point_light_2d.rs:
crates/bevy_sprite/src/render/light.rs:
PointLight2D
intoExtractedPointLight2D
.GpuLights2D
for GPU consumption.crates/bevy_sprite/src/render/mod.rs:
crates/bevy_sprite/src/lib.rs:
extract_point_lights_2d
andprepare_point_lights_2d
to the SpritePlugin.crates/bevy_sprite/src/render/sprite.wgsl
Testing
O: Set intensity to 0;
ArrowUp: Increase intensity;
ArrowDown: Decrease intensity;
ArrowRight: Change color;
N: Change scene;
SpaceBar: Change fall off type.
Showcase
demo.mp4