Skip to content

Instantly share code, notes, and snippets.

@behreajj
Last active May 22, 2021 12:31
Show Gist options
  • Save behreajj/c5f5932f5bda50048c9e9d337ca3a872 to your computer and use it in GitHub Desktop.
Save behreajj/c5f5932f5bda50048c9e9d337ca3a872 to your computer and use it in GitHub Desktop.
Linear-CIE XYZ Conversion
vector lRgbToXyz(color linear) {
return transform(matrix(
0.41241086, 0.21264935, 0.019331759, 0.0,
0.35758457, 0.71516913, 0.11919486 , 0.0,
0.1804538 , 0.07218152, 0.95039004 , 0.0,
0.0 , 0.0 , 0.0 , 1.0),
linear);
}
color xyzTolRgb(vector xyz) {
return transform(matrix(
3.2408123 , -0.969243 , 0.0556384 , 0.0,
-1.5373085 , 1.8759663 , -0.20400746, 0.0,
-0.49858654, 0.041555032, 1.0571296 , 0.0,
0.0 , 0.0 , 0.0 , 1.0),
xyz);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment