Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Adriigbs
Copy link

@Adriigbs Adriigbs commented Jun 8, 2025

Objective

2d Point Light implementation and integration inside Sprite Plugin.

  • Point lights with configurable radius, color, and intensity;
  • Light falloff (linear or exponential);

Solution

crates/bevy_sprite/src/light/point_light_2d.rs:

  • PointLight2D component and FallOffType enum definition.

crates/bevy_sprite/src/render/light.rs:

  • Light extraction from PointLight2D into ExtractedPointLight2D.
  • Processes and store the extracted lights into GpuLights2D for GPU consumption.

crates/bevy_sprite/src/render/mod.rs:

  • Create and add the light bind group to the Sprite pipeline.

crates/bevy_sprite/src/lib.rs:

  • Add extract_point_lights_2d and prepare_point_lights_2d to the SpritePlugin.

crates/bevy_sprite/src/render/sprite.wgsl

  • Light computation.
  • Apply it to the sprite.

Testing

  • tests/light_render.rs
  • examples/2dscene.rs:
    O: Set intensity to 0;
    ArrowUp: Increase intensity;
    ArrowDown: Decrease intensity;
    ArrowRight: Change color;
    N: Change scene;
    SpaceBar: Change fall off type.
  • Might need performance tests.

Showcase

demo.mp4

- 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 <adrian.graur@tecnico.ulisboa.pt>
Co-authored-by: Daniel Fernandes <daniel.chaves.fernandes@tecnico.ulisboa.pt>
@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen M-Needs-Release-Note Work that should be called out in the blog due to impact X-Contentious There are nontrivial implications that should be thought through S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 8, 2025
@alice-i-cecile alice-i-cecile added the D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes label Jun 8, 2025
Copy link
Contributor

github-actions bot commented Jun 8, 2025

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!
You can review it at https://pixel-eagle.com/project/B04F67C0-C054-4A6F-92EC-F599FEC2FD1D?filter=PR-19539

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.

@KurlykovDanila
Copy link

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.

@Adriigbs
Copy link
Author

Adriigbs commented Jun 8, 2025

@KurlykovDanila that is totally doable and it didn't cross my mind. I'll be working on that and on the CI errors. Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes M-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Contentious There are nontrivial implications that should be thought through
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants