Skip to content
Andrew Voirol
Work → Drop of Blood: Slow-Motion Fluid & Hemoglobin Optics in WebGPU
Interactive SimulationLive

Drop of Blood: Slow-Motion Fluid & Hemoglobin Optics in WebGPU

Real-time 1000 fps slow-motion WebGPU simulation of whole blood drops in calm water — 512² Stockham FFT capillary precursors, 3-level Multigrid MAC fluid dynamics, 393k Lagrangian RBC parcels, multi-drop vortex leapfrogging, and 380–720 nm Prahl spectral optics.

Code↗ Live

512² FFT waves · 192×256×192 MAC · 393k RBC parcels · XDR HDR

Started Nov 10, 2026

In 1885, J. J. Thomson and H. F. Newall published hand-drawn studies of liquid drops falling into miscible baths — documenting how surface-tension crater collapse injects circulation that rolls a single falling sphere into an oblate, hollow-cored vortex torus before baroclinic instability splits the ring into secondary curtains and smaller daughter rings.

Drop of Blood simulates that full multiphase and optical cascade in real time at 1000 fps slow motion using raw WebGPU and 31 custom WGSL compute and optical shaders (0 runtime dependencies). Rather than resetting a canned animation, the vessel runs continuously: you can release a single 3.5 mm bead to study clean symmetric roll-up and osmotic hemolysis, or press-and-hold to swell heavier drops across the water and watch multi-drop wave interference and axial vortex leapfrogging unfold.

Coupled multiphase & spectral GPU pipeline

Standard graphics smoke solvers fail on liquid-in-liquid plumes: collocated pressure grids leave odd-even divergence spikes that pinch vortex bottoms into pointed cones, Eulerian grid advection smears millimeter stems into fog, and RGB Beer–Lambert turns thin hemoglobin fringes muddy brown. Every frame instead steps exact dispersive surface waves, staggered MAC multigrid projection, Lagrangian red-blood-cell parcels, and spectral radiative transfer:

ω(k)=gk+σρk3,μeff(λ)=−1dcellln⁡ ⁣(1−fpack+fpack e−μHb(λ) dcell)\omega(k) = \sqrt{g k + \frac{\sigma}{\rho} k^3}, \qquad \mu_{\text{eff}}(\lambda) = -\frac{1}{d_{\text{cell}}}\ln\!\Bigl(1 - f_{\text{pack}} + f_{\text{pack}}\,e^{-\mu_{\text{Hb}}(\lambda)\,d_{\text{cell}}}\Bigr)ω(k)=gk+ρσ​k3​,μeff​(λ)=−dcell​1​ln(1−fpack​+fpack​e−μHb​(λ)dcell​)

Left: exact capillary–gravity dispersion solved in 512 × 512 Fourier space (Δx=6.25 mm\Delta x = 6.25\text{ mm}Δx=6.25 mm) lets short capillary ripples (λ<17 mm\lambda < 17\text{ mm}λ<17 mm) outrun the gravity crater. Right: Duysens discrete-cell sieve flattening models hemoglobin packaged inside 8 µm biconcave erythrocytes (Hct ~ 45%) alongside Scott Prahl's 380–720 nm HbO2\text{HbO}_2HbO2​/dHb\text{dHb}dHb molar extinction spectra, keeping 3–4 mm aerial cores opaque oxblood (< 0.05% sky transmission) while rendering lysed plasma (concTex.g) as a translucent ruby-rose absorber.

Pass / SubsystemGrid / BudgetWGSL Implementation
2D Stockham FFT meniscus512 × 512 (3.20 m span)Unitary radix-2 FFT exact phase rotation + viscous 2νk22\nu k^22νk2 damping + circular Rayleigh outer absorber
Staggered MAC + Multigrid192 × 256 × 192 (~5.0 mm)Face-centered velocity + 3-level red-black Gauss–Seidel V-cycle + shear-thinning Casson blood viscosity
Lagrangian RBC ring buffer393,216 parcels (concTex RGBA16F)Tracks intact erythrocytes (.r), hypotonic lysed plasma (.g), oxygenation/shear (.b), and floor rouleaux bed (.a)
Volumetric + Retina raytracerHalf-res + 1:1 Retina + 16× SSAA8-tap C2C^2C2-cubic B-spline density, Snell's Window & wave-warped TIR, dual-lobe Henyey–Greenstein Mie scatter
Apple Silicon XDR swapchainrgba16float (extended) / bgra8unormPiecewise IEC sRGBmidtone parity (Δ <= 0.0033) with unclipped > 1.0 specular headroom on XDR displays

Single-drop vs. multi-drop physics & macro inspection

  • Quick squeeze vs. held Young–Laplace pendant drops: Clicking anywhere on the meniscus squeezes a brisk 3.5 mm bead from the borosilicate Pasteur pipette (y = +0.55). Pressing and holding (0.16–2.2 s) integrates V∝tV \propto tV∝t capillary swelling on the glass orifice — changing drop radius, initial osmotic surface lysis, Stokes settling velocity, and vortex circulation.
  • Wake slipstreaming & vortex leapfrogging: Releasing a second drop above an active submerged torus pulls the trailing plume into the low-pressure downward wake of the first ring, accelerating it straight through the primary core while circular capillary wave trains intersect cleanly across clear water (0 false red meniscus tinting where blood hasn't touched the surface).
  • Macro 0.24 m inspection & paused 16× SSAA: Drag to orbit, Shift + drag (or two-finger drag) to pan in 3D, scroll to 24 cm macro focal distance with physical pupil stop-down, press F to cycle Focus across individual plumes, L to toggle Backlit vs. Dark Field chiaroscuro lighting, and Space + . to single-step substeps while progressive 16× golden-ratio SSAA converges the frame.
WebGPUShadersApple SiliconAnimationDesignShippingOpen Source

Related Threads

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.


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.