Skip to main content

blend_divergence

Function blend_divergence 

Source
pub fn blend_divergence(
    alpha_a: f32,
    mu_a: f32,
    sigma_a: f32,
    alpha_b: f32,
    mu_b: f32,
    sigma_b: f32,
    t: f32,
) -> f32
Expand description

Compute the ΔE divergence between spectral blend and gamma-encoded sRGB lerp at parameter t.

The CMF projection is linear, so SPD lerp = XYZ lerp. The divergence with “RGB lerp” appears because display RGB lerp happens in gamma-encoded sRGB space, which is non-linear. We decode the gamma-encoded endpoints, lerp in linear space, then re-encode — no, that would be the same.

The real divergence is: spectral blend produces an SPD with two peaks (for narrow-band inputs), which when projected gives a different XYZ than the gamma-encoded sRGB lerp. We simulate the common “lerp in 8-bit sRGB” workflow: encode both endpoints to 8-bit sRGB, lerp the 8-bit values, decode back to linear, convert to XYZ.