Procgen Effects Showcase
README.md
StormDirector
StormDirector handles everything about a lightning strike apart from the particles. The storm graph
(the Generator on the same entity) owns the bolts, rain, splashes, sparks and smoke, and runs on one
looping clock. StormDirector reads that same clock every frame and, through the shared
storm.schedule, pours each strike's light over the rest of the scene: the sun swings to the bolt
and throws the tower's shadow, point lights blaze at the strike, the cloud deck and the puddles light
up, and the thunder follows at the speed of sound. Between strikes the values hold still, so its resting cost is one clock read.
The fx_storm scene uses it on the storm entity, next to the Generator that plays the
storm.storm graph, with moonIntensity = 0.3 and ambientIntensity = 0.05.
It requires storm.schedule. It runs at executionOrder = 60. It finds these by name, and finds
them again every 2 seconds, whenever one of their entities is gone, and while it is still looking
for the generator:
| Name | What it reads |
|---|---|
sun | Light: the moonlight that swings toward each bolt |
ambient | Light: the ambient level |
FlashKey | Light: the point light that blazes at the strike |
FlashFill | Light: the fill light high in the cloud |
storm | Generator: the storm clock |
Thunder1, Thunder2, Thunder3 | Audio: the thunder sounds |
storm_sky, storm_ground | materials, resolved once as assets |
Fields
| Field | Type | Default | Description |
|---|---|---|---|
flashGain | number | 1.0 | Scene-wide brightness of a strike's light, as a multiplier on the tuned defaults. |
moonIntensity | number | 1.7 | Moonlight before any strike: the sun light's intensity between strikes. |
ambientIntensity | number | 0.26 | The ambient light's intensity between strikes. |
thunderVolume | number | 1.0 | Thunder loudness. |
All fields are Sync.
What each frame does
- Reads the generator's time and turns it into the storm phase with
schedule.phase. - Sums every strike's weighted
envelopeintoflash(held at most 3, then scaled byflashGain) and its weightedafterglowintoglow(held at most 1.2). The strike with the largestenvelope + afterglowleads the lighting. - Carries each strike's
targetandtopfrom the graph's own space into the world through thestormentity's position and rotation (Transform.localToWorld). - In play (
update), cues the thunder. Each strike's thunder plays when the phase passes the strike time plus the distance from the camera drawing the viewport to the point halfway up the strike, divided by 343. The strikes take turns overThunder1toThunder3; the volume isthunderVolume(times 0.85 for a ground strike) and each strike gets its own pitch near 1. - When
flash,glowor the leading strike has moved since the last write, it updates:- the sun's direction, lerped from the moonlight direction toward the bolt's direction as the
flash burns, its intensity (
moonIntensity + flash * 7 + glow * 0.6) and its colour, from{ 0.36, 0.46, 0.78 }toward{ 0.72, 0.80, 1.0 }; - the ambient light's intensity (
ambientIntensity + flash * 0.55 + glow * 0.08); FlashKey, moved near the leading strike, at intensityflash * 9000 + glow * 700, andFlashFillatflash * 7000 + glow * 500;storm_sky'sflashandbolt_dir(the direction from the camera drawing the viewport toward the bolt's top), andstorm_ground'sflashandbolt_pos(the strike target).
- the sun's direction, lerped from the moonlight direction toward the bolt's direction as the
flash burns, its intensity (
Lifecycle
update(dt): runs the frame above with thunder cues.editorUpdate(dt): runs the same frame, skipping the thunder cues.
Both use dt when given and 0.016 otherwise.