Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/facett

facett-map3d-flight/.nornir/scatter-lut-gpu-for-idiots.md

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 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

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.