Visualizations
410 / 500

410 · Nature

Volumetric Clouds

Raymarched cumulus with silver linings, light shafts and drifting shadows.

Each pixel's view ray marches through a layer of cloud built from tileable 3D noise: value noise blended with Worley cells into billowy shapes, cut by a coverage map and a height profile, then eroded by finer Worley noise so bases go wispy and tops go cauliflower. At every step inside a cloud, five growing steps toward the sun measure how much cloud is in the way (Beer-Lambert), and a two-lobe Henyey-Greenstein phase, a sum of three ever softer scattering octaves standing in for multiple scattering, and a powder term shape the light. The camera stands still, so each frame marches one pixel in every 3x3 block and reprojects the rest along the wind using each pixel's cloud depth. Light shafts come from a radial blur of the sun's visibility, and cloud shadows sweep across the fields below a lone acacia.

Try it. Drag the sky to move the sun (try putting it just behind a cloud). Use the sliders to go from fair weather to a lightning storm and to change the wind. Arrow keys nudge the sun, and R resets.

  • Volumetric raymarching
  • Henyey-Greenstein phase function
  • Temporal reprojection
  • Screen-space light shafts

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 volumetric cloud renderer 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. Render into a small offscreen canvas (about 160 by 100 pixels) with ImageData, then drawImage it scaled up with smoothing on.
- Write a small 3D value noise function and sum three octaves of it (fbm).
- Put the camera on the ground looking slightly up. For each pixel, intersect the view ray with a flat cloud layer between 1.5 and 3.5 km, and march about 32 steps through it.
- Cloud density at a point is fbm(point) minus a coverage threshold, clamped at zero, and faded out near the top and bottom of the layer.
- Accumulate with Beer-Lambert: at each step, transmittance *= exp(-density * stepLength * sigma), and add the light at that point times the amount absorbed. Stop early when transmittance is nearly zero.
- For the light, take four short steps toward the sun, sum the density, and use exp(-sum) as the sunlight that reaches the point, plus a little blue sky light.
- Blend the cloud color over a simple sky gradient.

Once that works, make it beautiful:
- Multiply the sunlight by a Henyey-Greenstein phase function (g around 0.7) so clouds near the sun get bright silver linings.
- Precompute the noise into a small tileable 3D array and sample it with trilinear interpolation so it runs fast enough to raise the resolution.
- Let the pointer drag the sun, warm its color as it gets low, and slide the noise with time so the clouds drift.
- Add a coverage slider that goes from a few puffs to a heavy sky.

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 Worley noise for puffier shapes, cloud shadows on the ground, or light shafts.
PreviousChromaticity LabDraw any light's spectrum and watch it land on the CIE 1931 horseshoe. NextFoveated VisionWhat one eye really captures: a sharp fovea, a blurry gray periphery and a blind spot.

Related visualizations

  • Kelvin-Helmholtz BillowsFluids A sunset sky where sliding air layers roll a cloud deck into breaking-wave billows.
  • Mountain Wave CloudsSimulation Wind over a range rings into lee waves, and saucer clouds stack at the crests.
  • MandelbulbFractals A 3D fractal, ray marched pixel by pixel on the CPU.
  • Sky MachinePhysics Drag the sun and watch real Rayleigh and Mie scattering paint the sky.
  • PlanetAstronomy A procedurally generated world with oceans, clouds and a glowing atmosphere.
  • Light & ShadowPhysics Red, green and blue lights cast crisp, colored shadows through spinning shapes.
  • Voxel Diorama3D A floating voxel island with baked AO, sun shadows and a waterfall. Click to build.
  • MiragePhysics Bent light over hot asphalt and cold sea: road puddles, floating cars, Fata Morgana.
  • Forest of LightNature Trees grow by competing for light in a watercolor forest that turns with the seasons.

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

← More from Emergent Mind Labs