Log inGet started
Package

godrays.shader

Newest version

README.md

godrays

Real volumetric light shafts: the dusty air of the yard, lit by the sodium lamps, marched rather than painted.

For every pixel the shader walks the view ray from the eye out to whatever that pixel is standing on. At each step it projects the sample back to the screen and compares it against the depth already drawn there, so air behind the fence, the shed or the sawbuck is in shadow and air in the open is not. That depth test is what makes a beam a beam: its edges are the silhouettes of whatever stands in front of the lamp.

Each sample then asks every punctual light in the scene how much of itself reaches that point — the light's own radius falloff, plus Henyey-Greenstein forward scattering, so a shaft is bright when you look through it toward its lamp and fades as you look across it. A cheap value noise breaks the dust up so the beam has grain instead of a smooth wash, and the step phase is jittered per pixel so the march does not band.

propertywhat it does
intensityoverall strength of the scattered light
densityhow thick the dust is
falloffper-lamp distance falloff on top of the light radius
scatteringHenyey-Greenstein asymmetry, 0 even to 0.95 forward
samplessteps per ray — the whole cost of the effect
maxDistancehow far a ray is marched, in metres
noiseScalescale of the dust breakup noise

Runs on the scene layer, so it grades the rendered picture and leaves the order card, the RPM gauge and the title card untouched.

It is the only effect here that does real work per pixel: cost is linear in samples × screen pixels × lights. Drop samples before anything else if the frame has to come back.

This replaces the additive game/yard/light_shaft cylinders, which were a painted cone and read as glowing slabs stuck in the air. Those are removed.