bevy_lit
bevy_lit
is a simple and easy-to-use 2D lighting library for Bevy, designed to work seamlessly with a single camera setup. The library provides basic lighting functionalities through the types: Lighting2dSettings
, AmbientLight2d
, LightOccluder2d
, and PointLight2d
.
Features
- Lighting2dSettings: Controls lighting parameters such as shadow softness
- AmbientLight2d: Provides a general light source that illuminates the entire scene uniformly.
- PointLight2d: Emits light from a specific point, simulating light sources like lamps or torches.
- LightOccluder2d: Creates shadows and blocks light from
PointLight2d
. - Web support both for WebGPU and WebGL2 targets
Getting Started
Installation
You can add bevy_lit
to your Cargo.lock
:
[]
= "0.2"
Or install it using the CLI:
Demo
Usage
Below is a basic example demonstrating how to set up and use bevy_lit
in your Bevy project:
use *;
use *;
Implementation
bevy_lit
uses signed distance fields (SDFs) to compute the occluders' distances. To soften the shadows, a blur is applied. This approach is not ideal and might have limitations in terms of performance and visual accuracy, but it provides a starting point for basic 2D lighting effects.
Acknowledgement
This library took heavy inspiration from the work of other developers. I learned a lot about lighting and Bevy development by reading the source code of the following crates:
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
bevy_lit
is licensed under the MIT License. See LICENSE for more details.