Falling SandBeta
Pour sand, water, fire and lava and watch them react
This tool is a beta version still being stabilized. Please let us know if a result looks off.
Pick a material and drag on the canvas to pour it (right button = eraser). Sand piles up, water and oil flow and spread, and oil floats on water. Fire burns wood, oil and plants and turns to steam when it touches water. Lava hardens into stone when it meets water, and plants grow by drinking water. Steam cools and falls back down as rain. Ice melts near fire and slowly freezes water it touches, while snow drifts down and piles up. Acid dissolves anything but walls, gunpowder explodes when fire reaches it, and the cloner endlessly copies the first material that touches it. Seeds grow into trees once they land, fireworks shoot up and burst, gas flares up the moment fire touches it, and the black hole swallows everything. Tools: build walls with Line and Box, blow things up with the Bomb, or strike with Lightning. Set the resolution to "Extreme" to play with millions of particles.
Working…
0.0
It hasn't frozen — the result will appear when the calculation finishes.
About Falling Sand
A falling-sand game is a cellular automaton in which every grid cell holds exactly one element. On each step this tool updates the cells row by row from the bottom up, choosing at random for each row whether to sweep left-to-right or right-to-left, and it never touches a particle twice in the same step. All motion comes down to one operation — swap places with a neighbouring cell — and whether a swap is allowed is decided by density.
So the physics here is rules, not Newton's laws. The angle a sand pile settles at, how fast water spreads, and why oil floats all fall out of a few lines of code and a handful of numbers. What follows spells out those rules and where they part ways with real physics.
One grain's rule, and the 45° pile
Sand, gravel and gunpowder try to move straight down each step. If that cell is blocked, they try down-left or down-right, picking which to try first at random. If both are blocked, they stay put. There is no sideways slide.
That rule alone fixes the slope. A grain only comes to rest when the cell below and both diagonals below are full, so sand poured on one spot forms a triangle that widens by one cell on each side per row — a 45° pile. A triangle h rows high holds 1 + 3 + 5 + … + (2h − 1) = h² cells, so 400 cells of sand poured in one place stand about 20 rows tall. Real dry sand collapses at a gentler slope that depends on friction and grain shape. The fixed 45° here is a property of a grid whose neighbours stop at the diagonals.
Falling speed comes from the rules too. A particle moves at most one cell per step, so it never accelerates no matter how far it falls. In real free fall, speed grows in proportion to time.
Layers from a density ranking
A moving particle can only enter a cell holding something less dense. The ranking in this tool is gravel 10 > sand 9 > gunpowder and seeds 8 > lava 7 > snow 6 > water and acid 5 > oil 4 > smoke, steam, fire and gas 1 > empty 0. Pour sand into water and it swaps its way to the bottom; put oil beneath water and it climbs one cell at a time until it floats on top.
That works well for liquids but not for mixtures of grains. Mix gravel and sand here and the gravel sinks through the sand to the floor. Real granular mixtures that are shaken often do the opposite, with large particles rising to the top — the “Brazil nut effect”, whose mechanism Rosato and colleagues analysed with simulations in 1987. Separation driven by size and shaking cannot come from a simple density comparison.
Water here has no pressure
When water cannot move down, it flows up to four cells sideways in a single step; oil flows up to two. That difference is why oil spreads more slowly than water — a stand-in for viscosity.
What water cannot do is move up. Build a U-tube and fill only one arm, and the levels never even out, unlike real water. In reality the pressure at the bottom pushes water up the other side, but each water particle here only looks at its immediate neighbours. Fountains and siphons fail for the same reason. Commercial games work around this by layering separate pressure calculations or rigid-body physics on top of the particle rules; Petri Purho's GDC 2019 talk on Noita, a game built entirely on falling-sand simulation, describes how those layers were combined.
A few reaction rules
Fire checks the four cells above, below, left and right each step. Per-step ignition odds are 0.6 for gas, 0.15 for oil and 0.05 for wood, plants and seeds. Fire on wood lasts 90 to 150 steps, which is why gas flashes and vanishes while a wood pile smoulders for a long time.
Fire touching water turns the water to steam and goes out. Lava touching water becomes stone (gravel) and turns the water to steam. Steam rises, and when its lifetime runs out it has a 30% chance of becoming a water droplet that falls again — the whole rain cycle comes from that one line. Gunpowder touched by fire or lava blows out a radius of six cells.
- Open floor: moving particles in the bottom row drain away, handy for waterfalls that keep flowing.
- Cloner: it keeps producing the first element that touched it, so a water cloner next to a lava cloner makes stone endlessly.
- “Extreme” resolution: smaller cells push the particle count into the millions. The rules do not change, so piles still stand at 45°.
Worked examples
Height of a sand pile poured in one spot
- Input
400 cells of sand poured onto one point of the floor- Output
A 45° triangle about 39 cells wide and 20 rows tall
A triangle of height h holds h² cells (1 + 3 + … + 39 = 400). The brush paints sand at 50% density, so brush size is not the same as cell count, but the settled shape always follows this ratio.
Pouring water and oil into the same tank
- Input
A 20-cell-wide tank, equal amounts of water and oil- Output
Oil ends on top and water below; the water surface flattens faster
Density 5 > 4 separates the layers, and sideways reach per step (water 4 cells, oil 2) makes water level out roughly twice as fast.
The U-tube test
- Input
Build a U-tube from wall and fill only one arm with water- Output
Even once the bottom channel is full, the level in the other arm does not rise
There is no upward-move rule, so pressure is not transmitted. Communicating vessels reaching the same level is the biggest way this tool's water differs from the real thing.
How to use it
- Pick an element from the palette and drag on the canvas to pour it (right button erases).
- Use Line and Box to build walls or containers first.
- Add fire, lava or gunpowder to watch reactions, or shake things up with the Bomb or Lightning.
Frequently asked questions
Why do sand piles always settle at the same angle?
A sand particle only considers the cell below and the two diagonals below, which fixes the slope at 45°. Real sand's angle of repose depends on grain size, shape and moisture; this rule has none of those variables.
Why don't the water levels even out?
Water here moves only sideways and down, and no pressure is calculated. Anything that relies on pressure lifting water, such as a U-tube or siphon, is not reproduced.
Why update one row at a time from the bottom?
Updating from the top lets the same particle fall several times in one step. Going bottom-up and marking particles that have already moved means each particle moves once per step. Randomising the left–right sweep for each row stops sand and water from drifting to one side.
Does a higher resolution make it more realistic?
More particles make shapes smoother, but the rules are identical, so the 45° slope and lack of pressure remain. Each cell is also smaller, so particles cover less screen distance in the same number of steps.
Sources
- Petri Purho (Nolla Games), Exploring the Tech and Design of Noita, GDC 2019
- A. Rosato, K. J. Strandburg, F. Prinz, R. H. Swendsen, Why the Brazil nuts are on top, Phys. Rev. Lett. 58, 1038 (1987)
Last reviewed: