Repository navigation
SkyAtmosphere.altitude: a planet's sky from the street to low orbit - #282
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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).pathtrace.wgslaerial_planet, reference + testssky.rsaerial_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 (testplanet_haze_is_the_airs_light).world.rs,live/edits.rs): a new altitude alone isChanges::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; descriptoraltitude.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
altitudechange)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 inedits_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).tests/render/sky-aerial-perspective.ts,scenes/sun-room.ts,scenes/material-grid.tsare identical to the byte, and each repeats run to run. Neither the fullrender-identitynor the perf smoke was run. The code that existing scenes run is unchanged (new branches onP.aerial.w > 0,Horizon::Levelas before).threert-render render, a 6,371 km globe under the camera at (0, −(R + h), 0)):altitude(the old sky): the frame is fogged white;🤖 Generated with Claude Code