Amber Oil Timer
Bunny Chen · v1.1.1

Amber Oil Timer

Turn a glass timer and follow the oil as it drips through ramps, turns the wheels, and gathers in the receiving chamber.

The Twin Wheels design running in the browser
Twin Wheels in motion. Wheels, ramps and the receiving well share one volume ledger.

Watch the oil in motion

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.

Measured silhouettes at one scale, from a near-spherical small drop to a spread large drop, aspect ratio falling from 0.94 to 0.32
Four silhouettes taken from the actual Ultra triangle mesh. With the same plate, oil and lateral shake, a drop of radius 0.150 stands about 0.223 high, while a pool of radius 0.230 spreads to about 0.169. Widths are about 0.347 and 0.527 in model length. The first three are sampled at 0.76 s, the largest at 1.50 s.

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.

Wall film
The oil left in the tank sets the wetted area, surface level and ripples.
Local detachment
Weber number is estimated from local speed, shear and stretch. A hard shake sends some particles off with their real volume and momentum.
Return and merge
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。

Hanging Gardens tilted: oil pooling on the low side of the plate above the receiving tank
Hanging Gardens fed at a tilt. Oil can gather on the low side and leave the drain hole alone; it drains only where the wet area covers the opening and the valve is open.

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

gbottle = Q⁻¹ gworld  Δt = 1/120 s

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

R = (3V / 4π)1/3  Bo = R² aₙ / τ
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.

Fixed at aₙ = 2.65, τ = 0.022.

3 How the plate carries oil to the drain

Vplate = Σ A hᵢ  hᵢ ← hᵢ − q  hⱼ ← hⱼ + q

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

The support region of one particlehNeighbourhood of particle iCore: w large, stronger near-field repulsionRim: w approaches 0Outside: not counted in the density sum
A 2D section through particle i. The real solve is in 3D; dashed lines mark the kernel support radius for this pair.
wᵢⱼ = max(0, 1 − dᵢⱼ/hᵢⱼ)
ρᵢ = Σ (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.

We = L u² / τ  Vfilm = Vtank − Σ fᵢ Vᵢ
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

Two drops merging through a liquid bridgeBefore contact→Bridge carries volume→Round again after merging
The sketch shows contact order only. How much oil moves per step is set by bridge progress.
F(t) = 3t² − 2t³  ΔV = Vsmall,0 [F(t₂) − F(t₁)]
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

ωₖ² = (gk + c k³) tanh(kH)

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

Oil surface rebuilt from local particlesParticles with volume→Oriented kernel splat→Continuous isosurface
Particle stretch sets the reconstruction kernel. After meshing, a ray can still query the same 3D field for exit distance.
K(q) ∝ max(0, 1 − q²)³  T(ℓ) = exp(−σₐ ℓ)

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

Single-cavity pipelineSolve threadImage threadSolve ASolve BSolve CRebuild ARebuild Btime →
A, B and C are sequential input batches. Once snapshot A is done, solving B and rebuilding A run at the same time; the display publishes the surface and mechanism state of one instant together.

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.

  1. 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.
  2. 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.
  3. 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.

Old 2140225 → optimised de76fda
Design and render sizeSurface updates/sInterval p95Simulated time in 6 s
Twin Wheels · 2560 × 144024.3 → 50.642.1 → 21.2 ms4.90 → 6.01 s
Lunar Halo · 1280 × 72024.5 → 52.642.1 → 21.1 ms4.93 → 6.03 s
Hanging Gardens · 1280 × 72017.8 → 72.470.1 → 14.6 ms3.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

  1. 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.
  2. 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.
  3. 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.

  1. Van der Laan et al. on screen-space fluid rendering
  2. Experiment and theory of drop motion in a conical capillary
  3. Zhang and Stone on pendant drops in a capillary
  4. Prosperetti on drop oscillation
  5. Solid boundaries and tangential slip
  6. Coalescence in an outer carrier liquid
  7. Eggers, Lister and Stone on drop coalescence
  8. Linear surface waves at finite depth
  9. High-speed observation of drops and pools
  10. Shallow-water height-field simulation
  11. Lorensen and Cline on Marching Cubes
  12. Crane, Llamas and Tariq on 3D fluid rendering
  13. Two-liquid toy observations, figures 1–3
  14. Sessile drop from spherical cap to flat
  15. W3C Device Orientation and Motion
  16. Shoemake on Arcball
  17. Scardovelli and Zaleski on volume-of-fluid cutting planes
  18. Chentanez, Müller and Kim on hybrid liquid simulation
  19. Clavet, Beaudoin and Poulin on double-density relaxation
  20. Yu and Turk on anisotropic fluid surface reconstruction