Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

bevy_light_grid

An illuminance grid that creature AI can read. It answers “how bright is it here, and which way is brighter” per cell, on the CPU, so a creature can flee into shadow or climb toward a lamp. Your GPU lighting already knows how bright each pixel is, but that answer lives in a framebuffer gameplay cannot read; this crate computes it in a form gameplay can sample and differentiate.

Add it

Not on crates.io yet:

[dependencies]
bevy_light_grid = { git = "https://github.com/bevy-coven/bevy_light_grid" }

The README has a quick start that is compiled on every cargo test. The crate takes bevy_math and bevy_ecs and nothing that draws.

What it gives you

  • LightGrid with bake (static lamps, rerun when one changes) and compose (moving FlashlightCones on the cached bake, every tick), both shadowed by your own line-of-sight closure (the field).
  • sample_cell and gradient_cell, and light_push_at for a steering push up or down the gradient.
  • Photophobic, Photophilic and Phototropic markers, and phototropic_scale for growth toward light.

Use it in the Cauldron

The Cauldron takes this crate behind its bevy_light_grid feature for the light map (issue #103), a read-only operation and overlay. Every placement that carries a bevy_lights Flicker is a fixture, a placement whose descriptor is a wall blocks line of sight, and the values drawn over the map are the crate’s own LightGrid::sample_cell, so what the author reads is what a light-shy creature in the game reads.