Visualizations
015 / 500

015 · Physics

Kelp Forest

Buoyant kelp sways in an ocean surge under god rays and live caustics.

Every frond of giant kelp is a buoyant elastic rod: a chain of Verlet nodes anchored by a holdfast, held up by the gas bladders at the base of each blade, with distance and bending constraints and water drag toward the local current. The current is an oscillating surge that is strongest near the surface and travels across the forest, plus noise turbulence, so fronds lean, curl and lay their tops along the surface as canopy while each blade streams with the flow behind it. The caustic web on the sand is computed every frame by refracting a grid of sunlight rays through an analytic wave surface and counting where they land, and the god rays flicker with the same waves. A school of fish follows boids rules and steers around the stipes.

Try it. Drag through the water to push a current through the forest. Tap to drop a pebble: it splashes, sinks and sends a pressure pulse through the kelp when it hits the sand.

  • Buoyant Verlet rods
  • Caustics by ray refraction and splatting
  • Boids
  • Layered depth haze

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 an underwater kelp forest 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. Fill it with a vertical gradient from bright teal at the top to deep blue at the bottom, with a strip of sand along the floor.
- Each kelp frond is a chain of about 25 points using Verlet integration (velocity is the current position minus the previous one). Pin the first point to the sea floor and join neighbors with distance constraints, relaxed a few times per frame.
- Instead of gravity, give every point a small upward buoyancy force, so the chain stands up. Stop points at the water surface so the tops float along it.
- Add a water current: a horizontal velocity that oscillates slowly with a sine of time, stronger near the surface. Each frame, nudge every point's velocity a little toward the water velocity (drag).
- Draw each frond as a smooth curve, with narrow leaf-shaped blades along it that point along the current.

Then make it beautiful:
- Use three depth layers of fronds, smaller and more blue-tinted the further away they are.
- Add slanted, softly fading light shafts from the surface with additive blending, and drifting specks of marine snow that move with the current.
- Add caustics on the sand: compute a wave height function, refract a grid of light rays through its slope, and count where they land on a small offscreen canvas. Draw it stretched over the sand with "lighter" blending.
- Let the mouse drag push the water, adding a short-lived jet to the current.

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 a school of fish with boids steering, pebbles that send pressure pulses through the forest, or a day and night cycle with bioluminescence.
PreviousTotalityA total solar eclipse from a lakeshore, driven by the real shadow geometry. NextMandelbulbA 3D fractal, ray marched pixel by pixel on the CPU.

Related visualizations

  • Pool CausticsPhysics Sunlight bent by a rippling pool surface draws a living net of light on the tiles.
  • SOFAR ChannelPhysics Sound rays bend into the ocean's deep channel, lighting up caustics and shadow zones.
  • Glowing SurfFluids Moonlit waves break on a beach and the plankton in them flash electric blue.
  • Ocean3D Rolling waves at sunset, built from layered Gerstner waves.
  • Rainbow OpticsPhysics A double rainbow, dark band and fogbow computed from Snell's law and wave optics.
  • Plankton BloomFluids Eddies stir green diatom and turquoise coccolith blooms, like ocean-color imagery.
  • MiragePhysics Bent light over hot asphalt and cold sea: road puddles, floating cars, Fata Morgana.
  • Water RipplesFluids Raindrops on a koi pond, with ripples that bend the scene below.
  • Faraday WavesFluids A shaken dish of liquid locks into stripes, squares, hexagons and a 12-fold quasicrystal.

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

← More from Emergent Mind Labs