3D Margolus 2×2×2 Block Cellular Automata
Partition a 3D voxel grid into disjoint 2×2×2 blocks whose origin shifts each substep, letting GPU threads update all blocks in place in parallel while strictly conserving voxel count and avoiding write conflicts.
Also known as Margolus neighborhood CA, partitioning cellular automata, 3D block cellular automata, mass-conserving voxel falling sand
In the family Simulation & animation, voxel cellular automata
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | No built-in 3D Margolus block cellular automata compute pipeline. |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | |
| Unity | None found | No built-in 3D Margolus 2x2x2 block cellular automata simulation framework. |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Ordinary cellular automata update one cell at a time by reading neighbors, which makes mass-conserving transport (such as falling sand, rubble, or granular collapse) hard to parallelize on GPUs: two grains can simultaneously try to move into the same empty voxel, causing race conditions or lost matter.
The Margolus partitioning scheme eliminates write hazards by decomposing the 3D lattice into non-overlapping 2× 2× 2 blocks. On each step, a single GPU thread owns one 8-voxel block, reads all eight cells, applies a local mass-conserving permutation rule (such as letting sediment drop vertically into empty lower cells, slide diagonally off slopes, or erode when exposed to wind or water jets), and writes all eight voxels back in place with zero atomics and zero double-buffering.
To allow matter to travel across block boundaries, the grid partition origin shifts between steps across offsets (ox, oy, oz) ∈ {0, 1}3 (cycling or randomizing parity to prevent directional bias). Because every local rule only permutes states within a disjoint 2× 2× 2 cube, total particle mass is conserved by construction while achieving full hardware parallelism across millions of voxels.
When to choose it
Reach for it when
- falling sand or granular voxel sim loses or duplicates particles on gpu
- need race-free parallel 3d cellular automata without atomic locks
- simulate mass-conserving 3d sand piles water percolation and avalanches
- update colliding voxel neighbors cleanly in alternating 2x2x2 blocks
- build a fast real-time 3d falling-sand sandbox in compute shaders
Choose it for real-time 3D granular sand, sandstone erosion, rubble avalanches, or interactive destructible voxel sandboxes where strict mass conservation and race-free GPU compute performance matter.
Prefer GPU Pipe-Model Hydraulic Erosion or Shallow Water Equations (Height-field Water) for flowing water with hydrostatic pressure (Margolus voxel water lacks pressure gradients and creeps slowly without forming streams). Prefer Material Point Method (snow) or Smoothed Particle Hydrodynamics (fluids) for smooth continuum deformation and free-flowing liquids. Prefer Cellular automata cave generation when generating static procedural caverns without conservation laws.
Field marks
- No long-range hydrostatic pressure or momentum transmission: bulk liquids creep at most one voxel per step and pile up instead of rushing downhill
- Regular parity cycling can create subtle diagonal bias or checkerboarding unless block shift orders are randomized or well-balanced
- Maximum transport speed is bounded by one voxel per substep, requiring multiple substeps per frame for fast-falling debris
- Fixed-resolution dense 3D voxel buffers scale cubically in memory with world extent
Crosses
- Overhang-capable voxel erosion with pipe-model water: Interactive hydraulic erosion that carves real 3D caves, undercut banks, and collapsing arches instead of flat 2.5D heightfields. A fast pipe-model water solver drives surface runoff and scouring, a mass-conserving 3D Margolus cellular automaton moves loosened sand and rock voxels through overhangs, and exact DDA ray traversal renders the evolving volume with zero remeshing.
- Voxel grid DDA ray traversal (Amanatides–Woo): Direct 3D DDA ray traversal renders the live voxel storage buffer immediately after each Margolus step without remeshing.
- GPU Pipe-Model Hydraulic Erosion: Virtual-pipe surface water cuts into solid rock voxels and feeds loosened sediment directly into the Margolus falling-block pass.
Sources
- primaryNorman Margolus (1984). Physics-like models of computation. Physica D: Nonlinear Phenomena.Verified via doi.org · 2026-11-30doi:10.1016/0167-2789(84)90252-5
- primaryTommaso Toffoli, Norman Margolus (1987). Cellular Automata Machines. The MIT Press.Verified via crossref · 2026-11-30doi:10.7551/mitpress/1763.001.0001