All examples · Post-processing

Light shafts

What this example shows

godrays() streams shafts of light from a point past whatever stands in front of it: sun through trees, a window in a dark hall, a relic on an altar. center is where the light comes from, from [0, 0] (top left) to [1, 1], and it may lie off screen.

It takes two passes at half the game's size: one picks out what is brighter than threshold, the other smears it outwards from center, and the result is added back over the sharp picture. density is how far the rays reach, decay how fast they fade along the way and intensity how strong they are. A dark shape in front of something bright is what makes the shafts.

Move the pointer to move the light, ↑ ↓ for the threshold and Space to switch it off.

Starting