GPU scattering-LUT precompute — for idiots
What is this?
The sky is blue and sunsets are red because air scatters light. To draw that fast, we bake a little lookup table (LUT): "from here, looking that way, how much sunlight survives the air?" That table is the transmittance LUT.
We already compute it on the CPU (atmos.rs). This change also computes it on the GPU — much faster, and the answer lives in a texture the sky shader can read.
The trick
The GPU version must give the same numbers as the CPU version. So we run BOTH and compare, cell by cell. The CPU one is the "right answer" (the oracle); the GPU one has to match it.
Why care about "no GPU"?
Some machines (a thin laptop) have no usable GPU. So:
- The CPU table is always there — it's the fallback that draws the sky anywhere.
- The GPU test skips politely if there's no graphics card (and writes a little note saying it skipped), but the CPU correctness test still runs and still fails loudly if someone breaks the math. So the feature is checkable on any box.
The one weird edge
Right at the horizon (looking level, or slightly down into the ground), the math has a knife-edge: a tiny rounding difference makes the CPU and GPU disagree on "did the ray hit the ground?". That happens only below the horizon — where the sun is hidden anyway — so we don't count those cells. Everywhere the sky is actually drawn, GPU and CPU agree to ~0.00002.
Run it
- Fast box with a GPU:
cargo test -p facett-map3d-flight --features wgpu,testmatrix - Laptop, no GPU:
cargo test -p facett-map3d-flight --features testmatrix(the CPU check still guards the math).
What did NOT change
The big 21-step picture pipeline in facett-map3d is untouched. This just adds a fast GPU way to bake the sky table, and proves it matches the slow, trusted one.