Skip to content

Instantly share code, notes, and snippets.

@behreajj
Last active May 22, 2021 12:30
Show Gist options
  • Save behreajj/c9add0366340b670210005e9cacb82ca to your computer and use it in GitHub Desktop.
Save behreajj/c9add0366340b670210005e9cacb82ca to your computer and use it in GitHub Desktop.
Linear Standard Revised
vector le(vector a, float b) {
return vector(a[0] <= b, a[1] <= b, a[2] <= b);
}
vector gt(vector a, float b) {
return vector(a[0] > b, a[1] > b, a[2] > b);
}
color sRgbTolRgb(color standard) {
return select(pow((standard + 0.055) / 1.055, 2.4),
standard / 12.92,
le(standard, 0.04045));
}
color lRgbTosRgb(color linear) {
return select(pow(linear, 1.0 / 2.4) * 1.055 - 0.055,
linear * 12.92,
le(linear, 0.0031308));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment