Skip to content
Andrew Voirol
Work → Drop of Blood: Slow-Motion Fluid & Hemoglobin Optics in WebGPU → Building Drop of Blood: Multiphase Hemorheology & Spectral Optics in WebGPU
ThreadActive

Building Drop of Blood: Multiphase Hemorheology & Spectral Optics in WebGPU

Replacing graphics smoke advection and plate waves with 393,216 Lagrangian red-blood-cell parcels, a 3-level Multigrid MAC solver, 512² Stockham FFT capillary waves, and 380–720 nm hemoglobin optics.

Code↗ Live
Started Oct 30, 2026·Latest Nov 10, 2026·5 entries

What happens at 1000 fps when a single bead of whole blood releases from a borosilicate Pasteur pipette into calm water — and what changes when a second or third bead plunges into its wake? My initial prototype tried to fake the answer with standard graphics smoke (collocated Jacobi pressure, BFECC advection, RGB Beer-Lambert, and a finite-difference wave spring). Within half a second of impact, every shortcut betrayed itself: residual velocity divergence pinched the bottom of the drop into a pointed spear instead of an oblate Thomson–Newall vortex ring, numerical diffusion blurred sub-millimeter tendrils into grey fog, and clear water ripples pulsed red whenever they crossed over an older submerged plume.

Rebuilding the engine from physical first principles meant coupling five real-time WebGPU solvers inside a zero-allocation single-encoder frame: a 512 × 512 unitary 2D Stockham FFT free-surface solver (ω2=gk+(σ/ρ)k3\omega^2 = gk + (\sigma/\rho)k^3ω2=gk+(σ/ρ)k3) so capillary precursor ripples outrun the main gravity crater; a 192 × 256 × 192 staggered MAC incompressible solver with a 3-level geometric Multigrid V-cycle and shear-thinning Casson blood rheology; 393,216 Lagrangian erythrocyte parcels tracking intact cells, lysed free-hemoglobin plasma, oxygenation, and circular floor rouleaux sediment; and a two-stage volumetric + 1:1 Retina raytracer integrating Scott Prahl's 380–720 nm HbO2\text{HbO}_2HbO2​/dHb\text{dHb}dHb molar extinction curves with Duysens discrete-cell sieve flattening and Apple Silicon XDR rgba16float headroom.

Once the vessel stayed continuous across drops, multi-drop dynamics emerged without scripted choreography: holding the pointer swells larger Young–Laplace pendant drops (V∝tV \propto tV∝t) on the glass tip, staggered impacts weave clean circular interference patterns across the meniscus, and a second drop released above an active torus accelerates down the primary slipstream to leapfrog straight through the older ring's core before unfurling into ruby-rose osmotic hemolysis veils.

Latest Update

512x512 FFT capillary precursors and paused 16x SSAA macro inspection

Tue, Nov 10, 2026

Timeline

My first WebGPU prototype looked right for about half a second after splashdown — until you watched the ripples and the vortex bottom. Under the hood I had reached for standard graphics shortcuts: a 26-iteration collocated Jacobi pressure pass on a 96×128×96 grid, MacCormack BFECC smoke advection, RGB Beer-Lambert (σ = [136, 820, 1100]), and a 2D finite-difference wave grid with a −κ η-\kappa\,\eta−κη restoring spring. Auditing the PDEs against Thomson & Newall's 1885 vortex-ring plates exposed four coupled failures at once: collocated central differences decoupled odd-even pressure modes and left 15–30% residual divergence that pinched the bottom of the drop into a pointed axial spear instead of an oblate torus; BFECC diffused sub-millimeter erythrocyte curtains into cotton-ball smoke within 80 steps; the −κ η-\kappa\,\eta−κη term turned the water surface into a Klein-Gordon elastic trampoline; and pure exponential RGB absorption lacked hemoglobin's 415 nm Soret band, turning thin fringes muddy brown. Fixing any of them meant tearing out the smoke solver for real multiphase and spectral physics.

WebGPUShadersArchitecture
Permalink →

Replacing Eulerian smoke advection with 393,216 Lagrangian red-blood-cell parcels and a staggered 3-level Multigrid MAC solver finally produced a real Thomson-Newall vortex torus. Moving velocity components onto true 192×256×192 staggered MAC faces (~5.0 mm voxels) and projecting pressure through a 3-level red-black Gauss-Seidel Multigrid V-cycle killed the axial V-tip spear (centerSpearExcessPx <= 14) while incorporating shear-thinning Casson blood rheology (τ=τy+μ∞γ˙\sqrt{\tau} = \sqrt{\tau_y} + \sqrt{\mu_\infty\dot{\gamma}}τ​=τy​​+μ∞​γ˙​​). Because particles carry zero numerical grid diffusion, individual erythrocyte parcels hold crisp capillary stems (emptyGapScanlines === 0) and transfer mass symmetrically into lysed plasma (concTex.g) and floor rouleaux sediment (concTex.a). On the optical side, integrating Scott Prahl's 380–720 nm HbO2\text{HbO}_2HbO2​ and dHb\text{dHb}dHb molar extinction tables against CIE 1931 xˉ,yˉ,zˉ\bar{x},\bar{y},\bar{z}xˉ,yˉ​,zˉ with Duysens discrete-cell sieve flattening kept 4 mm oxblood cores opaque (< 0.05% ballistic sky transmission) while preserving translucent ruby pinch-off necks.

WebGPUShadersApple Silicon
Permalink →

Enabling WebGPU rgba16float with toneMapping: { mode: 'extended' } on a MacBook Pro XDR display unexpectedly crushed the entire water tank three stops dark. Headless SDR screenshots looked normal because they fell back to bgra8unorm, but macOS extended-sRGB swapchains apply the piecewise IEC 61966-2-1 sRGB transfer curve across [0, 1] while leaving values above 1.0 unclipped for specular headroom — feeding raw linear radiance straight out of tone mapping darkened midtones by ~3×. Encoding linearToSRGB(mapped) + edrBoost restored 1:1 SDR midtone parity (maxMidtoneSdrDiff = 0.0033) while pushing meniscus highlights to 1.32× EDR peak. In the same live audit I killed two subtle multi-drop bugs: an outer eta * sponge wave clamp was bouncing circular drumhead echoes inward across clear water, and meniscus blood tinting wasn't gated by surface contact, making clear ripples pulse red whenever they crossed over an older submerged plume (clearWaterRedRipplePx -> 0).

WebGPUApple SiliconShaders
Permalink →

One drop in calm water is an anatomy lesson; a second or third drop is where the fluid dynamics start surprising you. Instead of resetting the tank on every click, I turned the 393,216-particle ring buffer into a continuous open vessel (autoLoop = false) and coupled pointer press-and-hold (0.16–2.2 s, V∝tV \propto tV∝t) to a Young-Laplace pendant drop swelling directly on a borosilicate Pasteur pipette tip (y = +0.55). Releasing a small brisk bead vs. a heavy held drop changes initial osmotic swelling, Stokes settling speed, and toroidal core inertia. Better still, dropping a second bead above an active vortex ring pulls the newcomer into the low-pressure downward slipstream of the first plume — accelerating it straight through the older ring's core in classic axial vortex leapfrogging while their circular wave trains cross cleanly on the meniscus above.

WebGPUAnimationDesign
Permalink →

Before taking Drop of Blood live, I wanted you to be able to pause mid-leapfrog, zoom 24 cm from a bifurcating tendril, and find zero voxel staircases or wave-grid artifacts. First, I upgraded the free surface to a 512×512 unitary 2D Stockham FFT solver (Δx=6.25 mm\Delta x = 6.25\text{ mm}Δx=6.25 mm across 3.20 m with a circular Rayleigh absorber), integrating exact capillary-gravity phase rotation ω(k)=gk+(σ/ρ)k3\omega(k) = \sqrt{gk + (\sigma/\rho)k^3}ω(k)=gk+(σ/ρ)k3​ so high-frequency capillary ripples genuinely outrun the main gravity swell on impact. Second, I replaced scalar FBM plume noise with divergence-free curl-potential breakup (∇⋅usub≡0\nabla \cdot \mathbf{u}_{\text{sub}} \equiv 0∇⋅usub​≡0) and C2C^2C2-continuous cubic B-spline density reconstruction (8 hardware trilinear taps). Finally, adding 0.24 m macro zoom, Shift+drag 3D pan, F plume focus cycling, and automatic 16× golden-ratio progressive SSAA convergence whenever paused let me verify every single-drop and multi-drop regime before deploying to drop-of-blood.andrewvoirol.com.

WebGPUShadersShippingOpen Source
Permalink →

Andrew Voirol

Builder, hacker, shipper. Currently leaving localhost.

Navigate

WorkThreadsBuilder's LogAboutContactRSS Feed

Connect

X / TwitterGitHubLinkedIn

© 2026 Andrew Voirol·Back to top ↑
✦Just one prompt away from figuring it all out.