Apex › Data & encoding

Why RGB blends look muddy (OKLab)

Averaging two vivid colors by their RGB values makes a muddy, too-dark midpoint, because RGB codes are gamma-encoded emitted light, not perception. OKLab (Ottosson 2020) is a perceptual color space — gamma-decode → LMS cones → cube root → L/a/b — so blending in it keeps the lightness even. Verified in node: the sRGB→OKLab→sRGB round-trip returns to 1.6e-6, sRGB red maps to Ottosson’s reference (0.628, 0.225, 0.126), and the sRGB gradient midpoint measures up to ~11% darker in perceived L than OKLab’s. It’s CSS Color 4’s oklch(). Compare the two blends and watch the lightness curve sag or stay straight.

More in Data & encoding