Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

bevy-magic-light-2d

> 编程语言
Open source

Experiment with computing 2D shading, lighting and shadows with Bevy Engine

586 stars0 likes2 views
WebsiteGitHub

About

Experiment with computing 2D shading, lighting and shadows with Bevy Engine

Beware! This repo is heavily under construction and a lot of things may change.

Experimental dynamic 2D global illumination system for Bevy, based on SDF ray-marching and screen space irradiance cache probes.

Demo

bash
cargo run --example minimal
cargo run --example krypta
cargo run --example movement

Implementation is based on several approaches:

  • First pass computes SDF for all occluders and stores it in a texture with one channel.
  • Second pass computes irradiance from direct light. We check amount of light received by probe taking into account occlusion which checked using SDF. The final contribution for each light source is computed using square falloff.
  • Third pass computes secondary bounced light. The approach is similar to the second pass, but instead of direct light, it uses irradiance is sampled from the probes. We use exponential sampling to check how much of reflected light is received by probe. Same as in the second pass SDF is used to check occlusion and the final contribution is computed using square falloff.
  • Finally, we combine results from the second and third passes combining cache from the previous eight frames. The we optionally filter the result using a edge-aware smoothing filter and apply Gamma correction.

The main performance gain is coming from computing value of only 1 / 64 number of pixels (for 8x8 probe size). The rest of the pixels are interpolated from the nearest probes.

Usage

bash
cargo run --example krypta
  • WASD to control camera.
  • SHIFT+LMC to place a light source.
  • RMC to change color of light source.

TODOs

Optimizations

  • Use jump flood algorithm for calculating SDF.
  • Precomputed noise.
  • Guided sampling for secondary light.

Features

  • Light can bounce from occluders.
  • Arbitrary number of bounces via configuration.
  • Handle camera scale and rotation.
  • Support multiple layers.
  • Expose settings instead of hardcoding them.
  • Support resize of targets.
  • Support transparent occluders.
  • Support color transfer from occluders.
  • Add inspector for GI settings.
  • Add support for emissive materials and other types of light sources.

Address limitations

  • SDF for offscreen occluders.

Others

  • Add examples and HUD explaining how to use example.

Compatibility

bevy bevy_magic_light_2d
0.16 0.10
0.15 0.9
0.14 0.8

License

Copyright 2022, 2023 Vladimir Zaytsev 

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言