How it works
There is no fluid grid here. The goo is up to 128 beads on strands, simulated on the CPU, and every pixel of its surface is computed exactly from them, in one shader pass. Each link of a strand is an uneven capsule, bent into up to three on curves. All of them are joined with the exponential smooth-min, d = −k·log₂ Σ 2−dᵢ/k, which is a metaball field in log space. Since that union doesn’t care about order, beads can stretch apart, pinch off, fly away and melt back in without any bookkeeping in the renderer. The same sum gives the distance, its gradient and the local thickness, so the surface is lit like syrup sitting on the page.
Pipeline (per frame)
pointer (shell) ─▶ HEAD damped spring ω = 6.5–17 rad/s, ζ = .8, settling 1.2 R behind the cursor tip
drops a bead every 0.5–1.3 R of arc: wider when fast, tighter on curves (κ);
fat when slow, thin again as the pointer comes to rest
CPU, dt-based, no allocation
ring buffer 128 beads × Float32Array: pos, vel, base radius, age, life, wave phase, seed, link → older bead
├─ physics ×2 substeps tension-only link springs · bending · head drag · cohesion (≤ 8128 bead pairs,
│ skipping beads within 10 places along the trail) · gravity · viscous drag that
│ rises 2.5× over a bead's first second (laid goo sticks) · cursor push (slow pointer)
├─ links viscous creep: a stretch stays instead of springing back; stretch thins the beads
│ (r ∝ 1/√stretch); a link necks just before it snaps (2.4–4× its laid length);
│ a snapped neck retracts as two blunt cones (tip ≥ .35 r, .13–.26s)
├─ radius wave r·(1 + a·sin φ), a grows from 1–1.5s of age → troughs pinch off → pearls;
│ a retracting thread feeds its volume to the goo it pulls into (r³)
├─ contract + merge once beaded, pieces pull in; a free piece of ≤ 4 beads pulls in all the way and
│ its beads drain into one (r³): a drop; a thin loose end retracts into its neighbour
├─ remesh links > 1.7 R get a Catmull-Rom midpoint bead
├─ droplets flung sideways above a head speed; drain into goo they touch (volume ∝ r³)
└─ segments ≤ 392: links as 1–3 Hermite sub-capsules (≤ 10–20° of turn each, by k), free
beads, the head link → 3 × vec4 each (the third: the strand's tangent and radius
slope at both ends, shared with the neighbour), plus bound circles
GPU one program → canvas RGBA8 2560×1440, premultiplied, no render targets
TILES ≈ 2.6 R (96–256 px): the CPU bins the segments whose bound reaches each tile, skips a tile when
an upper bound on its weights (Σ 2^−D/k) puts every pixel beyond edge, halo and shadow, packs the
lists into one uniform buffer (std140, aligned offsets), uploads it once and draws each tile
scissored with bindBufferRange (measured 29–65 tile draws, ≤ 34 segments per tile on Slime)
per pixel, per segment in the tile (cull 4.5k, at most 3.2 R; weight faded to 0 over its outer half):
intact link ─ 1 uneven capsule (iq) │ necked or retracting ─ 2 capsules to the neck − their neck disc
− its shared end disc (inclusion–exclusion: joints aren't counted twice), smooth-gated
shading gradient: sides in the frame interpolated between the two ends' tangent + slope; caps and
end discs radial, held at the joint's tube normal across the wedge between capsules
accumulate Σw, Σw·∇d, Σw·ρ, Σw·age, Σw·seed and the largest single capsule weight
d = −k·log₂Σ ∇d = Σw∇d / Σw (clamped to |∇d| ≤ 1) cursor tip: smooth subtraction, only while moving
coverage clamp(.5 − (d/|∇d|)/px) constant 1-px edge, any blend radius
height spherical cap over the local radius + k·log₂(Σw / max w) (contact slope 1.8·depth)
→ normal from ∇d, levelled where merged strands' gradients cancel
colour Beer–Lambert T = exp(−A·tint·(thickness + refract·(1 − n.z))), A = −ln(body)
light page: page·τ + bg·(T − τ) + scatter + caustic, α = 1 − τ, τ = translucency·min(T)
dark page: wrap-lit body + bounce rim; with glow: dark-rock albedo + emission by heat
(churning yellow-orange core → orange → crust plates (cells) split by glowing cracks)
+ Fresnel environment + Blinn-Phong spot + softbox window (softer on molten goo)
hue-preserving shoulder · ±½ LSB dither
halo dark pages with glow: compact (1 − d/2.5g)³ from the uncarved distance, × heat (no haze)
shadow light pages: the same field one offset away, d(p − off) ≈ d − ∇d·off: contact + cast,
tinted, composited under the goo
clear zone a resting fine pointer fades the goo within 0.03–0.09 screen heights of its tip
The ideas that matter
- Smooth-min as a metaball field. Polynomial smooth-min is the usual choice for SDF blobs, but chained over dozens of capsules it depends on loop order. The exponential version,
−k·log₂ Σ 2−dᵢ/k, is just a sum: it is associative, so links, droplets and the head can be added in any order and anything near anything else blends. Because it stays a distance (approximately), the edge is anti-aliased byd/|∇d|to a constant one pixel, even inside fillets where the raw field is flat. Smoothness k sets how far beads reach for each other. - Exact capsules, analytic gradient. Each link is iq’s
sdUnevenCapsule(the hull of two discs), rotated into the link’s frame. Its gradient falls out per region: radial on the caps, the tangent normal along the sides. Weighting those gradients with the same 2−d/k terms gives the union’s gradient for free, so the normals are smooth across every merge. NodFdx, so no 2×2-quad faceting. One refinement: the distance field has a ridge along every capsule’s axis, where that gradient flips. A smooth sign over 0.35 of the local radius rounds it; a hard flip showed as a crease along thin arms of a merged blob. - Inclusion–exclusion at the joints. Neighbouring capsules share the disc of the bead between them, so a plain sum counts every joint twice. That inflates each joint by about k, and the ribbon gets a rib at every bead. Each link subtracts its shared end disc once (
w_link − w_disc, never negative because the disc is inside the capsule), and bends keep their smooth-min fillet. For the shading to be one smooth tube too, every quantity in the sum must cancel exactly where the capsule and its end disc are the same function. So a capsule reports the local radius of the region its distance comes from (rA on the A cap, rB on the B cap, along the tangent generator on the sides), its gradient is taken in the same frame as the disc’s, and the float rounding residue is dropped by a smooth gate on wnet/wlink. An earlier version took the radius from the axis projection and switched near-cancelled links on or off; at those switches the radius jumped by up to 0.4 R (measured on a CPU copy of the shader’s sums), and the shading showed ribs at bead joints, strongest at Translucency 1. - One normal along the whole strand. Exact capsule gradients still stepped at every joint: along its side each capsule’s normal is fixed to its own chord and its own radius slope, and since a joint’s caps cancel exactly, the normal switched from one capsule’s to the next’s at the joint plane. On a bend that is up to ~10° of turn, plus the change of slope wherever the radius changes; the caustic, the softbox edge and the specular turned it into hard transverse bands, like stacked tiles. Now every joint has one tangent (the one the Hermite curves use) and one radius slope (the mean of the two capsules’), sent with both segments. Along its side a capsule interpolates its normal from its two ends’ frames, and its caps and the subtracted end disc hold the joint’s tube normal across the wedge between the two capsules’ end planes, and are radial beyond it. They use the same function, so they still cancel exactly, and the normal is continuous from one capsule to the next. A joint keeps plain caps where one frame can’t stand for both sides: a kink sharper than 60°, or a jump in slope of more than 0.35 (a neck that is thinning, a retracting tip, the fat end of a slow stroke). A faint crease can show at such a joint until the neck snaps. Checked on contrast-boosted crops of a steady arc stroke and of the reduced-motion still: the bands at bead and sub-capsule joints are gone.
- Necks that pinch, then let go. A link that thins is drawn as two capsules from the beads to a neck radius, minus the disc they share at the neck: the same inclusion–exclusion, so unnecked they make the single capsule (within 1.4% of a radius) and necking never starts with a bulge. When it snaps, both halves retract toward their beads as blunt cones over 0.13–0.26s (each tip keeps at least a third of the thinner bead’s radius, so it ends round, not in a thorn); the subtracted disc shrinks as the tips part, so it always stays inside both capsules. (A cross-fade along the link did the job before, until a short link showed a straight cut where the fade crossed its end bead.) Stretch thins the beads, conserving volume (r ∝ 1/√stretch), instead of necking every link.
- Goo stays where it is laid. On a fast stroke each new bead outruns the previous one, so every link ends up stretched. With plain springs the whole strand then recoiled toward the head and piled up into balls. Here the rest length creeps toward the stretched length (viscous, not elastic), drag rises 2.5× over a bead’s first second as the goo settles onto the page, and cohesion skips beads within 10 places of each other along the trail; pulling those together contracted every strand along its own length. Measured with a counter on the harness’s fast sweep: snaps in the 1.2s after the stroke went from 11 to 3. The figure-eight is still one ribbon 1.2s after the stroke ends, has beaded into pieces by +2.4s and is down to drops by +3.6s.
- Plateau–Rayleigh, art-directed. A real syrup thread breaks into pearls because surface tension favours a wavelength of about 9 radii. Each bead carries a phase that advances along the strand (λ = 5.5–8 R). Its radius is modulated by 1 + a·sin φ, with a growing from 1–1.5s of age (later for thick goo), so the wake holds as a ribbon first. Troughs pinch off and retract, and a retracting thread hands its volume to the goo it pulls back into, so the thread ends as a row of pearls instead of dissolving. Only then do the pieces contract, and linked beads that slide onto each other drain into one (volume ∝ r³). A long strand stops contracting at 0.45 of its laid length, which left short pieces at low viscosity stalled just outside merge range, as pills. A free piece of up to four beads now contracts all the way, without the extra drag of laid goo, and merges sooner, so it rounds into a drop within about half a second, at Viscosity 0 too. A loose end much thinner than the bead it hangs from (under 65%) retracts into it, so tapered or snapped tails shorten into a round end instead of staying needles. Droplets that touch goo drain into it over 0.15s.
- Round bends. Capsules are straight, so a strand drawn as one capsule per link shows a polygon on tight curves: on a bend of radius 2 R, bead spacing of 0.5 R turns about 14° per capsule. Each intact link is drawn along a Hermite curve through its beads (tangents from the neighbours, scaled to the chord so nothing overshoots), split into up to three sub-capsules; sub-capsules after the first take the inclusion–exclusion flag like any joint. Each turns at most 10° when the blend is tight, up to 20° at a wide Smoothness k, where the blend already rounds the corners between capsules (the shading is continuous either way). A light bending force also pulls each bead toward its neighbours’ midpoint, and any link pulled past 1.7 R gets a new bead at its Catmull-Rom midpoint. The outline of a tight bend is still a polygon, but one of ≤ 10° corners that the blend softens: at Smoothness k 0.06 the zig-zags of one capsule per link are gone, though a slight faceting of the rim remains. The cost is about 1.4× GPU time on curvy strokes.
- A wake that trails, then lets go. The head is a spring that lags the pointer and settles 1.2 R behind the cursor tip, with the offset growing in over the stroke’s first 2 R so a click lays no goo. When you hold still for 0.25–0.7s the head releases its strand: a ghost bead at the tip pinches off and the strand recoils. A real fine pointer is also an obstacle: when it moves slowly or rests, goo within 0.08 screen heights of its tip is pushed aside (beads, the released head bead, and the closest point of each link). While it moves, a smooth subtraction in the distance field parts the goo around the tip; 0.3s after it stops, that fades out, so a resting cursor never leaves a punched hole. Instead, once it has rested for 0.2s, goo within 0.03–0.09 screen heights of the tip fades to transparent, so the button under it stays readable. A stroke that comes to rest also lays thinner goo near the stop, so nothing piles up on the target. In a slow approach that stops on Start free trial, that button is readable 0.8s later and the trail has cleared Watch the demo by 1.5s; before, a fat blob sat on the hovered button for over 1.5s. The ghost pointer and touch never clear goo.
- An intro that shows the material. Before you touch anything, a ghost pointer draws one art-directed stroke, keyed in time and joined by a Hermite spline so its speed is continuous. It makes a generous loop over the headline that crosses itself and merges, then whips out around the right side, so a droplet flies by about 1.5s and the thin strand necks soon after. A slow tail comes to rest bottom right, clear of the buttons. The markup starts in the default light theme, and transitions stay off until the first frames are drawn: the shell switches themes while it boots, and the first frame used to fade in from near-black.
- Translucent over a page WebGL can’t see. The canvas can’t read the DOM, but it knows the page colour. With τ = translucency·min(T), it writes α = 1 − τ and colour bg·(T − τ) plus scatter. The compositor then adds the real page × τ, which yields page·τ + bg·(T − τ): the right tint over the background, and text behind thin goo stays legible. Thick cores and the refracted rim go deep and opaque.
- A drop’s profile, not a puck’s. The height is a spherical cap over the local radius, with a contact slope of 1.8·depth at the edge, so it stays curved all the way to the crest, and the window highlight sits at mid-radius toward the light, as on a real drop. Overlapping goo inflates the smooth union by k·log₂(Σw / max w), so the cap’s radius grows by the same amount; without that, a clump of beads saturated into a flat disc with only a rim (a “coin”). Where two merged strands’ gradients cancel deep inside, the normal levels out instead of creasing into a valley, as liquid would.
- Molten goo. On dark pages Glow darkens the goo’s own albedo to rock and adds emission by heat. Fresh goo is hottest where it is deep, and a slowly churning value noise varies the core from orange to saturated yellow-orange, kept below the shoulder so it doesn’t flatten into one cream tone; the specular spot stays. As it cools (fully by about 75% of its life), crust spreads over it, sooner at thin edges and per bead, from a seed that travels with the goo. The crust is cellular noise: dark rock plates about a bead radius across, their borders wobbled by the churn, split by cracks that glow orange while warm, then narrow and dim to dull red. The halo is scaled by the same heat, so cold crust stops glowing. The softbox reflection dims and softens, so the crust reads as wet black rock rather than orange plastic.
- Trail length is a bead budget. A bead dies when it runs out of life or when Blob count newer trail beads exist (flung droplets don’t count), whichever comes first. The radius holds for most of a bead’s life (r ∝ √(1 − age²)). Over the oldest 25% of the trail it narrows to about two thirds, then the end retracts into its neighbour, so a tail ends in a rounded bead, not a needle. The loop keeps waking while any goo is alive and clears the canvas once it is gone (or once all of it is off-canvas), then idles.
- Tiles made it 4× cheaper. The first version looped every pixel of the trail’s bounding box over all segments: 6.5ms mean / 13.2ms p95 at 2560×1440. Binning segments into tiles of about 2.6 bead radii, with a tighter, faded cull (4.5k, capped at 3.2 bead radii above Smoothness k 0.71), and drawing intact links as one capsule brought it to 1.7 / 3.0ms, with the same image. The Lava halo now lives inside the same cull instead of adding its own reach on top, which had made Lava loop about 2.8× more segments per pixel. A tile is also skipped when it can’t show anything: every weight in it is at most 2−D/k, D a lower bound on that segment’s distance from the tile, so when −k·log₂ Σ 2−D/k is beyond the reach of the edge, the halo and the shadow, the tile is left clear (about 12% fewer tile draws on the default sweep).
- The shadow is part of the field. On light pages the goo casts a tinted shadow: a tight contact shadow and a soft one down-right, away from the key light. It used to be two CSS
drop-shadow()filters on the canvas, a full-screen blur repainted every frame whose cost the GPU timer never saw. Now the shader evaluates the same distance one offset away. The offset (0.16 R) is well under the blur (0.32 R), so first order is enough: d(p − off) ≈ d − ∇d·off, and smoothstep(−blur, blur) of it gives the soft edge. It costs a few instructions per pixel, needs no second loop over the segments, is composited under the goo (it shows through thin goo, as before), and looks the same on phones.
Parameters
Presets
Performance & compatibility
- Measured in headless Chrome (ANGLE-Metal, Apple-silicon Mac) at 1280×720 and DPR 2, so a 2560×1440 backing store, during the harness’s 1.5s lemniscate sweep (with the intro’s loop still alive, which adds bent links). Other agents were rendering on the same GPU throughout (load average 3–10), and the timer then also counts their time slices, so these are upper bounds with a wide spread. Five interleaved runs per preset, GPU mean / p95: Slime 2.7–4.5 / 4.2–11.1ms (median mean 3.0), Honey 2.4–3.8 / 4.6–7.2ms, Lava 2.6–4.9 / 5.8–8.8ms, Ink 2.2–3.9 / 4.9–8.5ms. Full harness runs on the default measured 1.49 / 2.18ms and 2.22 / 3.11ms in quiet minutes and 4.74 / 8.71ms in a busy one, at a steady 60 fps with no frame over 25ms. JS: 0.15–0.5ms per frame for the simulation, binning and the buffer upload.
- What scales the cost. Nearly all of it is the segment loop (a variant that returns right after the loop costs the same), so it is covered pixels × the segments within reach of each pixel. Bigger Blob size, a larger Smoothness k (it widens every cull radius), curvy strokes (up to three sub-capsules per link) and goo that lasts longer (Decay, Blob count) all raise it. Variants without the shading frames at the joints, or without the Lava crust’s cellular noise, measured the same through the contention; the per-pixel shading after the loop, shadow included, is small next to the loop. The worst case, Lava with Blob size, Smoothness k and Blob count at their maximum and Decay 7s, measured 7.2–9.2 / 10.9–14.4ms, alongside an earlier build of this page at 7.5–10.3 / 11.2–22ms in the same minutes. Scaling the sub-capsule turn with k, capping the cull at 3.2 radii and the per-tile skip cut its tile–segment pairs by 38% (the new intro’s curvier loop had raised them). A default frame is 29–65 scissored tile draws of one program, with at most 34 segments in a tile on Slime (40 on Honey and Lava), no render targets and no texture reads. Memory is the canvas, a uniform buffer of a few hundred KB, and a few KB of typed arrays.
- Requirements. WebGL2 only. No float render targets or extensions, so it runs on GPUs without
EXT_color_buffer_float. Segments live in a std140 uniform block of 256 × 3 vec4 per tile (12 KB, inside the 16 KB block size WebGL2 guarantees); every tile’s list is packed into one buffer atUNIFORM_BUFFER_OFFSET_ALIGNMENToffsets and bound per draw withbindBufferRange, so the old 97-segment uniform-array cap is gone. Without WebGL2 the hero stays visible and clickable, and a message card in the corner explains why the goo is missing. - Mobile. Drag to pull the goo. Coarse pointers render at DPR 1.5 (585px wide on a 390px phone) and keep two thirds of Blob count (64 by default), so the slider works across its whole range. Sizes follow min(height, 1.25 × width), so a portrait phone gets proportionate goo, and there is no cursor clearance or push under a finger. On a portrait screen the intro loop is lifted above the hero’s buttons and its tail runs out below them. The shadow is drawn in the shader, so phones get the same shadow as desktops with no CSS filter to composite. The harness measured a 59 fps touch drag at 390px, but it emulates the phone on the desktop GPU: this measures the pipeline at phone size, not phone hardware.
- Idle. The loop runs while goo is alive, clears the canvas when the last bead is gone or when all of it is off-canvas (no tile draws, so the browser would otherwise keep showing the last frame), and stops 1.8s later. Measured: idle 2.0–4.0s after the harness’s final pointer move (the time depends on how long the last goo lives), then zero frames. It also pauses off-screen and in hidden tabs.
- Reduced motion. 150 steps of the intro stroke (2.5s) are simulated off-screen and drawn once: a fresh loop that crosses itself, with the whipped strand pulling off it around the right side, and a “Play anyway” button.
- Gallery embed. The ghost pointer sweeps forever at DPR 1, along a Lissajous at about one screen height per second with tight turns where strands get flung (the intro’s loop would already have beaded into pieces when the poster is taken, 3.2s in).
References & credits
- Inigo Quilez, “Smooth minimum”: the exponential smooth-min, its normalisation and the property table (associative, not rigid). iquilezles.org/articles/smin (article; no code license stated there; implemented here from the formula).
- Inigo Quilez, “2D distance functions”:
sdUnevenCapsule. iquilezles.org/articles/distfunctions2d (article; no code license stated there). Re-implemented here in the a→b frame, with the per-region analytic gradient and degenerate-case handling added. - Inigo Quilez, “Metaballs - Quintic”: field-based blobs, bounding culls and analytic normals. shadertoy.com/view/ld2GRz (MIT, per its header). Background only, no code used.
- Jamie Wong, “Metaballs and WebGL” (2016): the per-pixel loop over uniform arrays and its uniform-count limits. jamie-wong.com/2016/07/06/metaballs-and-webgl (article).
- Lord Rayleigh, “On the instability of jets”, Proc. London Math. Soc. 1878, and the Plateau–Rayleigh instability: why threads bead at about 9 radii. en.wikipedia.org/wiki/Plateau–Rayleigh_instability (overview).
- Dither and lava-crust value-noise hash: David Hoskins, “Hash without Sine”. shadertoy.com/view/4djSRW, MIT License, © 2014 David Hoskins. Notice kept in the shader comment.
- Research:
research/rd-metaballs-sdf.mdin this library (thegoo-syrup-trailcandidate, plus the metaball and smooth-min sections). Lighting and cursor lessons come from the stable-fluids trail in the Russ Hype Machine page: height-field normals, Blinn-Phong, colour by thickness, a CSS drop shadow on light pages, and keeping the cursor’s target visible. The simulation, the renderer and everything else here are written from scratch.