Crates.io | bevy_lit |
lib.rs | bevy_lit |
version | |
source | src |
created_at | 2024-07-23 15:23:26.7348 |
updated_at | 2024-12-10 16:00:57.216636 |
description | A lighting 2d library for Bevy |
homepage | |
repository | https://github.com/malbernaz/bevy_lit |
max_upload_size | |
id | 1312920 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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
.
PointLight2d
.You can add bevy_lit
to your Cargo.lock
:
[dependencies]
bevy_lit = "0.4"
Or install it using the CLI:
cargo add bevy_lit
cargo run --example basic
Below is a basic example demonstrating how to set up and use bevy_lit
in your Bevy 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) {
commands.spawn((
Camera2d,
Lighting2dSettings {
shadow_softness: 32.0,
..default()
},
AmbientLight2d {
brightness: 0.2,
color: Color::Srgba(Srgba::hex("#C09AFE").unwrap()),
},
));
commands.spawn(PointLight2d {
color: Color::rgb(1.0, 1.0, 1.0),
intensity: 3.0,
radius: 200.0,
falloff: 2.0,
});
commands.spawn((
LightOccluder2d::new(Vec2::new(50.0, 50.0)),
Transform::from_xyz(0.0, 200.0, 0.0)
));
}
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.
bevy | bevy_lit |
---|---|
0.15 | 0.4 |
0.14 | 0.3 |
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:
Contributions are welcome! Please open an issue or submit a pull request.
bevy_lit
is licensed under the MIT License. See LICENSE for more details.