Visualizations
422 / 500

422 · Physics

Snow and Slush

Snowballs, jelly, sand and water smash and tumble down a slope, simulated with MLS-MPM.

Every body is thousands of material points simulated with MLS-MPM, the Material Point Method family behind film-grade snow: each step the particles scatter mass, momentum and stress onto a background grid with quadratic B-spline weights, the grid adds gravity and collides with the terrain, and the particles read back their velocity and a local affine velocity field that updates their deformation gradient. What a material is lives entirely in how that deformation becomes stress, using closed-form 2x2 singular value decompositions: jelly is pure corotated elasticity, snow clamps its singular values and hardens as it is compressed (Stomakhin et al. 2013) so it packs, cracks and crumbles, sand uses Drucker-Prager plasticity with volume correction so it pours and piles at an angle of repose, and water keeps only pressure. Snow, jelly and water are drawn as a density field shaded from its own gradient, sand as individual grains, and the particle budget adapts to hold the frame rate by melting away the oldest bodies.

Try it. Click to drop a ball of the current material, drag to fling whatever is under the pointer, and press 1 to 4 (or Tab, or the chips) to switch between snow, sand, jelly and water. Space throws a pair at each other and R clears the slope. Left alone, it stages mid-air collisions of every pairing.

  • MLS-MPM
  • Snow plasticity
  • Drucker-Prager sand
  • Closed-form 2x2 SVD
  • Density field shading
  • Adaptive particle budget

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a 2D snow simulation with the Material Point Method (MLS-MPM), with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window. Simulate in a unit square shown as large as fits.
- Use a 64 by 64 background grid and about 3,000 particles in three blocks. Each particle stores a position, velocity, a 2x2 affine velocity matrix C, a 2x2 deformation gradient F, and a plastic volume ratio Jp.
- Each step, follow the classic mpm88 and mpm99 structure: scatter particle mass and momentum (plus the stress term) to the 3x3 nearby grid nodes with quadratic B-spline weights; turn grid momentum into velocity, add gravity and stop velocities into the walls; then gather velocities and C back to the particles, update F and move them.
- Give the stress by fixed corotated elasticity, 2 mu (F - R) F^T + lambda J (J - 1) I, where R is the rotation part of F.
- Run about 20 steps of dt = 1e-4 per frame and draw particles as 2 pixel squares.

Once that works, make it beautiful:
- Make it snow: compute the 2x2 SVD of F, clamp the singular values to [1 - 0.025, 1 + 0.0045], store the excess in Jp, and scale mu and lambda by exp(10 (1 - Jp)) so packed snow hardens.
- Add jelly (pure elasticity) and water (no shear stiffness, F reset to a pure dilation each step) and switch materials with the number keys.
- Let a click drop a new ball of the current material and a drag push the grid nodes near the mouse along with it.
- Color snow white, water blue and jelly pink, and add a sloped ground to tumble down.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as Drucker-Prager sand, rendering a smooth density field instead of dots, or adapting the particle count to hold the frame rate.
PreviousBPE TokenizerByte pair encoding learns a vocabulary live, fusing typeset tiles merge by merge. NextLatent Face AtlasA VAE learns cartoon faces in seconds and lays out its latent space as a map of faces.

Related visualizations

  • SPH WaterFluids Thousands of particles that slosh, splash and pour like a liquid.
  • Falling SandSimulation Sand, water, fire, lava and plants that all react with each other.
  • JellyPhysics Squishy soft bodies that wobble, bounce and squash into each other.
  • Glowing SurfFluids Moonlit waves break on a beach and the plankton in them flash electric blue.
  • Drying MudSimulation Wet clay dries and cracks into a lakebed of curling plates, primaries first.
  • Magnetic BottlePhysics Particles gyrate, bounce and drift in Earth's dipole, filling the radiation belts.
  • ImpactPhysics A grain-by-grain slice of layered regolith as impactors dig craters, in slow motion.
  • Ball PitPhysics Hundreds of colorful balls tumble, stack and bounce off each other.
  • Snowflake GrowthNature Steer the weather on a Nakaya diagram and grow one-of-a-kind snowflakes.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs