Feature Library

Procedural planets from a seed

3.47 GPU · 0.20 CPU ms
A still of the Procedural planets from a seed demo
Still
The live demo starts when it’s in view.Drag the planet to turn and tip it (or arrow keys) · pick a nearby seed below · type a seed or roll one

A whole planet from one number: a seed picks the kind (temperate, ocean, desert, ice, lava, gas giant or barren moon), its palette, its axis, and how much sea…

What it costs a frame

3.47 ms
0.20 ms
GPU
3.47 ms
CPU, median
0.20 ms
CPU, 95th pct
0.33 ms
Draw calls
0
Weight
Heavy

Measured 13 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 2.20–4.73, CPU 0.17–0.20 ms). What ran: Measured with the hero turning (body, rings and halo) and six small planets beside it, all in one canvas with three instanced draws, timed by their own timestamp queries. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool3.470.200.33
apple · Apple A19 Proin a browser tab · 16 November 202616.30.040.20
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20261.110.350.58

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPUNeeds WebGPU: current Chrome and Edge, Safari 26+, Firefox 141+ on Windows.
Your browser
Checking…Looking for WebGPU
Depends on
NothingNo other packages

What it’s for

  1. A world for each user, project or save file, the same every time from its id
  2. A planet picker or a galaxy map in a game menu
  3. A hero image or a loading screen that is never the same twice
  4. Icons and avatars drawn from a seed, at any size
  5. Teaching what makes a planet look the way it does: sea level, air, ice, rings

Pitfalls, in brief

  1. The coast is a quantile, not a constant: seaLevelFor() samples the continents at 1,536 points and takes the height under which the asked share lies.
  2. The continents use fixed octaves on both sides (5 for the base, 4 for the ridges): that is what makes the CPU’s coast the GPU’s coast.
  3. dpdx and dpdy need uniform control flow in WGSL: the body shader works out the height for every pixel (outside the rim from the rim’s own point), merges every branch, and only then takes the derivatives.
  4. A ring point that falls on the disc is in front of the body when its depth is positive, and behind it otherwise: the ring lies outside the unit sphere, so it can never be between the visible surface and the centre.
  5. Keep lean (the axis tipped toward you) away from zero: the ring plane is then seen edge-on and its depth divides by sin(lean).
7 more in brief
  1. The noise lattice is offset by the seed (up to about 1,000 cells).
  2. The hash takes integer lattice points through bitcast<vec3u>(vec3i(floor(p))) in WGSL and Math.imul in TypeScript: both wrap negatives as two’s complement, so the two sides agree.
  3. The canvas is not sRGB: colours are kept linear in the spec and encoded at the end of the shader.
  4. draw() returns false while the last frame is still on the GPU: keep it dirty and draw again next frame, or a change is lost.
  5. A device can be lost while the page is open (a driver reset, a laptop waking): draw() then returns false for good.
  6. seedOf() reads any u32 written in digits (up to 4294967295) as that number, so a seed shown as a number gives the same planet when it is typed back.
  7. The Canvas 2D still costs about 40 ms for a 120 px radius (all on the main thread): paint it after a change settles, never per frame.
12 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Fully custom code.

Mark Jarzynski & Marc Olano, Hash Functions for GPU Rendering (JCGT, 2020): PCG3D, the integer hash under every lattice point, in WGSL and in TypeScript.

Ken Perlin, Improving Noise (SIGGRAPH 2002): The quintic fade 6t⁵ − 15t⁴ + 10t³ the value noise interpolates with.

Inigo Quilez, Domain warping: The idea of bending the noise’s input by more noise, behind the coasts and the bands (written here in our own way).

Álvaro González, Fibonacci lattice on the sphere (Mathematical Geosciences, 2010): The evenly spread samples the sea level is worked out from.

planetproceduralseedspaceterrainoceanatmosphereringscloudsgas giantcraterslavafbmvalue noisepcg hashimpostorraw webgpuwgslcanvas 2d fallbackdraw on demandtimestamp queriesno dependencies

Near it in the frame