Watch the oil in motion
- Follow the first dropChoose the nozzle camera. Watch the tip fill, narrow and release the drop.
- Tilt the guideIn Twin Wheels, use Q or E to tilt the timer. Watch where drops pool and how they move as the slope changes.
- Shake and let it settleHold S, then release it. Switch to the receiving chamber camera to watch ripples and fragments.
Why small drops stay round and large drops flatten
In a real two-liquid toy, two immiscible liquids trade places because of a density difference. A falling drop meets a surface of its own phase and briefly touches before merging. On a solid, interfacial tension pulls the surface area smaller while gravity spreads the liquid sideways. In sessile-drop experiments the height rises steeply with volume at first, then levels off toward a limit.
The toy and the experiments are documented inthe two-liquid toy observations, figures 1–3、the experiment where a sessile drop goes from spherical cap to flat。
The code computes load from equivalent parameters in model units and lets a drop approach its pressed equilibrium shape as a damped oscillation. Very large pools hand their oil to the film on the plate, and neighbouring cells exchange oil by head difference. When a flip removes the support, oil detaches from the film it was sitting on. Free pendant drops, the neck at the nozzle and narrow rails each keep their own contact constraint.
From whole-tank drawing to local oil exchange
The old failure could be triggered on demand. With container pose, oil volume and particle coordinates fixed, moving the tank-wide active weight from 0 to 0.35 alone changed the surface mesh. Under a slight turn back and forth the user saw the whole pool suddenly shrink into one big bead. We also tried drawing the entire tank from particles, but the sampling density we can afford makes a shallow film look thick and erases the dimple left by a small drop.
The oil left in the tank sets the wetted area, surface level and ripples.
Weber number is estimated from local speed, shear and stretch. A hard shake sends some particles off with their real volume and momentum.
A drop on the wall moves its oil across a liquid bridge. Thin film and fragments both write into the 3D field, and one surface is extracted from it.
The implementation leans on film–particle coupling, near-field pressure relaxation and anisotropic surface reconstruction. A regression test holds the local oil state and steps the active weight through 0 → 0.35 → 1 → 0.35 → 0, comparing mesh positions and indices at each step. A hard-shake input checks that wall oil and detached fragments exist at the same time, and that the per-particle sum matches the tank ledger.
The algorithms come fromChentanez, Müller and Kim on hybrid liquid simulation、Clavet, Beaudoin and Poulin on double-density relaxation、Yu and Turk on anisotropic fluid surface reconstruction。
From input to pixel: the core in steps
Lengths and times below stay in the model units and seconds used in the engineering notes. Bo and We are dimensionless ratios; pressure coefficients, response rates and thresholds are approximations for this project. Diagram outlines are schematic, and can be compared with the measured silhouettes above.
1 Move into the bottle frame
Q is the bottle orientation; Q⁻¹ here means rotating a vector by the inverse. While the bottle turns, local coordinates also pick up −α×r, −ω×(ω×r) and −2ω×v for angular acceleration, centrifugal and Coriolis terms. r is the offset from the rotation centre and v the relative velocity, so oil at the centre and at the far end feels different loads. When the gesture reverses, input samples advance in arrival order and physics updates only once a whole fixed step is filled.
2 Shape held by gravity and interfacial tension
s″ + 2ζωs′ + ω²(s − s★) = 0
τ is the effective interfacial tension over density in the model, aₙ the normal load toward the plate. s is the stretch along the deformation axis and s★ its current equilibrium. The axial radius is Rs and both lateral radii are R/√s, so the three multiply to R³. A free small drop returns to round faster after a disturbance because capillary frequency scales with R to the −3/2 power; the implementation clamps angular frequency to 19–57 rad/s.
The static flattening term on the plate is 0.35 Bo/(1+Bo). An impact adds a transient on top; a large enough pool starts delivering volume into the plate depth field once Bo>4. This demo shows the static term and the transfer condition only, without impact or flow.
3 How the plate carries oil to the drain
Each cell of the plate grid has area A and depth hᵢ. The head difference between two cells accounts for plate bottom height, local depth and the in-plane component of gravity. q is the depth moved in this step, the smallest of the available depth, the head-limited value and the viscous transport value. Neighbouring cells have equal area, so the volume taken from one equals the volume received by the other. Only the area over the opening takes part in draining, so a tilted plate still holds oil on the low side.
4 Neighbourhood pressure and local breakup
ρᵢ = Σ (Vⱼ/V₀) wᵢⱼ² ρnearᵢ = Σ (Vⱼ/V₀) wᵢⱼ³
d is centre distance, h the support radius and V₀ the reference particle volume. The two sums estimate local packing. The code turns the deviation of the first from rest density into pressure, the second into near-field pressure, then applies pairwise position corrections along the line between the two particles. Each side takes a share of the move by the other's volume, so the smaller particle moves further. Cached pair distances let both passes share one value.
fᵢ ← fᵢ + (f★ − fᵢ)(1 − e−kΔt)
L is a local length scale, u combines local speed, shear and stretch, and fᵢ is the share of detached volume particle i actually carries. Exposure, connectivity and We together set the target f★. k follows the capillary response, so oil can leave or rejoin the film within a few steps. Particle splitting has its own local criterion; no single We value acts as a switch for the whole tank.
5 How a liquid bridge moves mass and momentum
vnew = (Vlarge vlarge + ΔV vsmall) / (Vlarge + ΔV)
t is bridge progress from 0 to 1. F has zero slope at both ends, so transfer starts and stops gently. Oils of equal density can use a volume-weighted velocity directly. The subtracted and added ΔV are equal, and total momentum is the same before and after. Two drops must touch first, and their relative speed and slip must be small enough, before a bridge forms.
6 How a shallow film gets dimples and ripples
k is the wave number, H the mean depth and c the capillary coefficient of the wave model. Gravity dominates long waves; interfacial tension shows more on short ones. When H is small the floor limits vertical motion, and the implementation scales impact amplitude by tanh(kH). Reflections in the rectangular tank use a 29 × 7 cosine basis, with fast decay for short waves. The uniform-lift mode is excluded so ripples cannot create oil.
How the oil type changes the swing after release
The restoring term for a tilted tank has coefficient 36, a natural angular frequency of 6 rad/s. Slosh damping is set per oil: 0.40 for light, 0.60 for standard, 1.03 for high viscosity. Supply, bridge exchange and drop deformation keep their own coefficients. All three oils share the static interfacial tension and plate wetting model, so at equal volume, support and tilt a fully settled profile follows the same scaling.
7 From particle kernels to isosurface to amber
q is distance normalised along the ellipsoid support axes. Dense interiors add smooth kernels while sparse fragments keep a local core; wall film and moving pools both enter the scalar field. The isosurface is corrected to the tank's total oil and clipped against vessel walls and mechanism. Marching Cubes interpolates triangles on grid edges that cross the surface.
Shading queries the oil boundary from the entry point along the refracted direction to estimate path length ℓ. σₐ is absorption per colour channel and T the transmitted fraction. For example a channel that keeps 70% through one layer keeps about 49% at twice the path. The shader also combines several absorption segments and interface reflection, so the same geometry can look deeper or shallower as the view changes.
8 How throughput and simulated time are checked
In steady state the two serial stages add up, and the interval between finished batches approaches the slower stage plus messaging and scheduling. The first batch still passes through both in order. Acceptance therefore records the new-mesh interval, the simulated time advanced within 6 s, and the order of reversed input. The table below gives the measured values.
Source files behind the formulas (project paths)
src/handling.jshandles pose and inertia;src/fluid/capillary.jsdrop shape and liquid bridges;collector-layer.jstransport across the plate;reservoir-fluid.jsneighbourhood pressure and detached volume;pool-waves.jsmodal waves;reservoir-surface.js、surface.jsandview.jsrebuild the surface and shade it;threaded.jsandworker.jshandle scheduling. Short file names below live insrc/fluid/。
Why solving and shading go to different cores
On the old version a hard shake turned the shell with your hand while the oil surface updated only about every 42 ms. The main thread still had time to draw, but the background had to finish particle pressure, connectivity checks and surface reconstruction in order. Watching only total CPU or display frame rate easily hides that wait.
- Main thread records input.Pose and direction reversals inside a batch are kept, and physics advances in 1/120 s steps. The background takes the next batch as soon as it is free; the foreground usually keeps up to 80 ms of catch-up time.
- Worker threads run in parallel.On a single-cavity design with four or more logical cores, one core solves the next batch while another rebuilds the mesh from the previous snapshot. Independent double cavities run per compartment and display once both are ready. Fewer cores fall back to the serial path.
- The GPU draws the optics.The 3D field supports view-direction refraction, absorption from oil thickness and projection from the light direction. Screen-space reconstruction suits scenes that only need the current view; this project needs thickness data in other directions too.
On the CPU side both pressure passes reuse the same pair distances and the search range narrows to the largest touching radius. In a fixed hard-shake run with 960 particles, the median step time fell from 10.32 to 8.14 ms and p95 from 11.47 to 9.10 ms, at a cost of 150 KiB of fixed buffers per compartment. Particle snapshots and mesh buffers can move ownership between threads.
Shading methods are compared inVan der Laan et al. on screen-space fluid rendering、Lorensen and Cline on Marching Cubes。
Measured performance under a hard shake
These historical measurements compare two development builds under the same workload. They are not benchmarks for v1.1.1.
i7-14700KF, RTX 4070 Ti, Edge on D3D11, single HTML at high quality. Hold S for 2.5 s to warm up, then sample for 6 s. Surface update rate comes from uploads of new triangle indices; simulation progress comes from worker time slices. All three designs reach 224 channel mist droplets.
| Design and render size | Surface updates/s | Interval p95 | Simulated time in 6 s |
|---|---|---|---|
| Twin Wheels · 2560 × 1440 | 24.3 → 50.6 | 42.1 → 21.2 ms | 4.90 → 6.01 s |
| Lunar Halo · 1280 × 720 | 24.5 → 52.6 | 42.1 → 21.1 ms | 4.93 → 6.03 s |
| Hanging Gardens · 1280 × 720 | 17.8 → 72.4 | 70.1 → 14.6 ms | 3.60 → 6.01 s |
Long intervals on Twin Wheels roughly halve and simulated time keeps up with real time. p95 means about 95% of update intervals fall at or below that value. Timing is booked at batch completion, so window edges can differ by tens of milliseconds.
How to check it in the finished piece
- Small turn, then stop.While a shallow film has just formed in the receiving tank, turn back and forth slightly. Watch the wall film, local ripples, and whether one patch of oil suddenly shrinks into a single ball.
- Hard shake, then release.Hold S on the web build for a few seconds to see sustained breakup, then release and watch fragments merge where they actually touch. Check where oil pools when tilted, plus the valve and drain hole.
- Compare sizes.Watch a small drop recover after hitting the plate, and a large pool spread sideways. The silhouette figure gives a same-scale reference for aspect ratio and plate coverage.
Versionde76fdapassed all 138 automated tests, covering conservation, wall slide-off, nozzle continuity, breakup and return, in-batch direction reversal, and snapshot versus direct rebuild. Desktop web and the wallpaper entry were tested offline in Edge. Table data comes from the browser; native Wallpaper Engine host frame rate still needs a machine test. Carrier flow, microscopic film drainage and contact angle are real-time approximations, and the parameters are not calibrated against the oil of one physical hourglass.
References and further reading
These links are the experiments, algorithms, interfaces and visual references used in the engineering notes. Body images and captures are embedded; opening the originals needs a network connection.
- Van der Laan et al. on screen-space fluid rendering
- Experiment and theory of drop motion in a conical capillary
- Zhang and Stone on pendant drops in a capillary
- Prosperetti on drop oscillation
- Solid boundaries and tangential slip
- Coalescence in an outer carrier liquid
- Eggers, Lister and Stone on drop coalescence
- Linear surface waves at finite depth
- High-speed observation of drops and pools
- Shallow-water height-field simulation
- Lorensen and Cline on Marching Cubes
- Crane, Llamas and Tariq on 3D fluid rendering
- Two-liquid toy observations, figures 1–3
- Sessile drop from spherical cap to flat
- W3C Device Orientation and Motion
- Shoemake on Arcball
- Scardovelli and Zaleski on volume-of-fluid cutting planes
- Chentanez, Müller and Kim on hybrid liquid simulation
- Clavet, Beaudoin and Poulin on double-density relaxation
- Yu and Turk on anisotropic fluid surface reconstruction