Last active
May 22, 2021 12:29
-
-
Save behreajj/dc185ec497bde0cf19a53cb95d4e5c73 to your computer and use it in GitHub Desktop.
Linear Standard RGB Conversions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
color sRgbTolRgb(color standard) { | |
float sr = standard[0]; | |
float sg = standard[1]; | |
float sb = standard[2]; | |
return color( | |
select(pow((sr + 0.055) / 1.055, 2.4), sr / 12.92, sr <= 0.04045), | |
select(pow((sg + 0.055) / 1.055, 2.4), sg / 12.92, sg <= 0.04045), | |
select(pow((sb + 0.055) / 1.055, 2.4), sb / 12.92, sb <= 0.04045)); | |
} | |
color lRgbTosRgb(color linear) { | |
float lr = linear[0]; | |
float lg = linear[1]; | |
float lb = linear[2]; | |
return color( | |
select(pow(lr, 1.0 / 2.4) * 1.055 - 0.055, lr * 12.92, lr <= 0.0031308), | |
select(pow(lg, 1.0 / 2.4) * 1.055 - 0.055, lg * 12.92, lg <= 0.0031308), | |
select(pow(lb, 1.0 / 2.4) * 1.055 - 0.055, lb * 12.92, lb <= 0.0031308)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment