Whether the rays are drawn at all.
Occlusion buffer size as a fraction of the drawing buffer.
How strongly the rays read right now, 0–1 — every gate multiplied together. 0 means GodRays.render skipped the pass entirely. Refreshed by GodRays.update.
The sun's position on screen in uv (0–1, y up), the point the shafts fan out from — hand it to a lens flare to put the two in the same place. Reused between calls; may fall outside 0–1 with the sun off frame.
Show or hide the rays.
Restyle at runtime. Unset fields keep their current value.
Swap (or drop, with null) the dome the rays belong to — the overcast gate and the mesh kept out of the occlusion pass move with it.
Stop an object from blocking the light (particles, overlays, your own sky).
Let an excluded object block the light again.
Point the rays by hand — the standalone path for scenes without a
day/night cycle. dirTowardSun is the same vector the sky dome's sun is
drawn along, so the shafts start at the disc.
Optionalcolor: ColorAdopt one moment of a DayNightCycle. Named as the cycle's
godRays target this is called for you every frame.
It takes sunDir, never lightDir: the moon is the active light after
dark and pointing the shafts at it would fan them from the wrong side of
the sky. Below the horizon the sun's own height closes the gate instead.
How overcast the sky reads, 0–1 — a WeatherSystem's overcast,
making this an overcast target like the dome. With a dome attached its
value wins, since the weather already drives it there.
Recompute everything the composite reads — the sun's screen position, the ray color, the gain — and return the resulting GodRays.strength. GodRays.render calls this itself; reach for it directly only to drive something else off the same numbers.
Draw the rays over the frame. Call after renderer.render(scene, camera) with the same three arguments — the pass reads the scene again
for its occlusion mask and adds to the image already on the canvas.
A no-op while the gate is shut (night, heavy overcast, sun behind you), so there is nothing to switch off outside daylight.
Free the occlusion buffer, the quad, and the override material.
Crepuscular rays: light shafts fanning out from the sun around whatever blocks it — a ridgeline, a forest, a cliff edge.
The pass is the cheap classic. The scene is re-rendered at a fraction of the resolution with every material replaced by flat black on a white clear, which costs a depth-only-ish pass and yields a mask of where the sky is visible. Each pixel of a full-screen quad then marches that mask toward the sun's screen position, accumulating open sky with a per-step decay, and the result is added to the frame.
Deliberately not a composer: the main render never goes through a target, so the renderer's MSAA survives and nothing re-encodes an already-final image. Call GodRays.render straight after your own
renderer.render(scene, camera).It is a sink, not a clock, exactly like SkyDome — feed it a DayNightState (directly, or by naming it as a DayNightCycle target) and it takes the sun from the same source the dome draws it from, so the shafts always start where the sun disc is. Scattered light is what these are, so they scale with
daylightand die out under overcast: no shafts from the moon, none through a solid cloud deck. When the gate closes the whole pass is skipped, so a night frame costs nothing.Example