Why is the sky blue? Build a planet and find out.

Earth is never told to be blue. The engine takes a star temperature, a pressure, a gas and a haze, runs Rayleigh scattering, Planck spectra and the CIE colour-matching functions, and blue is what comes out. Turn the same knobs and the same equations give you the black sky of the Moon, Mars, Titan, the Archean, a lava world, or a sky no one has seen.

Sky image is brightness-normalised: the dome shows chromaticity and relative brightness only, with one floor: a sky dimmer than about 1/180 of Earth's (relative to its own star) is shown dark rather than gained up, so an airless world goes black. Absolute illuminance is on the lux bar below. Plane-parallel single scattering; left edge faces the sun, right edge faces away.

45.0° −10° (twilight cut-off)time of day, not a planet parameter90° zenith
Zenith sky#000000
Horizon toward sun#000000
Sun disc (transmitted)#000000
Eye
Ground illuminance (direct + diffuse, horizontal surface) first-principles0 lx
Star
5772 K 2300 K (late M)12,000 K (A star)
1.00 S⊕ 0.1 S⊕3 S⊕
Atmosphere
1.00 bar 1 µbar (airless)log axis100 bar
column: 2.15e29 molecules/m² (Earth g) · scattering column vs Earth: 1.00×
τRayleigh(550 nm) = 0.0973 · τtotal(550 nm) = 0.147 · multi-scatter blend 0%
Main gas scattering ratio vs N₂
0.00 % 0 %absorbs 600 to 730 nm, scaled by column5 %
0.05 0 (clear)10 (Titan-thick)
ω = 0.99 sooty, absorbingbright, scattering
Surface
288 K 200 Kfree parameter, not derived3000 K

Eight skies, one engine

Every preset runs through exactly the same code path as the free sandbox. Nothing in the engine knows which planet it is rendering. What differs between worlds is only where the sliders sit, and the table says which slider carries the colour.

PresetWhat sets the colourThe knob that mattersReads as
MoonNothing. At 1 µbar (the slider floor; the real lunar exosphere is around 3 × 10⁻¹⁵ bar) τR(550) ≈ 10⁻⁷, so the sky radiance is a few 10⁻⁸ of the sunlight and the exposure floor leaves it black. The sun disc is the unattenuated Planck curve of a 5772 K starPressure. Drag it up from the floor and watch the sky fade in: a dark navy appears near 1 mbar, a full blue dome by about 10 mbar. The dome is the same equation at every step; only the column changesBlack sky, hard white sun, 12 % grey ground (lunar regolith albedo happens to be about 0.12), 88,000 lx from the direct beam alone
EarthRayleigh λ⁻⁴ on a 1 bar N₂ column, τR(550) ≈ 0.097, almost no hazePressure. Watch the τR readout: 1 bar is the sweet spot where blue is scattered strongly but not yet self-shieldedBlue zenith, pale horizon, red sun at sunset
Mars6 mbar of CO₂ gives τR(550) ≈ 0.0014, three hundred times weaker than the dust (haze 0.5, ω ≈ 0.55)Pressure again. Mars fails to be blue on column density, not chemistry: switch its gas to N₂ and nothing changesButterscotch, low saturation
TitanHaze τ = 5 with dark aerosols and 5 % CH₄: the light you see has already crossed airmasses of haze that eats blue first, then multiple scattering (blend ≈ 0.5) washes it toward sunlightHaze optical depth. Drop it to 1 and the orange collapses to grey-whitePeach-orange, dim (0.011 S⊕)
Archean EarthSame N₂ column as today under a 5400 K younger Sun, plus a dark organic haze at τ ≈ 3 and 1.5 % CH₄Haze darkness. Bright haze at the same τ gives a white sky; sooty haze gives orangeOrange-tan, no blue anywhere
Lava worldA 2400 K surface out-radiates the star. Absorbing haze re-emits that glow into the sky (thermal term, weighted by 1 − e−τabs)Surface temperature. Below about 1200 K the glow vanishes and the thin N₂ sky returnsIncandescent orange-red dome, lux off the chart
M-dwarf terrestrialA 2550 K star has almost no blue to scatter. Rayleigh still prefers blue, but it is scattering a red-orange illuminantThe Eye toggle. Camera: pale peach. Adapted eye: the star's white is divided out and the sky is blue againDepends entirely on adaptation
Ice giantDeep H₂ column (10 bar, k = 0.22) with 3 % CH₄: methane bands remove 600 to 730 nm from the transmitted and scattered light, so even the sun disc goes green-whiteMethane. Slide it to zero and the sky goes from cyan-blue to plain Rayleigh blue with a whiter horizonCyan-blue

The pipeline

Everything flows one direction. No feedback loops, no solving for equilibrium, no radiative transfer solver. Tags mark which steps are physics and which are fitted.

  1. Illuminant. Normalised Planck curve at the star temperature, scaled by insolation to W/m²/nm at the top of the atmosphere. No absorption lines. first-principles
  2. Rayleigh optical depth. τR(λ) = 0.0973 · kgas · (P/P⊕) · (550/λ)⁴, with 0.0973 Earth's sea-level Rayleigh optical depth at 550 nm. λ⁻⁴ The per-gas factors N₂ 1.0, CO₂ 2.4, H₂ 0.22, H₂O 0.6 come from squared refractivity ratios. fitted
  3. Methane absorption. Empirical band curve, zero below 600 nm, rising to a strong cut at 730 nm, scaled by mixing ratio and column. Pure absorber: it removes light, it never adds scattering. fitted
  4. Haze. Optical depth with a mild (550/λ)¹ dependence, single-scattering albedo from the darkness slider (0.20 sooty to 0.99 bright at 550 nm, absorption tilted toward blue like real soot, tholin and iron-oxide dust), Henyey-Greenstein phase function with g = 0.7. fitted
  5. Airmass. Kasten-Young from elevation, clamped at 40. Below 0° the direct beam fades to zero by −6°; the page cuts at −10° because plane-parallel twilight is wrong. first-principles
  6. Radiance. Exact single-scattering slab solution for 8 view zenith angles (0° to 88°) in three azimuths (toward the sun, 90°, away): incident irradiance × phase function at the sun-view scattering angle × albedo × the slab geometry factor mv(e−τms − e−τmv)/(mv − ms). first-principles
  7. Multiple-scattering correction. When τtotal(550) exceeds 0.5, chromaticity is blended toward the illuminant's own chromaticity by a factor rising to 0.85 at τ = 10. This is the largest approximation on the page: a desaturation hack standing in for successive orders of scattering. fitted
  8. Thermal emission. Above 900 K the surface Planck curve is added, weighted by 1 − e−τabs·m over the absorbing (non-scattering) part of the column. Below 900 K it is invisible and skipped. first-principles
  9. Colour. Integrate against the CIE 1931 2° colour-matching functions (embedded, 5 nm, 380 to 730 nm), preserve chromaticity, convert to linear sRGB with D65 primaries, desaturate toward white when out of gamut rather than clamping per channel, then sRGB gamma. first-principles
  10. Adaptation. Camera mode assumes D65 and applies nothing. Adapted-eye mode applies a von Kries (Bradford) transform from the star's white point to D65. first-principles

Why Earth is blue, in three lines

Rayleigh scattering goes as λ⁻⁴, so 450 nm light is scattered about 4.4 times more than 650 nm light. Sunlight is a 5772 K Planck curve that already peaks in the green and falls off in the violet, and the CIE ȳ curve says the eye is nearly blind below 420 nm, so the scattered spectrum, when integrated, lands at a chromaticity of roughly x = 0.25, y = 0.26: a sky blue, not violet. Toward the horizon the view path crosses many airmasses, blue is scattered out again before it reaches you, and the colour whitens.

Why Mars is not blue

Set the Mars preset and read the pressure panel. At 6 mbar the Rayleigh optical depth at 550 nm is about 0.0014. The dust haze is 0.5. Molecular scattering is losing by a factor of several hundred, so the sky is whatever the dust makes it, and iron-oxide dust absorbs blue. Switch Mars to N₂, or to H₂O, and the colour does not move. Now drag the pressure to 1 bar and Mars goes blue with CO₂ still selected. The lesson is in the τR readout, not in the chemistry.

The self-check you can see

The sun disc is drawn in the transmitted beam colour, the illuminant attenuated by e−τ(λ)·m, while the dome is the scattered colour. They are computed separately from the same τ(λ). At an Earth sunset the two must come apart: red disc, blue-then-orange sky. If they ever agree at low sun, the engine is broken.

How accurate is this?

First-principles (the equation is the real one, only the geometry is simplified): Rayleigh λ⁻⁴ scaling, the Planck illuminant and thermal term, the exact single-scattering slab solution, Kasten-Young airmass, CIE 1931 integration, the XYZ to sRGB matrix, Bradford chromatic adaptation, the lux integral (683 lm/W × ȳ).

Fitted (a number or a shape chosen to look right, not derived): the per-gas scattering coefficients, the methane band curve and its strength constant, the haze wavelength exponent, the haze albedo range and its blue-tilted absorption, the Henyey-Greenstein asymmetry g = 0.7, the multiple-scattering chromaticity blend (its 0.5 threshold, its 0.85 ceiling and its linear ramp), the dome tone curve and its exposure floor (skies below 10⁻⁴ of the star's irradiance are shown dark instead of normalised), and every preset value.

Known omissions: no Mie theory or aerosol size distributions, no ozone Chappuis band (real Earth twilight is bluer than this), no spherical-shell geometry (so twilight is wrong and cut at −10°), no polarisation, no clouds, no surface reflection into the sky, no equilibrium temperature, no check that the world could exist. Real Mars dust and Titan tholins have albedo spectra measured across many wavelengths; here they are one number and one tilt.

The reason to take the invented worlds semi-seriously: Earth and Mars are not special-cased anywhere. They are produced by the same equations, with the same fitted constants, that produce the lava world and the M-dwarf sky. Add ?test to the URL to see the regression harness assert that Earth comes out blue, its sunset red, Mars butterscotch and Titan orange, with the actual hex values printed. If that harness ever fails, the presets are not to be adjusted to hide it.

Things worth trying

David Veksler is a Principal AI Engineer in Denver. He leads agentic AI engineering at Antech, a Mars company, and builds AI platforms for regulated financial firms. This page was produced by a governed, multi-agent Claude Code pipeline with a git audit trail. How it's built Case studies