How it works

How it works

A small stable-fluids simulation carries a single channel of ink, and the ink is never drawn as a cloud: only its iso-contours are, as lines that keep the same pixel width however hard the flow stretches them. Because the ink is advected, every contour is a material line, a thread of liquid that moves with the flow. Dragging the cursor combs the threads into long parallel filaments that fold around vortices and nest like suminagashi marbling or a moving topographic map. A click drops ink that pushes the older rings aside, the way a drop spreads on a marbling bath.

Pipeline (per frame)

Sizes at a 2560×1440 backing store (1280×720 CSS px at DPR 2). Steps of ~1/60 s, one per frame at 60 Hz;
on 90–144 Hz displays a frame between steps draws the latest ink back-warped along the last velocity.

pointer ─▶ critically damped spring (ω 32/s) whose target glides to the cursor over each step
   └─▶ ink      ≤16 erf ridge segments per step, blend ONE,ONE, scissored ─▶ ink  R32F  1707×960
click / intro ─▶ drop: C²-footed cone at 0.45·R, blended once + spreading-flow uniforms (≤6 drops)

vel ─▶ curl + rotation weight RG16F ─▶ vorticity confinement (vortex cores only)   vel  RG16F  228×128
    ─▶ viscosity (v₀ parked, 10 Jacobi)
    ─▶ k sub-steps, k = clamp(⌈brush travel / ½σ⌉, 1, 3):
         grip (erf-weighted mix toward the brush velocity over 2.5σ, speed soft-capped)
         ─▶ divergence (free-slip walls) ─▶ red-black SOR ×20 (×8 when k > 1, warm) ─▶ v −= ½∇p
         ─▶ snapshot ─▶ semi-Lagrangian self-advection by h/k, fade 0.6/s
ink ─▶ MacCormack A  back-trace by B-spline(vel) + drop flow ──────────────────▶ hat  R32F  1707×960
    ─▶ MacCormack B  hat + β(CFL)·½(φ − fwd), clamp to the 4 source texels,
                     + 0.06·∇²hat, fade ──────────────────────────────────────▶ ink  R32F  1707×960
    (k > 1: both again, scissored to the brush path, tracing through all k snapshots)
    (ink is R16F where R32F can't be filtered or blended)

dark grounds only (allocated on first use):
ink ─▶ bloom source: box-filtered line coverage × colour ───────────────────────▶ RGBA16F  640×360
    ─▶ 4 × 5-tap down (to 40×23) ─▶ 4 × 8-tap tent up, added level by level

ink (+ bloom, + washi paper RGBA8 512² mipmapped, drawn once on a 2D canvas)
    ─▶ display 2560×1440: [between steps: offset + Jacobian from B-spline(last vel) + drop flow]
       f = bands·T(B-spline(ink)); ∇f and Hessian from 7 taps;
       contour level of detail (2 candidates/pixel); second-order distance to each level
       ─▶ 1 px anti-aliased edge; colour by level
       paper: fibre-feathered ink + soft line shadow (quadratic model at p − offset, faded by spacing)
       night: Tanaka lighting + wire glint + bloom + hue-keeping shoulder; ±1/255 dither

The ideas that matter

Parameters

Presets

Performance & compatibility

References & credits