Files
hyperframes/packages/engine/src
Vance Ingalls ee48280fe0 fix(engine): convert sRGB DOM overlays to BT.2020 primaries before HDR composite
DOM overlays composited onto HDR video frames were oversaturated because
`blitRgba8OverRgb48le` mapped sRGB 8-bit values directly through an
HDR OETF (HLG or PQ) without first converting from BT.709 to BT.2020
color primaries. Treating sRGB values as if they already lived in the
much wider BT.2020 gamut pushed saturated colors well past the
designer's intent — e.g. sRGB pure blue (0,0,255) landed on BT.2020
blue, which is far more vivid than what was specified.

Replace `buildSrgbToHdrLut` with the full pipeline:
  sRGB 8-bit
    → linear BT.709 (sRGB EOTF, 256-entry LUT)
    → linear BT.2020 (3×3 BT.2087-0 primary matrix)
    → HDR signal 16-bit (HLG/PQ OETF, 4096-entry LUT)

The matrix rows sum to 1.0, so neutral content (R=G=B) is invariant —
text and grayscale UI render identically. Chromatic content (icons,
accent colors, progress bars) is now color-accurate against BT.2020
HDR video. PQ scales relative to 203 nits SDR white per BT.2408 so
SDR overlays sit at conventional brightness inside the HDR frame.

Verified end-to-end with hdr-smoke (sdr-baseline, hdr-pq,
mixed-sdr-hdr): sampled red overlay pixels (#C1121F) in the rendered
PQ output match the calculated post-conversion 16-bit values
(~30837/18894/15630), versus the old buggy pipeline's
~33820/10529/13663 (visibly oversaturated).

Removes the `getSrgbToHdrLut` public export — the LUT is now an
internal pipeline stage, not a single-step conversion.

Made-with: Cursor
2026-04-19 18:34:32 -07:00
..
2026-03-21 22:43:56 -07:00