Skip to main content

Crate bevy_lit

Crate bevy_lit 

Source
Expand description

bevy_lit demo

§bevy_lit

A simple 2D lighting library designed for Bevy.

§Features

  • Multiple light sources including PointLight2d, SpotLight2d and TextureLight2d
  • Includes primitives CustomLight2dPlugin and Light2dMaterial for defining custom light sources
  • Light occlusion through LightOccluder2d that can be used along side any Mesh2d
  • Per camera fine grain control over lighting parameters such as shadow softness and more
  • Terraria-like light penetration effect
  • Web support for WebGPU

§Getting started

§Installation

Install it using the CLI:

cargo add bevy_lit

Or add bevy_lit to your Cargo.lock:

[dependencies]
bevy_lit = "*"

§Usage

Below is a basic example demonstrating how to set up and use bevy_lit in your project:

use bevy::prelude::*;
use bevy_lit::prelude::*;

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

fn setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>) {
    commands.spawn_scene(bsn! {
        Camera2d
        Lighting2dSettings
    });

    commands.spawn_scene(bsn! {
        PointLight2d { color: { Color::WHITE }, intensity: 3.0, outer_radius: 200.0, falloff: 2.0 }
    });

    let mesh = meshes.add(Circle::new(50.0));
    commands.spawn_scene(bsn! {
        Mesh2d(mesh)
        LightOccluder2d
        Transform::from_xyz(0.0, 200.0, 0.0)
    });
}

§Compatibility

bevybevy_lit
0.190.11
0.180.10
0.17.30.9
0.170.8
0.160.7
0.150.4..0.6
0.140.3

§License

bevy_lit is licensed under the MIT License. See LICENSE for more details.

Modules§

prelude
use bevy_lit::prelude::*; to import common components and plugins