#lighting #2d-rendering #game-engine #light #graphics #shadow #webgl2

bevy_light_2d

General purpose 2d lighting for the Bevy game engine

15 releases (4 breaking)

new 0.5.0-rc.1 Oct 29, 2024
0.4.2 Oct 26, 2024
0.4.0 Sep 18, 2024
0.3.0 Aug 6, 2024
0.1.2 May 29, 2024

#171 in Game dev

Download history 183/week @ 2024-07-14 112/week @ 2024-07-21 249/week @ 2024-07-28 170/week @ 2024-08-04 38/week @ 2024-08-11 10/week @ 2024-08-18 10/week @ 2024-08-25 14/week @ 2024-09-01 10/week @ 2024-09-08 158/week @ 2024-09-15 50/week @ 2024-09-22 96/week @ 2024-09-29 50/week @ 2024-10-06 105/week @ 2024-10-13 366/week @ 2024-10-20 188/week @ 2024-10-27

722 downloads per month

MIT license

54KB
1K SLoC

Rust 1K SLoC // 0.0% comments WebGPU Shader Language 171 SLoC // 0.1% comments

bevy_light_2d

Discord Crates.io docs license GitHub Actions Workflow Status Crates.io

General purpose 2D lighting for the bevy game engine. Designed to be simple to use, yet expressive enough to fit a variety of needs.

Features

  • Component driven design
  • Configurable point lights
  • Light occlusion
  • Dynamic shadows
  • Camera specific ambient light
  • Single camera rendering
  • Web support for WebGL2 and WebGPU

Usage

In the basic example, all we need is the plugin, a camera, and a light source.

# Cargo.toml
[dependencies]
bevy = "0.15"
bevy_light_2d = "0.5"
use bevy::prelude::*;
use bevy_light_2d::prelude::*;

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, Light2dPlugin))
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);

    commands.spawn(PointLight2d {
        intensity: 3.0,
        radius: 100.0,
        ..default()
    });
}

To see an in depth example, use cargo run --example dungeon.

Motiviation

When I first started experimenting with Bevy, the lack of a first party 2D lighting implementation left me wanting. While there were some rather impressive experimental 2D lighting crates out there, there wasn't much in the way of drop in options available.

My goal with this crate is to fill that void, prioritizing ease of use and general application over depth of features.

Bevy compatibility

bevy bevy_light_2d
0.15 0.5
0.14 0.2..0.4
0.13 0.1

Acknowledgements

I'd like to thank the authors of the below crates; they were a significant source of inspiration.

Asset credits

Dependencies

~41–79MB
~1.5M SLoC