zenpixels · transfer functions & codegen

Why pixel codes are curved, not linear

Human eyes see brightness roughly logarithmically: a tiny step near black looks as big as a huge jump near white. Transfer functions bend stored codes to match human vision (and HDR headroom). Hover the charts to inspect exact EOTF/OETF values, compare bit allocation, and generate live zenpixels-convert Rust code below.

01

Interactive EOTF, OETF & bit-allocation charts

Nothing is hidden or silently clamped. Flip between EOTF (encoded value → light) and OETF (light → encoded value), and toggle every rule explicitly below — including unclamped floats above 1.0 (so Linear, sRGB, BT.709, and Gamma 2.2 climb right past SDR white to 10,000 nits), negative out-of-gamut floats, odd mirroring, narrow TV range, log/linear axes, and HLG display rendering.

Rules (toggle any assumption explicitly)
HLG Display Rendering (HlgRendering · BT.2100-3 Table 5)

EOTF: encoded signal → linear light

x = signal, y = linear light

Perceptual bit allocation (stops per code step)

lower = finer dark/midtone steps (less banding)

Try toggling the rules above: With Allow > 1.0 checked (floating-point F32), Linear climbs smoothly right past 1.0 (203 nits) all the way to 49.3 (10,000 nits), and sRGB climbs to 5.12 — uncheck Allow > 1.0 to see integer U8/U16 clip at SDR white while PQ & HLG keep HDR inside [0, 1]. Flip to OETF (light → value) to put every curve on the same physical luminance axis, or toggle Narrow / TV range to see 16–235 studio swing.

02

HLG on the Web & why a 1D curve isn't enough

Unlike PQ (where every code has one absolute brightness in nits), HLG is display-adaptive and channel-coupled. Two rules explain almost every HLG surprise on the web:

HLG on the web (Chrome, Safari, CSS HDR & ICC): Browsers and OS compositors render HLG using the viewer's live display peak Lw, black floor Lb, and surround-adjusted γ — so the exact same HLG image maps 75% signal to ~203 nits on a 1000-nit reference monitor, ~81 nits on a 300-nit SDR laptop, and ~342 nits on a 2000-nit TV. Because the BT.2100-3 OOTF scales all three channels by shared BT.2020 luminance Ysγ−1 (not independent per-channel cγ), standard 1D ICC TRCs cannot represent HLG display rendering — which is why zenpixels requires explicit HlgRendering (on full-range BT.2020 RGB/RGBA) and refuses HLG ICC synthesis.
03

Every transfer function in zenpixels, explained

Each curve encodes a different physical assumption. Mixing up scene-referred and display-referred curves (or applying sRGB curves to alpha) is the #1 source of washed-out or crushed colors.

04

Live Rust conversion code

Pick source, destination, policies, and SIMD accelerator budget. The Rust code updates live using the real zenpixels-convert 0.4 API (including const Accelerators helpers for light builds).