Shading via GPU and body radiometry

This commit is contained in:
connor committed 2026-10-14 16:30:50 -04:00
1 parent 1b53c9305f
commit 9076929da2
11 files changed
+826 -3

No files matched your search

+59 -1
View File
@@ -313,17 +313,75 @@ Picking the exposure time is the same trade a photographer makes. A longer
exposure saturates the sunlit target. A shorter one leaves the side of the
target lit only by Earthshine lost in noise once noise is modeled (M3).
## Earth, Moon and Sun
Code: `bodies.rs`, `gpu/bodies.rs`, `shaders/bodies.wgsl`.
The three bodies are not drawn as triangle meshes. For every pixel, the
shader sends a ray from the camera through the pixel's center and solves
for where it meets each body's exact shape. The nearest hit wins. This
gives an exact edge at any zoom, at the cost of a few arithmetic operations
per pixel. A mesh would show its facets along the limb, the edge of the
disk, which is the feature horizon-based navigation measures.
- **Earth** is the WGS84 ellipsoid: 6378.137 km equatorial radius,
6356.752 km polar. The 21 km difference matters at fine pixel scales. A
camera with 5.5 urad pixels at 200,000 km sees the north limb 19 pixels
away from where a spherical Earth would put it. A test checks the limb
against the exact tangent to the ellipsoid to within a pixel.
- **The Moon** is a sphere of 1737.4 km radius. From Earth's distance it
is about 0.52 degrees across, 82 pixels in the example camera.
- **The Sun** is a sphere of 695,700 km radius: 0.53 degrees across, about
85 pixels in the example camera. Its disk has the solar radiance from the
folding section above, and it is drawn only where no nearer body covers
it. So Earth eclipses it naturally.
### Shading
Earth and the Moon are Lambertian, with one albedo each, set by
`Appearance`: 0.3 for Earth and 0.12 for the Moon, flat across wavelength.
Each point's radiance is rho cos(i) S_k / (pi d^2), with i the angle between
the surface normal and the Sun. The night side has i past 90 degrees and is
black. The Sun's distance d is taken from each body's center, since the
difference across a body is a few parts in 10^5.
This gets the overall brightness and the phase (how much of the disk is
lit) right. It misses some things that are visible in real images:
- Earth's oceans, land and clouds differ in brightness by a factor of
several. An albedo map comes in M2.
- The full Moon looks almost uniformly bright out to its edge. A Lambertian
sphere instead darkens toward the edge, because the light there arrives
and leaves at grazing angles. Lunar soil scatters light back toward its
source much more strongly than Lambert predicts, and a dedicated lunar
reflectance model (M4) fixes that. The Moon's maria (the dark plains of
old basalt lava, the "seas" seen with the naked eye) and its bright
highlands also differ in albedo by about a factor of two (M2 albedo
map).
- Earth's atmosphere softens the limb and adds a thin bright band around it
(M4). Here Earth's edge is a sharp line.
### Depth from the bodies
The pass also writes each hit's depth, near / z, as described in the
geometry section. The target spacecraft, drawn after the bodies, uses the
same depth buffer. So a target in front of Earth covers it, and a target
behind Earth's limb is hidden.
## Not modeled yet
| Effect | Where |
|---|---|
| Light from Earth and the Moon illuminating the target (Earthshine, Moonshine) | M2 |
| Earth's shadow on the Moon (lunar eclipses) | M2 |
| Earthshine on the Moon's night side | M4 |
| Shadows the target casts on itself | M2 |
| The Sun as a disk that is darker toward its edge (limb darkening) | M2 |
| Lens distortion | M3 |
| Blur from diffraction and lens imperfections (point spread function) | M3 |
| Noise: photon shot noise, read noise, dark current, pixel-to-pixel variation | M3 |
| Saturation spilling into neighbors (blooming) | M3 |
| Non-Lambertian materials (BRDFs), glints | M4 |
| Non-Lambertian materials (BRDFs), glints, lunar backscatter | M4 |
| Earth and Moon albedo maps | M2 |
| Earth's atmosphere: scattering, the bright limb | M4 |
| Motion blur, rolling shutter, stray light | M6 |