Visualizations
003 / 500

003 · Nature

Aurora

Curtains of oxygen and nitrogen light on tilted field lines, mirrored in a lake.

Each curtain is a sheet of magnetic field lines standing on a folded footprint that runs east to west, rippled by kinks traveling along the arc. Every ray climbs its field line at the 78 degree magnetic dip, over a curved Earth, so distant curtains sink toward the horizon and overhead ones stream down from the zenith. Color comes from altitude: oxygen's green line glows from about 100 to 150 km with a sharp lower edge, its slow red line survives only above 200 km, and in strong storms harder electrons reach 90 km and fringe the bottom with nitrogen pink. Rays deposit their emission into a floating point buffer, which is blurred for glow, auto exposed and mirrored row by row into the lake through the camera's projection.

Try it. Use the storm slider (or the up and down arrow keys) to go from a quiet arc on the horizon to a severe storm overhead. Click the sky to set off a substorm surge there, or press space. Drag or use the left and right arrow keys to look around, and press F (or the button) to show field lines with electrons spiraling down them. R resets.

  • Additive ray splatting
  • Emission by altitude
  • Auto exposure
  • Planar reflection

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 aurora borealis scene 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. Paint a night sky gradient (near black overhead, deep blue-green near the horizon) with a few hundred stars, and a dark treeline silhouette across the lower third.
- Model one aurora curtain in 3D: a footprint that runs from west to east about 300 km north of the viewer, wiggled by a few sine waves, at about 100 km altitude. The curtain is made of vertical rays rising from that footprint up to about 300 km.
- Project points with a simple perspective camera standing on the ground and looking north, tilted slightly up.
- For each ray, step up in altitude and color each step by height: green (oxygen at 557.7 nm) strongest from 100 to 150 km with a sharp bottom edge, fading to red (oxygen at 630 nm) above 200 km.
- Draw the rays as thin lines with globalCompositeOperation = "lighter" so overlapping light adds up and glows.

Once that works, make it beautiful:
- Render the rays into a small offscreen canvas, blur a copy for glow, and draw both scaled up.
- Vary brightness along the curtain with drifting noise and fine streaks, and animate the wiggles so folds travel along it.
- Mirror the sky in a still lake under the treeline, darkened and gently rippled.
- Add a storm slider that brings the curtain closer and brighter and adds a pink nitrogen fringe at the bottom.

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 tilting the rays along the magnetic field so overhead curtains form a corona, several layered curtains, or click-triggered substorm brightenings.
PreviousTiny PlanetA ray traced village panorama that curls into a tiny planet, a fisheye or a camera view. NextRoman MosaicThousands of tesserae laid in rows that follow every outline, as a Roman mosaicist would.

Related visualizations

  • MiragePhysics Bent light over hot asphalt and cold sea: road puddles, floating cars, Fata Morgana.
  • Magnetic BottlePhysics Particles gyrate, bounce and drift in Earth's dipole, filling the radiation belts.
  • Rainbow OpticsPhysics A double rainbow, dark band and fogbow computed from Snell's law and wave optics.
  • Volumetric CloudsNature Raymarched cumulus with silver linings, light shafts and drifting shadows.
  • Solar SurfaceAstronomy Granulation, sunspots and flaring magnetic loops at the Sun's limb, in three wavelengths.
  • Sky MachinePhysics Drag the sun and watch real Rayleigh and Mie scattering paint the sky.
  • Discharge TubesPhysics Glowing gas tubes whose colors are computed from their real spectral lines.
  • Star TrailsAstronomy A long exposure builds over a mountain camp as the sky wheels around the celestial pole.
  • Ice Crystal HalosPhysics Sundogs, arcs and halos built up live from millions of rays traced through ice.

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

← More from Emergent Mind Labs