Feature Library

Living water: lakes, rivers, falls and drift from the ground, with a live current round the camera

8.72 GPU · 0.54 CPU ms
A still of the Living water: lakes, rivers, falls and drift from the ground, with a live current round the camera demo
Still
The live demo starts when it’s in view.Cut a channel from the river, dig away from it, drop a splash, send a gust of logs, scrub the hour to night

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

Lakes and rivers are read off the terrain (a world water line, basin seeds that flood their own hollows, river brushes’ retained depth): one absolute stage, one current and a shore field per terrain sample, the CPU authority for gameplay and saves. Round the camera a shallow-water solve on a finer grid (128 m of half-metre cells on High) carries the real current, and it moves like water: waves travel at the speed their depth gives them and ride the current, only the grid’s own noise is damped, and the level is held by its broad deficit alone, so swells, pile-ups and the standing waves of a steep rapid stay alive. It parts round feet and posts, leaves wakes and eddies, backs up behind a dam and runs down a freshly cut channel as one front; its white water comes only from where the water converges, spins or runs fast and thin. The surface is the look the owner approved: clear water over a visible bed absorbed red first, streaks along the current, a calm lake, soft caustics, shore reflections that find only what stands above the water, a smooth skin that meets a steep or freshly dug bank without tearing, and a far lake that keeps its blue. Off a tall cliff (6 m and more) the water leaves the height field as a falling sheet that thickens with the flow coming over, breaks into white water and lands where its arc meets the pool with sky-lit spray and mist; the fall moves exactly the volume it takes, so the pool never rises into a mound. Lower steps stay rapids. Cargo floats on the published water on the simulation clock and saves with it; thousands of pieces of debris ride the live current, turn in its shear, catch on feet, pile against a boom and beach where fast water throws them. The demo is a steep wild river at golden hour: one fall off a cliff, a run of rapids over boulders, a machine on feet in the stream and a weir that gathers driftwood, where you cut a channel from the river (digging near the water is guarded), dig freely away from it, drop a splash and scrub the hour to moonlight.

What it costs a frame

8.72 ms
0.54 ms
GPU
8.72 ms
CPU, median
0.54 ms
CPU, 95th pct
0.87 ms
Draw calls
0
Weight
Heavy

Measured 25 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 8.47–9.69, CPU 0.52–0.56 ms). What ran: Alone: the bare water at golden hour: a still lake (a basin seed) and the steep run of rapids into it, the live current round the camera, on terrain-world’s clipmap valley under sky-atmosphere’s sky; no machine, weir, logs or trees. The camera turns slowly, so the live window scrolls. Frame pacing looked off during the run (most frames near 31 ms, about 80 near 16 ms, with the GPU busy 8.7 ms a frame): the owner may have had a light workload running; the GPU time is the number to read. 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 ?
30.98 ms
1% low ?
31 fps
Varies by ?
±5.27 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference
p50p95p9916.03 ms32.49 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) ?
30.98 ms
p95 ?
31.92 ms
p99 ?
32.30 ms
Slowest ?
32.55 ms
Mean ?
28.85 ms
Standard deviation ?
5.27 ms
1% low ?
31 fps
0.1% low ?
31 fps
Hitches ?
0 of 600
Over budget ?
0 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.2 / 0.4 / 0.5 ms

Input

No input during this run.

Memory

JavaScript heap ?
159 → 134 MB
Growth ?
-25.08 MB

Browser

JavaScript a frame ?
0.53 ms
All tasks a frame ?
1.51 ms
Layout / style ?
0.00 / 0.23 ms
Main thread busy ?
5%

Garbage collection

Collections ?
9 (7 minor, 2 major)
Pauses ?
14.9 ms in all, longest 1.9

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("living-water")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up

What it’s for

  1. The rivers and lakes of an open world or a strategy map, read off its terrain, with a current you can see near the camera and a flow map to the horizon
  2. A builder or colony game where players dig channels, dam streams and stand machines in the water: the current finds the cut, parts round the feet and backs up behind a dam
  3. Waterfalls and rapids that come from the ground itself: a tall cliff in a river becomes a fall with spray and mist, a steep run becomes white-water rapids, without placing anything by hand
  4. Floating cargo that saves and replays (logs, barrels, crates on the simulation clock) and visual debris by the thousand on the live current
  5. A landscape hero or a valley at dusk where water is the subject: a still lake, a river, the moon on the water

Pitfalls, in brief

  1. The demo needs WebGPU: the live current, the ripples, the falls’ supply and contact, and the debris are compute passes into storage buffers, and there is no WebGL path.
  2. Record one water step per command buffer.
  3. Keep the river’s supply your own array.
  4. Never let a continuous source write ripple impulses inside the live window.
  5. A fall is thrown only off a tall cliff: a ledge must drop FALL_STYLE.fallMinM (6 m) and the water must reach its brink on an approach that rises less than half of what the ground drops over the next two cells.
25 more in brief
  1. Give calm water a flat bed.
  2. Give a steep run its whole flow: an open, smooth outlet from the pool above it and boulders that mostly stay under the stage.
  3. A steep chute drawn by the coarse surface (on Low, or outside the live window) shows its triangles as mirror facets: the slope limit and filtering apply to the live grid only.
  4. Apply the detached faces to both the surface and the live solver (the host does): solving across a near-vertical face pushes a wedge of water out from behind the sheet.
  5. Draw the floating hulls before the water and include them in the opaque copy the water refracts: with 4× MSAA, resolve the floaters’ pass into it as well as the scene pass.
  6. Stand the live bed on the ground as drawn: pass the clipmap’s layout (terrain-render’s CLIPMAP_BED_WGSL, the host’s clipmap option) and the water meets the terrain at every ring and through the morph; without it the bed is the lattice bilinear and shores can open or bury a few centimetres where the terrain draws triangles.
  7. Read shore wetness on the source grid at each fragment and threshold after (0.5 is the waterline): thresholding per vertex, or a field interpolated from distant vertices, moves the bank in cell-sized steps.
  8. Sample cargo on the published stage and flow, never the live window: the camera’s moves replace the window’s cells.
  9. Sample debris’ depth, velocity and bed at the same wrapped live-grid coordinates; adding depth to the coarse bed throws a log into the air at a window seam.
  10. Put an obstacle’s top at the physical crest and pass each foot or post: one box round an elevated deck blocks the water underneath.
  11. Widen thin footings to 1.5 live cells (the raster does): narrower falls between cell centres and leaks.
  12. Read buffers back only if they carry COPY_SRC: a copy from one that lacks it invalidates the whole command buffer and every readback in it returns zeros.
  13. Keep foam thresholds in per-second units, and expect a fast channel on a dug slope (1 m deep on 4% runs about 3 m/s at the default drag); a pebbled bed’s drag is about 0.04.
  14. Hashed value noise costs about 0.05 ms a call over a 1080p lake; the surface reads one baked texture (noise.ts, 512 KB).
  15. Foam and spray are lit surfaces: under the moon they are grey-blue, never the brightest thing in the picture.
  16. Scrubbing the hour fast (more than about 0.03 h a frame) shows a one-frame step in the sunlit ground and the water’s spray from the sky host’s cloud shadow (sky-atmosphere’s, not the water’s: it goes with the cloud cover at 0, and a slow scrub shows none).
  17. Do not look for falls while a brush is still being dragged: pass update({ falls: false }) during the gesture and update() when it lands.
  18. Dig at the water only with terrain-brush’s channel stroke, under its water guard (the engine’s terrain-brush at a0404eb, in the demo’s copy): put waterGuard(grid, lw.wetLevel()) in the grid’s guard and the level in its waterLevel, and remake both after every update (a stale guard lets a stroke undercut a new shore).
  19. Give a channel from the water its floor relative to the water, not the ground: the demo starts the floor 0.65 m under the river’s level, falling 0.5% along the drag, and the stroke never cuts more than channelBelowWaterM (1.5 m) under it.
  20. Replay a journal of strokes under the guard each gesture was dug under, not today’s: the demo’s journal entries carry their guard and level (its terrain host copy), so an undo rebuilds every earlier gesture as it was dug even after the water moved.
  21. A fall’s sheet follows the discharge coming over now (published flux × the live spill ratio): a spill of a fraction of a cubic metre a second falls as a few thin strands that thicken into a sheet as the flow grows, and its spray and mist are thinner.
  22. Lay the sky into the scene’s colour before the opaque scene (the demo’s host does) when the sky is composited later: the water’s shore reflections and refraction sample the opaque copy, and where nothing was drawn they found black.
  23. Hold the level, never damp the waves: liveStyle.returnRate (1/s) acts only on the deficit blurred over holdM (4 m), so a swell, a pile-up and a rapid’s standing waves keep their height at any returnRate (the demo holds a dug channel at 1.2), and gridDamping (3/s on a two-cell wave) takes out the grid’s own noise and leaves anything longer than about 2 m.
  24. Compile only the sample count the page draws at: createLivingWater’s samples passes the engine’s inputSamples to the water, the falls, the floating draw and the half-resolution layer.
  25. On Low (no live solve) the coarse surface still draws a bank’s dry vertices sloping down to the ground, and at a freshly dug, steep bank its large triangles catch the sky as bright facets; the water motion pass’s bank rule covers the live grid only.
30 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 water, falling water and floating modules and their decisions (built for his game and proven there), the look he approved by eye, the library host and the demo’s valley.

The library’s shallow-stream: The live solve is adapted from its staggered, semi-Lagrangian face velocity and conservative upwind depth passes (the engine’s live.ts and live-shaders.ts say so), and the look follows it.

waterriverlakestreamwaterfallfallsrapidswhite waterwild riverstanding wavesfoamspraymistshallow watershallow-water equationsfluidcurrentwakeeddyflow maphydrologyshoreshorelinewet bank

Near it in the frame