# Bevy Fast Light
[](https://github.com/leomeinel/bevy_fast_light)
[](https://crates.io/crates/bevy_fast_light)
[](https://crates.io/crates/bevy_fast_light)
[](https://docs.rs/bevy_fast_light/latest/bevy_fast_light/)
Simple 2D lighting for Bevy focused on performance over features.
## Features
### Lights
| Ambient light | `AmbientLight2d` | `color` and `intensity` |
| Mesh light | `MeshLight` | `color`, `intensity` |
### Occluders
| Mesh occluder | `MeshOccluder` |
`Sprites` are rendered above occluders if they are on the same or a higher z-level. Also see [Showcase](#showcase).
### Mesh2d
The following `Components` allow the customization of their shape via attaching a `Mesh2d`:
- `MeshLight`
- `MeshOccluder`
The `Mesh2d` is required for the `Components` to render.
## Limitations
- There is currently no shadow casting for light occluders.
## Usage
Take a look at [`/examples`](https://github.com/leomeinel/bevy_fast_light/tree/main/examples) to find out how to use this crate.
### Showcase
I am using most features in my learning project [Slimy Mist](https://github.com/leomeinel/slimy_mist) and have also successfully implemented a day/night cycle.
This also visualizes how `Sprites` are rendered above occluders if they are on the same or a higher z-level.
<img src="https://github.com/leomeinel/bevy_fast_light/blob/main/static/slimy_mist.webp?raw=true" width="400" alt="slimy mist example">
### Examples
#### `ambient_light.rs`
Scene with a light sky colored `AmbientLight2d` with a lower `intensity`, a green `Rectangle` as background and an amber `MeshLight`.
<img src="https://github.com/leomeinel/bevy_fast_light/blob/main/static/ambient_light.webp?raw=true" width="400" alt="ambient light example">
#### `mesh_light.rs`
Scene with a green `Rectangle` as background and an amber `MeshLight`.
<img src="https://github.com/leomeinel/bevy_fast_light/blob/main/static/mesh_light.webp?raw=true" width="400" alt="mesh light example">
#### `mesh_occluder.rs`
Scene with a light sky colored `AmbientLight2d` with a lower `intensity`, a green `Rectangle` as background, an amber `MeshLight` and a `MeshOccluder`.
<img src="https://github.com/leomeinel/bevy_fast_light/blob/main/static/mesh_occluder.webp?raw=true" width="400" alt="mesh occluder example">
## Alternatives
- [bevy_firefly](https://crates.io/crates/bevy_firefly)
- [bevy_2d_screen_space_lightmaps](https://crates.io/crates/bevy_2d_screen_space_lightmaps)
- [bevy_light_2d](https://crates.io/crates/bevy_light_2d)
- [bevy_lit](https://crates.io/crates/bevy_lit)
## Resources
### Code
- [Bevy Example - Custom Post Processing](https://bevy.org/examples/shaders/custom-post-processing/)
- [Bevy Example - Custom Render Phase](https://bevy.org/examples/shaders/custom-render-phase/)
### Articles
- [hackmd.io - Bevy's Rendering Crates](https://hackmd.io/@bevy/rendering_summary)
- [hackmd.io - The Abyss](https://hackmd.io/@bevy/the_abyss)
- [slembcke.net - 2D Lighting Techniques](https://www.slembcke.net/blog/2DLightingTechniques/)
- [slembcke.net - 2D Lighting with Hard Shadows](https://www.slembcke.net/blog/SuperFastHardShadows/)
- [WebGPU Shading Language](https://www.w3.org/TR/WGSL/)