Feature Library

Valley weather: fronts, rain and snow, wet ground, snow on roofs and trees, and a lake that freezes from its shore

7.45 GPU · 0.34 CPU ms
A still of the Valley weather: fronts, rain and snow, wet ground, snow on roofs and trees, and a lake that freezes from its shore demo
Still
The live demo starts when it’s in view.Set the season, the hour, the sky (fair, showers, a front, a storm) and the wind; let time run or hold it; run a day ahead; turn round the valley

The HaTac engine’s weather as one kit, in raw WebGPU.

A seeded grid over the valley in world metres carries fronts on the prevailing wind; each climate (by biome) and its season set the air, and the air turns the fronts’ rain to snow. The grid is the CPU authority, on fixed steps, and saves: wet ground that dries, puddles that fill only below their lowest outlet, snow that builds and melts on the ground and on roofs (a roof keeps the ground under it dry), runoff that raises the rivers without ever compounding, storms that announce themselves once, and a seasonal ice sheet on the water that grows from a cold bank, joins a calm shelf to the lake while a fast river keeps its open centre, holds a load once thick enough and opens in a thaw. Round the viewer the rain and snow are drawn in two moving volumes on the engine’s particle runtime (a close one of impacts, a wide one of streaks and flakes out to 150 m on High), born only where the grid rains, stopped by roofs and water, ringing the water where they land; the ground, roofs, trees and water read the same grid in their shaders (a wet sheen, puddles that mirror the sky, snow on what faces up, snow shaken off the trees by gusts) and veil what lies beyond the rain along the sightline; the cloud lid takes its cover from the fronts. The demo is a small valley through a compressed day and year: a hamlet of timber cabins, a river from a tarn down two steep runs into a lake, spruces on the slopes, with the season, the hour, the sky and the wind to set.

What it costs a frame

7.45 ms
0.34 ms
GPU
7.45 ms
CPU, median
0.34 ms
CPU, 95th pct
3.54 ms
Draw calls
0
Weight
Heavy

Measured 28 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 158, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 7.43–7.45, CPU 0.34–0.34 ms). What ran: Alone: the weather over the bare valley at 16:12 in early winter under a passing front: the weather lattice (129² samples at 6 m) stepped at 5 Hz, its fields uploaded, the precipitation’s two moving volumes on the particle runtime, rain rings in the water, the ice on the lake, the wet and snowy ground and the sightline veil in terrain-world’s clipmap valley under sky-atmosphere’s sky, the lid driven by the weather’s cover; no cabins or trees. The camera turns slowly. Phones: tiers are being measured next.

How steadily it runs on RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference

Typical frame ?
16.67 ms
1% low ?
55 fps
Varies by ?
±0.41 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference
p50p95p9916.02 ms18.06 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.

Frames

Median (p50) ?
16.67 ms
p95 ?
17.41 ms
p99 ?
17.91 ms
Slowest ?
18.88 ms
Mean ?
16.70 ms
Standard deviation ?
0.41 ms
1% low ?
55 fps
0.1% low ?
53 fps
Hitches ?
0 of 600
Over budget ?
0 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.0 / 3.7 / 4.1 ms

Input

No input during this run.

Memory

JavaScript heap ?
136 → 133 MB
Growth ?
-3.28 MB

Browser

JavaScript a frame ?
0.85 ms
All tasks a frame ?
1.54 ms
Layout / style ?
0.01 / 0.14 ms
Main thread busy ?
9%

Garbage collection

Collections ?
16 (15 minor, 1 major)
Pauses ?
10.0 ms in all, longest 1.6

What it needs

Renders with
WebGPUNeeds WebGPU: current Chrome and Edge, Safari 26+, Firefox 141+ on Windows.
Your browser
Checking…Looking for WebGPU
Depends on
NothingNo other packages
With an agent
install("valley-weather")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up

What it’s for

  1. The weather of an open world or a strategy map that the game owns and saves: fronts, rain and snow, wet ground, snow that builds and melts, the same on every machine and from any camera
  2. A valley or village through the seasons: snow settling on roofs and trees, puddles after a shower, a lake that freezes from its shore and thaws in spring
  3. Gameplay on the weather: storms that arrive (once each), a river that rises with runoff, ice that bears a load at a crossing, a temperature and wind to read anywhere
  4. Rain and snow round the camera that agree with the world: born only where the grid rains, stopped by roofs and water, rings where they land, a veil across the valley beyond them

Pitfalls, in brief

  1. The demo needs WebGPU: the precipitation is simulated and drawn by compute passes into storage buffers, and the water’s live current is a compute solve; there is no WebGL path.
  2. Let nothing the camera does reach the weather.
  3. Save what the grid cannot derive: the clock (the season’s time and the wind’s integrated drift), wetness, puddles, snow, roof snow, the river stage, the storm and arrival flags, and with ice its clock, its stripe visits and the thickness (state.snapshot()).
  4. Connect the water before you register the weather on your clock or restore a checkpoint with ice: the checkpoint holds the ice’s fractional thermal time and the last visit to each wet-cell stripe, so a half-frozen shore resumes on the same tick.
  5. Add the rain’s stage to a freshly computed channel level (the water body does, through setRainStage).
19 more in brief
  1. Every published river stage republishes the water: body.update() and a rebuild of the ice’s wet cells, about 60 ms on the demo’s 513² water lattice (measured in headless Chrome on the reference laptop): a visible hitch each time.
  2. Step the grid on fixed time a few times a second, not every frame, and keep a step and its upload out of one frame.
  3. Puddles fill only below the lowest way out to the lattice’s edge (a priority flood, basins.ts): a flat shelf with a diagonal drain holds none.
  4. Give a roof its eave height. weatherAt(p, true) lays the roof’s own pack on faces at or above the stored height (less 0.1 m), the ground’s elsewhere: the ridge’s height leaves the lower half of a pitched roof bare.
  5. Reject a drop’s birth below its stop height (ground, water or roof) before the live list is compacted: a check on the next tick leaves one frame of rain under a roof.
  6. Gate rain rings by water depth and by where the drop hit: a roof over a river takes splashes and leaves the water under it still (the deposition’s waterSurface and toleranceM).
  7. Draw the drops after the haze and the clouds, as the engine does: into the single-sample composite over the scene’s 4× depth (samples 1, depthSamples 4).
  8. Fade drops and flakes out as they near the eye and cap their size on screen.
  9. Empty a kind’s volumes once it stops falling everywhere.
  10. Resolve thin streaks on the scene’s own pixel grid (nativeAlpha) and give far ones a minimum width with their opacity scaled to their coverage: at half resolution a slanting streak broke into dots.
  11. Give the frame light sky colours that follow the hour and the cloud.
  12. Sample a tree’s snow at its trunk (weatherCanopyAt(rootXZ)) and pass the needle face’s normal and exposure to weatherFoliageSnow: a lookup per branch puts the branches of one tree in different cells, and a passing gust sheds it in patches.
  13. Change a climate, the wind or the sky by changing the plan’s objects: the state keeps references to the climate objects it found at creation and reads the plan every step.
  14. The air has no lapse rate: a climate’s temperature is the same at the lake and on the ridge.
  15. A plan’s times and rates are in simulation seconds.
  16. arrivals() lists the cells that crossed into a storm on the last step, until the next: read it after a step, not every frame, or one storm is announced many times.
  17. Give a season its history.
  18. The ice grows from a cold bank cell by cell, each needing frontM (1.4 cm) before it seeds its neighbours, so a lake closes in time proportional to its width.
  19. Under a thin cover the engine mixes the snow in evenly, which reads as grey-green at three centimetres.
24 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Adapted from published work, named below.

Hannes Andersson: The HaTac engine’s weather, ice, water and particle modules and their decisions (built for his game and proven there), the library host and the demo’s valley.

The library’s living-water, terrain-world, sky-atmosphere and material-bake: The demo’s valley, river and lake, its ground, its sky and its materials are their demo copies.

weatherrainsnowsleetstormfrontcloudscloud coverwindgustsseasonseasonsclimatebiometemperaturewet groundwetnesspuddlessnow coversnow accumulationmeltthawroof snowshelter

Near it in the frame