The coating LUT and the render

Ghost Lab samples R(λ) at 81 wavelengths and 86 angles, folds it through the CIE illuminant into linear-sRGB, and hands a tiny texture to the GPU.

Lesson 3 of 5 · ~9 min read

The 3D scene is a thin shader over a precomputed lookup table. All the physics happens on the CPU in buildCoatingLUT; the GPU just multiplies, exposes, and gamma-encodes.

What the LUT holds

  1. For each view angle θ from 0° to 85° (86 samples), the TMM kernel is called at 81 wavelengths from 380 to 780 nm in 5 nm steps — unpolarised R(λ, θ).
  2. The 81-point R(λ) spectrum is integrated against the selected CIE illuminant (D65, A, or C) and the CIE 1931 colour-matching functions to get a CIE XYZ triple, then mapped to linear sRGB via the standard sRGB primary matrix.
  3. The resulting {R, G, B} triple is written into row θ of an 86×1 floating-point texture. Optionally the transmittance LUT is built the same way for see-through mode.

That is the entire physics side. One LUT per stack, rebuilt only when the stack, substrate, polarisation, or illuminant changes — typically under 10 ms for a four-layer stack on an M-series Mac.

What the shader does with it

The panel's fragment shader runs once per pixel. It computes the local incidence angle from the camera position and panel normal, looks up the linear-sRGB reflectance Rrgb(θ) in the LUT, samples the procedurally painted environment cube in the reflected direction to get the incoming radiance E(θ), multiplies, scales by the exposure, and applies the sRGB OETF.

pixel = sRGB_OETF( exposure · E(θ) · Rrgb(θ) )

Exposure is a display knob: it multiplies the linear radiance before tone-mapping. It changes how many stops of headroom you can see without clipping; it does not change the physics. A good coating stays dark at every exposure, a bad one brightens the moment you raise it.

The single-number readout

The R = …% figure shown next to each stack is not a per-pixel measurement and not a monochromatic reflectance. It is a single-angle readback from the LUT: the tool takes the three per-channel reflectances for that angle and combines them with the sRGB / Rec. 709 luminance weights, computed under a D65 LUT:

Y = 0.2126 R + 0.7152 G + 0.0722 B

Treat this number as an estimate of perceived brightness. It is not the reflectance at 555 nm — and it is not the full CIE photopic integral (∫ R(λ) · V(λ) · D65(λ) dλ) either. It is the standard display-luminance formula applied to the three sRGB-primary reflectances the LUT already holds — which is why the number stays comparable across stacks (the pipeline is the same), and why it only lines up with CIE Y when the reflectance is close to spectrally flat.