Math reference
For the curious. Sacred Drift is a 3D particle simulation: each particle is integrated through one of five vector fields, optionally pulled toward a 1D skeleton in space, then composited with additive blending and HDR bloom.
1. Curl-noise drift
The default motion mode. A smooth, time-varying pseudo-velocity field built from compositions of sin and cos at three spatial frequencies. Each particle samples this field at its current position and integrates forward in time:
vx = sin(0.7·2π·y + 0.31·t) · cos(0.5·2π·z + 0.17·t) + 0.4·sin(1.3·2π·z + 0.11·t)
vy = sin(0.6·2π·z + 0.23·t) · cos(0.8·2π·x + 0.19·t) + 0.4·sin(1.1·2π·x + 0.13·t) − 0.08
vz = sin(0.5·2π·x + 0.29·t) · cos(0.7·2π·y + 0.21·t) + 0.4·sin(0.9·2π·y + 0.07·t)
The −0.08 on vy is a small downward bias that gives the field a settling, breathing quality. Position update is forward Euler:
x(t + Δt) = x(t) + v · speed · Δt
Particles toroidally wrap at the cube edges of the spread region.
2. Strange attractors
Four classical 3D dynamical systems, each integrated with sub-stepped Euler. Particles initialize as a small Gaussian cluster around the system's natural seed point; over time they trace out the attractor's signature shape.
| System | Equations | Bounds |
|---|---|---|
| Lorenz (1963) | ẋ = σ(y−x), ẏ = x(ρ−z) − y, ż = xy − βz(σ=10, ρ=28, β=8/3) |
x∈[−22,22], y∈[−30,30], z∈[0,55] |
| Aizawa (1985) | ẋ = (z−b)x − dy, ẏ = dx + (z−b)yż = c + az − z³⁄3 − (x²+y²)(1+ez) + fzx³(a=0.95, b=0.7, c=0.6, d=3.5, e=0.25, f=0.1) |
x,y,z ∈ [−1.5, 1.5] |
| Thomas (1999) | ẋ = sin(y) − bx, ẏ = sin(z) − by, ż = sin(x) − bz(b ≈ 0.208186) |
x,y,z ∈ [−4, 4] |
| Halvorsen | ẋ = −ax − 4y − 4z − y², ẏ = −ay − 4z − 4x − z², ż = −az − 4x − 4y − x²(a = 1.4) |
x,y,z ∈ [−8, 8] |
Each attractor's natural bounds are mapped onto the world cube via:
worldi = ((si − loi) / (hii − loi) − 0.5) · 2 · halfSpread
An axis-permutation map reorders attractor (x, y, z) → world (x, y, z) per system; Lorenz uses [0, 2, 1] so its butterfly's "wing axis" lies in the camera plane by default. Each system also carries a timeScale multiplier (Lorenz=14, Aizawa=80, Thomas=40, Halvorsen=30) tuned so the visible motion runs at roughly the same perceptual speed across systems.
3. Confinement shapes
A confinement shape is a 1D skeleton in 3-space — a curve. A spring force pulls particles back toward the nearest point on the skeleton when they wander past a tube radius:
F = strength · 10 · max(0, |particle − nearestPoint| − thickness) · normalize(particle − nearestPoint)
Spawning new particles places them uniformly inside the tube volume so the shape is recognizable from the very first frame.
- Torus — major circle of radius
Rin the XZ plane. Nearest point is the projection of(x, 0, z)onto the circle. - N-Tube — regular polygon with
Nsides (3–12),Rcircumradius. Nearest point is found by scanning allNedges. - Galaxy —
Nlogarithmic spiral arms over a disc of radiusR. Each arm's angle at radiusris2πk/N + (r/R)·π; the wind term gives the spiral its sweep. - Merkaba — a star tetrahedron: two regular tetrahedra inscribed in a sphere of radius
R, the second rotated 60° around Y. Twelve edges total. Nearest point is found by scanning all edges.
4. Repulsor
Optional. A point in the XY plane that pushes particles outward with an inverse-square falloff:
push = min(strength · speed · 0.35 / (sd + 0.08)², 0.5), sd = max(distance, 0.15)
The cap at 0.5 prevents particles close to the repulsor from getting yeeted off-screen. The negative_space preset uses this to carve a visible empty region in the center of an otherwise dense field.
5. Color
Each particle carries a permanent palette position cpos ∈ [0, 1]. The displayed color is sampled from the active palette at (cpos + colorPhase) mod 1, then optionally tinted by a per-channel multiplier (warm, cool, sepia, cyan, magenta, amber).
Twenty-two palettes ship: infrared, nebula, aurora, plasma, fire, ocean, cosmic, sakura, silver, supernova, chlorophyll, amber_glow, ice, void, biolum, crimson, toxic, ember_glow, neon_city, starlight, deep_rose, aurora2.
Final pixels are composited additively. A small fraction of particles (hotSpotPct) are size-multiplied 1.8–3.0×; these are the "hot" pixels whose additive stacking creates the bright halos.
6. Bloom + vignette
The renderer runs in HDR — particles can stack to RGB values above 1.0. The post-pipeline (SCNCamera's built-in HDR + bloom) extracts pixels above bloomThreshold, blurs them, and adds them back to the frame at bloomIntensity weight. Vignette darkens screen edges by vignetteIntensity.
The transparent-background snapshot disables HDR/bloom/vignette so the alpha channel comes through cleanly — useful for layering the field under typography in graphic design work.
7. Reproducibility
Every scene is encoded as a 31-key JSON recipe (~1 KB). Two devices loading the same recipe with the same seed render bit-for-bit identical particle trajectories. The recipe schema is shared between the iOS app and the web etherics3d.html version; share a recipe via the share sheet and it'll open in either.
8. References
- Lorenz, E. N. "Deterministic Nonperiodic Flow." Journal of the Atmospheric Sciences, 20 (1963).
- Aizawa, Y. "Strange attractors and bifurcations of dissipative dynamical systems." Soviet J. Plasma Phys. 11(8), 1985.
- Thomas, R. "Deterministic chaos seen in terms of feedback circuits." Int. J. Bifurcation and Chaos, 9 (1999).
- Bridson, R., Houriham, J., Nordenstam, M. "Curl-noise for procedural fluid flow." ACM SIGGRAPH, 2007.
- Halvorsen, E. "A simple three-dimensional dissipative chaotic system." (1995). Cataloged in J. C. Sprott, Elegant Chaos, 2010.
- Apple SceneKit + Core Image bloom + HDR ACES tone mapping pipeline.