The Falling Sand Lab — 16 Elements, GPU Cellular Automaton, Endless Toy
A grid of pixels. Drop sand, water, fire, oil, gunpowder, plants, lava, acid. They interact via real cellular-automaton rules on the GPU. Burn the plants. Quench fire with water. Detonate gunpowder.
What this is
A digital sandbox with 16 elements: void, sand, water, oil, fire, smoke, steam, lava, stone, wood, plant, seed, gunpowder, acid, ice, gas. The entire 512×512 simulation lives in a single RGBA8 texture (R=element, G=temperature, B=lifetime, A=nonce) and updates every frame via a fragment shader that runs the cellular automaton rules in parallel. Mouse paints the selected element with adjustable brush size. Burn plants with fire. Quench fire with water. Detonate gunpowder. Acid dissolves most solids over time. Plants grow into adjacent empty cells when wet.
Why this is mind-blowing
This is the digital equivalent of a sandbox you can never bore of. The whole simulation is one fragment shader. 16 elements. Dozens of reactions. Endless emergent behavior. The model knows every Powder Toy pattern you ever wanted in one paragraph of prompt.
Build a single-file falling-sand simulator in WebGL2. 1024×1024 grid
stored as a single texture, ping-pong updated each frame via fragment-
shader cellular automaton rules. 16 elements: sand, water, oil, fire,
smoke, steam, lava, stone, wood, plant, seed, gunpowder, acid, ice,
gas, void. Each has falling rules, density, and reactions (water + lava
→ stone + steam; fire + plant → fire + smoke; gunpowder + heat →
explosion). Mouse paints the selected element.
Paste this into Claude, Cursor, or Copilot. Change one thing that matters to you.
What I learned shipping it
- Pack everything into RGBA8: R=element ID, G=temperature, B=lifetime, A=nonce. One texture, one ping-pong pass, sixteen behaviors. The byte budget is the constraint that forces clarity.
- GPU cellular automata require symmetric handshakes — both source and destination cells independently compute the same swap predicate. Solo CPU intuition doesn't transfer.
- Reactions like water+lava→stone+steam are why this is a SIMULATION, not an art toy. Each reaction adds an order-of-magnitude more emergent behavior. 16 elements is the sweet spot.