Skip to content

Instantly share code, notes, and snippets.

@behreajj
Last active May 22, 2021 12:31
Show Gist options
  • Save behreajj/76a1b7e1c158e1e4f002a57a67669c84 to your computer and use it in GitHub Desktop.
Save behreajj/76a1b7e1c158e1e4f002a57a67669c84 to your computer and use it in GitHub Desktop.
Mix Lab
shader mixLab(
color A = 0.0,
color B = 1.0,
float T = 0.5,
color LB = 0.0,
color UB = 1.0,
output color Color = 0.5) {
color aLinear = sRgbTolRgb(A);
vector aXyz = lRgbToXyz(aLinear);
vector aLab = xyzToLab(aXyz);
color bLinear = sRgbTolRgb(B);
vector bXyz = lRgbToXyz(bLinear);
vector bLab = xyzToLab(bXyz);
vector cLab = mix(aLab, bLab, T);
vector cXyz = labToXyz(cLab);
color cLinear = xyzTolRgb(cXyz);
Color = lRgbTosRgb(cLinear);
Color = clamp(Color, LB, UB);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment