Mirage Wells: Desert Dunes, Oasis and Ruins Kit
README.md
DustStorm
A desert dust storm (haboob) that rolls in, for every player at the same moment, drawn as one full-screen pass (shaders/dk_dust_storm). Called through DesertAtmos.dustStorm, or directly:
local DustStorm = require("desertKit.DustStorm")
DustStorm.start({ approach = 45, duration = 60, clear = 25, from = { 0, 1 } }) -- comes from +Z
print(DustStorm.state().phase, DustStorm.state().dist) -- "approach", metres to the front
DustStorm.stop() -- clear it now
How it is shared
start writes a record to runtime_data.world (desertKit/dustStorm): the shared start time (worldClockKit's timeline) and the real time it started (born), approach / peak / clear seconds, the direction it comes from, the distance it starts at and its origin (the desert's centre). How long a storm has run comes from the shared timeline while that agrees with real time to within 20 s, and from real time otherwise: a session's host can keep a timeline of its own, and the store keeps a record after its session ends, so this is what lets every machine, and a later session, agree on where a storm is and when it is over (a leftover record reads as long over and is cleared). Every machine draws from the record; the front is anchored in the world, so every player sees it at the same place. Whoever holds the clock moves the shared weather: the air stays as it was while the front is far off, then worldClockKit's own sandstorm weather (thick orange dust, dim sun, sand streaks, the sandstorm roar) fades in over the second half of the approach (HAZE_FROM), so it is at full strength as the wall arrives; clear when it ends, then the record is deleted. The kit defines no weather of its own. autoStep(minutes) starts one on its own every so many minutes (the component's stormEveryMinutes).
How it is drawn (cost)
One post pass, registered only while a storm shows, idle (returns the frame) otherwise:
- the wall: each view ray meets a vertical front of dust (bent back at its sides) once; where it does before the scene, a towering billowing cliff is drawn from 4-octave value noise: rolling heads, cauliflower billows lit on their upper sides, a dark foot, dust rolling out ahead of it over the ground. No ray march.
- inside: sheets of dust streaming downwind (two noise lookups along the ray) over the clock's thick fog.
- worldClockKit draws the blowing sand streaks round the camera (its 2,400-drop mesh) and plays its sandstorm bed from the weather.
stateAt(rec, t, x, z) is pure: { phase, front, dist, wall, engulf, progress }. LOOK holds the colours, visibility, wind speed, roll and curve; DEFAULTS the timings.