Stable fluids · MacCormack advection

Every stroke
leaves a wake.

Hair-thin threads of dye ride a real fluid simulation, lit like chrome and kept crisp for about three seconds before they fade.

How it works
How it works

How it works

Every stroke lays a bundle of hair-thin threads of dye into a real, viscous stable-fluids simulation. The fluid drags them into lazy S-curves around the vortices the stroke leaves behind; they hold for about three seconds, then thin and fade. Two things make it work. Second-order MacCormack advection keeps the threads crisp and separate for their whole life; toggle Advection in the hero and semi-Lagrangian widens each thread until the display drops it, within about 1.5 s (turn on Raw dye in the controls to watch the blur itself). A display pass then rebuilds each thread's round cross-section from the dye field, so it can be lit like a chrome tube: a white-hot core, coloured flanks and a rim, with bloom on dark and a soft cast shadow on light.

Pipeline (per frame)

pointer ─▶ timestamped samples, read back 25 ms late at each step's own time
           ─▶ critically damped spring (ω 60 rad/s), sub-stepped ≤ 0.012 screen heights
           │  fixed 60 Hz step from an accumulator: 0–1 steps per frame at 120 Hz, 2 at 30 Hz
           ▼
SIM STEP   S = velocity 228×128 RG16F (sim 128, 16:9)    D = dye 1820×1024 RGBA16F (dye 1024)
  strands ×~10      capsules over the path the deposit point (0.1 h behind the brush)
                    passed, ridges at p − u·dt·age, tapered heads, blend MAX   ──▶ dye  D
  grip discs ×1–6   Gaussian disc per spring sub-step, blend SRC_ALPHA,
                    mix(v, 0.4·v_stroke, w·grip), target ≤ 1.6 h/s             ──▶ vel  S
  stop fade         hard stop or cut-off stroke: dye × (1 − k·disc) at heads   ──▶ dye  D
  vorticity         curl inline (5 taps) + confinement, |v| ≤ 3 h/s            ──▶ v₀   S
  viscosity ×3      fused red-black Gauss-Seidel on (I − ν·dt·∇²) v = v₀       ⇄  vel  S
  divergence        open boundary (zero-gradient outflow)                      ──▶ div  S  R16F
  pressure ×6       fused red-black SOR, ω 1.8, warm start ×0.85, p = 0 out   ⇄  p    S  R16F
  gradient          v −= ½·∇p (consistent with the ½ in the divergence)        ──▶ vel  S
  backtrace         midpoint (RK2) displacement and its reverse, B-spline u    ──▶ disp S  RGBA16F
  dye pass A        semi-Lagrangian step along disp                            ──▶ tmp  D
  dye pass B        reverse step + ½ error, clamp to the 4 source texels, fade ──▶ dye  D
  velocity advect   semi-Lagrangian self-advection, fade 0.5/s                 ──▶ vel  S
RENDER (only on frames where a step ran or a control changed)
  bloom prefilter   tube shading 2×2 per texel, soft knee + Karis average      ──▶ 640×360 RGBA16F
  bloom             3 dual-filter downs, 3 ups                                 ──▶ 640×360 … 80×45
  composite         4×4 B-spline dye stencil → Hessian of log d → crest distance, σ, peak
                    → tube shading per channel (4 corner lights, glints, core, rim)
                    → fresher strands in front, text guard, clear zone
                    dark: background screened by 1 − e^−(strands + bloom)
                    light: paper × offset multi-scale shadow, strands over
                    + interleaved-gradient-noise dither                        ──▶ canvas 2560×1440
draws: 16 sim passes + ~10–16 splats per sim step, 8 per rendered frame

The ideas that matter

Parameters

Presets

Performance & compatibility

References & credits