Feature Library

Metaball liquid drops

0.09 GPU · 0.14 CPU ms
A still of the Metaball liquid drops demo
Still
The live demo starts when it’s in view.Squeeze a flavour into the glass · click the open page to splash · drag to fling

Liquid as GPU particles that merge like metaballs, in raw WebGPU.

What it costs a frame

0.09 ms
0.14 ms
GPU
0.09 ms
CPU, median
0.14 ms
CPU, 95th pct
0.29 ms
Draw calls
0
Weight
Light

Measured 13 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 0.06–0.09, CPU 0.13–0.16 ms). What ran: A pour running into the glass all the time, a splash of 40 drops every quarter second, runners and beads on the cards: about 1,500 to 2,500 live drops of the 4,096, splatted into a half-size field and shaded full screen; timed with its own timestamp queries. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool0.090.140.29
apple · Apple A19 Proin a browser tab · 16 November 20264.650.620.84
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20260.200.220.34

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

How steadily it runs on Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258V · in a browser tab

Typical frame ?
16.65 ms
1% low ?
56 fps
Varies by ?
±0.36 ms
All metricsIntel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258V · in a browser tab
p50p95p9916.02 ms17.63 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.65 ms
p95 ?
17.27 ms
p99 ?
17.55 ms
Slowest ?
18.29 ms
Mean ?
16.68 ms
Standard deviation ?
0.36 ms
1% low ?
56 fps
0.1% low ?
55 fps
Hitches ?
0 of 600
Over budget ?
0 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.0 / 0.5 / 1.2 ms

Input

No input during this run. A browser-tab run plays none.

Memory

JavaScript heap ?
83.1 → 83.3 MB
Growth ?
+0.21 MB

What it needs

Renders with
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages

What it’s for

  1. A splash when something is confirmed, completed or celebrated
  2. Pouring a value into a gauge or a glass (a progress that fills)
  3. A playful drink, food or paint theme where cards drip after a press
  4. Drops and drips over a page without touching its layout
  5. A liquid trail behind a drag

Pitfalls, in brief

  1. Splat into a field at half the page’s size or less: the drops are soft blobs, so the threshold hides the low resolution, and the cost falls with the square.
  2. The field must be a float format (rgba16float) with additive blending: weights pile up past 1 where drops overlap, and an 8-bit target clips them, so merged pools lose their colour and their dome.
  3. Store colour times weight, and divide by the weight when shading: plain additive colour turns two touching drops twice as bright where they meet.
  4. The liquid lives on the GPU and is never read back, so the CPU only knows how long the longest drop can live: count that down and stop drawing at 0, after one frame that clears the canvas, or the last splash stays on screen.
  5. The drops sit in a ring buffer: a batch wraps round the end (two writes), and a burst bigger than the ring keeps only its newest rows.
6 more in brief
  1. Aim a pour by solving the throw (aim: vx = dx / t, vy = (dy − g t² / 2) / t) and kill each drop at its flight time: it vanishes where it lands, into the glass, without a collision test.
  2. Put the canvas over the page with pointer-events: none: drops fall over cards and into a glass, but every click still reaches the DOM.
  3. Under reduced motion skip the particles: change the value (the glass’s level) at once and say what happened.
  4. The device can be lost after the liquid starts (a driver reset, the GPU process gone): pass onLost, and on it dispose the liquid and carry on as under reduced motion (values change at once), and say so.
  5. Resize on a new pixel ratio too: a ResizeObserver does not fire when the window moves to a screen with another ratio, so the liquid stays at the old resolution.
  6. Without WebGPU, createLiquid starts the WebGL2 twin on the same canvas (liquid-gl.ts): the drops are stepped on the CPU and sent to the GPU each frame (64 bytes a drop, all of the capacity), the field is RGBA16F and needs EXT_color_buffer_float; null only where WebGL2 has no float target.
11 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Fully custom code.

Jim Blinn, A Generalization of Algebraic Surface Drawing (1982): Blobby objects: summed fields thresholded at an iso level, the idea under every metaball.

Geoff Wyvill, Craig McPheeters & Brian Wyvill, Data Structure for Soft Objects (1986): The polynomial falloff (1 − r²)³ each drop splats.

Tommy Ettinger, Mulberry32: The small seeded random source in drops.ts (public domain), for tests and repeatable demos.

metaballsliquiddropssplashpourparticlescomputesplatfieldthresholddom + gpuraw webgpuwgslglslwebgl2 fallbacktimestamp queriesrests when idletouchno dependencies

Near it in the frame