Visualizations
011 / 500

011 · Astronomy

Planet

A procedurally generated world with oceans, clouds and a glowing atmosphere.

Each world is baked once into maps of longitude and latitude: domain-warped 3D fractal noise on the sphere gives height, and height, latitude and moisture pick the biome, from ocean depths and beaches to forests, deserts and snowy peaks. Every pixel of the disk is then mapped back to the sphere, with everything that does not change as it spins precomputed, so a frame is just texture lookups and lighting. Clouds drift and cast shadows, oceans glint, cities glow on the night side and the atmosphere scatters light at the rim. Worlds range from temperate to lava, ice and ringed gas giants.

Try it. Drag to spin and tilt the planet. Click for a new world, or leave it alone and it travels to the next one.

  • Sphere mapping
  • Fractal noise
  • Per-pixel lighting

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 procedurally generated planet 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 over a dark starfield, stays sharp on high-DPI screens, and resizes with the window.
- Write a small 3D Perlin noise function yourself, plus a fractal (fbm) helper summing 5 or 6 octaves.
- Bake the planet once into an equirectangular texture (for example 512 x 256): for each texel, turn its longitude and latitude into a point on the unit sphere, read fbm noise there as height, and pick a color by height: deep and shallow ocean, beach, grass, forest, rock, snow. Use latitude so the poles freeze.
- Render the planet into a small offscreen ImageData each frame. For every pixel inside the disk, compute the sphere point (x, y, z = sqrt(1 - x² - y²)), convert it to longitude and latitude, add a rotation offset to the longitude, and look up the texture. Light it with a dot product against a fixed sun direction. Scale it up with drawImage.

Once that works, make it beautiful:
- Precompute everything about each pixel that does not change as the planet spins (its longitude, latitude and sun angle), so spinning is just a texture offset.
- Add a cloud layer from a second noise texture that drifts faster than the ground, and darken the ground under it as a cloud shadow.
- Give the oceans a specular glint, put warm city lights on the night side of the land, and add an atmosphere: a bluish haze toward the limb and a glowing rim just outside the disk.
- Click for a new seed, and drag to spin it.

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 other kinds of worlds (desert, ice, lava, gas giant), planetary rings with shadows, or an orbiting moon.
PreviousBloomProcedural flowers open from bud to bloom, with ruffled, translucent, veined petals. NextVoxel DioramaA floating voxel island with baked AO, sun shadows and a waterfall. Click to build.

Related visualizations

  • Map ProjectionsMath One procedural planet morphing through a dozen map projections, Tissot ellipses and all.
  • Tiny Planet3D A ray traced village panorama that curls into a tiny planet, a fisheye or a camera view.
  • Gas Giant WeatherFluids Real 2D fluid dynamics paints turbulent belts, festoons and oval storms on a gas giant.
  • Planet ForgeAstronomy A dusty disk grows rocky worlds, ice giants and gas giants by N-body accretion.
  • Invented AtlasGenerative art A parchment map of a world that never was, with rivers, realms and its own language.
  • Volumetric CloudsNature Raymarched cumulus with silver linings, light shafts and drifting shadows.
  • ErosionNature Raindrops carve rivers and valleys into a mountain range.
  • Procedural CityGenerative art An isometric city that builds itself and runs through day and night.
  • Solar SurfaceAstronomy Granulation, sunspots and flaring magnetic loops at the Sun's limb, in three wavelengths.

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

← More from Emergent Mind Labs