Light · Act I

Lights in 2D are usually glow sprites laid over the scene. Nothing casts a shadow, and every new light costs more.
Cover the scene with probes that cast rays. Near: many probes, a few short rays. Far: a quarter of the probes, four times the rays. Merged from far to near, every pixel gets light from all directions, at a cost the number of lights does not change.
Light my 2D scene with radiance cascades: soft shadows from any number of lights, with no baking.
Read the whole briefFold the brief
Light my 2D scene with radiance cascades. - Each frame, draw what gives light and what blocks it into one picture at [my art's resolution]. - Cascade 0: a probe every [2] px, [4] rays each, [2] px long. - Each next cascade: probes twice as far apart, 4 times the rays, over the next stretch, 4 times longer. Stop when rays cross the screen. - Merge from the farthest cascade to the nearest: a ray that hit nothing takes the light its wedge found one cascade up. - Close the seams between cascades with the bilinear fix. - A pixel's light is the mean of its cascade 0 rays. - Give every light some size, [5] px or more: a tiny light flickers. - Keep it pixel art: snap the light to [my palette's ramps], with ordered dither between steps. - Run it [in a shader, every frame].
Change what stands in [brackets] to fit your game.
- Lights that move, or a level that changes. Nothing baked can follow those.
- Many lights. The cost is set by the screen's size: a hundred glowing bullets cost what one does.
Not forA few fixed lamps: glow sprites are cheaper.
Alexander Sannikov developed the method at Grinding Gear Games for Path of Exile 2.[1] Far light needs few places and many directions, near light the reverse.[1][2] Yaazarai wrote a step by step account.[3] The figure's 2D code is this atlas's own.
- Alexander Sannikov, Radiance Cascades, the paper, GitHub
- Jason McGhee, Building real-time global illumination: radiance cascades
- Yaazarai, Radiance Cascades, part one, GM Shaders