color-pipeline-tonemappinglisted
Install: claude install-skill rustcircle/c101
# Color pipeline and tonemapping
Rule zero: every texture, buffer and swapchain has a declared encoding and primaries, and an image is
decoded exactly once and encoded exactly once. Numbers below come from
[references/color-checks.md](references/color-checks.md) (NumPy; matrices re-derived, test pairs checked).
## 1. Pipeline order and per-buffer conventions
decode → linear working space (lighting) → exposure → display transform (tonemap, gamut map) → encode.
| Data | Format | Why |
|---|---|---|
| baseColor/albedo, emissive colour, sheen and specular colour, UI and sprite textures | `*_SRGB` (decoded on sample, before filtering) | authored as sRGB-encoded colour |
| normal, roughness, metallic, occlusion, ORM packs, height, masks, flow maps, noise, LUTs | `UNORM` (linear) | data, not colour |
| HDR environment maps | float (EXR, RGBE, KTX2 float) | already linear |
| HDR render targets | RGBA16F, or R11G11B10F for opaque lighting | section 7 |
| SDR swapchain | `*_SRGB` view with linear shader output, or `UNORM` plus one manual encode | exactly one encode |
| HDR swapchain | RGB10A2 with PQ (HDR10) or RGBA16F scRGB | section 6 |
## 2. Spaces and matrices
| Space | R xy | G xy | B xy | White | Transfer |
|---|---|---|---|---|---|
| sRGB / Rec.709 | 0.64, 0.33 | 0.30, 0.60 | 0.15, 0.06 | D65 (0.3127, 0.3290) | sRGB piecewise; BT.1886 for video |
| Display P3 | 0.680, 0.320 | 0.265, 0.690 | 0.150, 0.060 | D65 | sRGB curve |
| Rec.2020 / BT.2100 | 0.708, 0.292 | 0.170, 0.7