Skip to content

SkyAtmosphere.altitude: a planet's sky from the street to low orbit - #282

Merged
doodlewind merged 1 commit into
mainfrom
sky-altitude
Nov 26, 2026
Merged

doodlewind merged 1 commit into
mainfrom
sky-altitude

Conversation

@doodlewind

Copy link
Copy Markdown
Collaborator

SkyAtmosphere.altitude (m): the scene's ground is a globe drawn about a floating origin, and the viewer is this high above it, from the street to low orbit. Unset (the default), nothing changes.

What it does

  • The bake (sky.rs): the sky is baked from that altitude instead of the camera's y. Above the atmosphere's top (100 km) a ray is marched from where it enters the air; rays that miss the air see black space. The horizon dips with altitude (Horizon::Planet: 19.8° at 400 km), black below it so that rays that miss the globe geometry get no blue. The texel row the horizon crosses is covered in proportion, and its alpha holds that share, so the limb's own radiance can be read back (SkyBake::horizon_v → Params::sky_color.w).
  • Aerial perspective (pathtrace.wgsl aerial_planet, reference + tests sky.rs aerial_columns): with an altitude, the haze's air and Mie columns run over a sphere whose centre is straight below the camera, not at sea-level density around y = 0. Each segment is a difference of Chapman-function columns. Ch(x, μ) = √(πx/2) erfcx(μ√(x/2)), from the altitude to second order along the ray. erfcx is the Abramowitz & Stegun 7.1.13 bound with an exact slope at 0 and a fitted factor (own fit, within 0.42 %). Against a quadrature over the exact sphere, from 2 m to 2,000 km and segments of 10 m to 3,000 km, the transmittance is within 0.003. Haze light on a planet is the limb's radiance in the ray's azimuth (the bake's limb row), within 0.5–1.8× of the medium's own in-scatter for rays that end on the ground from 10–400 km (test planet_haze_is_the_airs_light).
  • Live (world.rs, live/edits.rs): a new altitude alone is Changes::altitude, not another sky. The haze takes it at once. The sky is re-baked in place on the dynamic sky's worker thread once it is 5 % (at least 250 m) from the altitude it was baked for (move_altitude). A sky without a sun bakes on the main thread.
  • packages/scene: SkyAtmosphere.altitude: number | null; descriptor altitude.

Sources

Chapman 1931 (the grazing-incidence function); Abramowitz & Stegun 1964, 7.1.13 (erfcx bounds); the atmosphere is the existing Bruneton & Neyret 2008 / Hillaire 2020 medium. No other code was consulted.

Merge gate (tier R1: only scenes that set altitude change)

  • cargo test --release -- --test-threads=1: 279 + 2 passed. New tests: sky_from_space, planet_bake_dips_its_horizon, aerial_columns_over_the_planet, planet_haze_is_the_airs_light, a_planets_altitude_is_not_another_sky, and two edits in edits_in_place_leave_what_a_build_does: a planet's sky, then its altitude moved (re-baked in place, the same state and picture as a build).
  • npm run typecheck, npm test (324 pass).
  • Byte identity, offline, against main 605120f: tests/render/sky-aerial-perspective.ts, scenes/sun-room.ts, scenes/material-grid.ts are identical to the byte, and each repeats run to run. Neither the full render-identity nor the perf smoke was run. The code that existing scenes run is unchanged (new branches on P.aerial.w > 0, Horizon::Level as before).
  • Stills (offline, threert-render render, a 6,371 km globe under the camera at (0, −(R + h), 0)):
    • at 400 km: black space, the limb, haze over the land;
    • the same without altitude (the old sky): the frame is fogged white;
    • at 10 km and at 2 m: as before.

🤖 Generated with Claude Code

The sky is baked from the viewer's real altitude (above the atmosphere's top:
black space and the air's limb), its horizon dipped and black below it
(sky::Horizon::Planet, the limb row's share in alpha); aerial perspective runs
over the sphere below the camera (Chapman's function as an erfcx, held to a
quadrature within 0.003 in transmittance); a new altitude alone re-bakes in
place on the worker thread past 5 % / 250 m.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@doodlewind
doodlewind merged commit 7876d87 into main Nov 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants