convert from rgb to srgb and the other way around in godot shaders
This file contains 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
float lts(float L) { | |
if (abs(L) < 0.0031308) { | |
return 12.92 * L; | |
} | |
return 1.055 * pow(L, (1.0 / 2.4)) - 0.055; | |
} | |
vec3 rgb_to_srgb(vec3 color) { | |
return vec3(lts(color.r), lts(color.g), lts(color.b)); | |
} | |
float stl(float S) { | |
if (abs(S) < 0.04045) { | |
return S / 12.92; | |
} | |
return pow((S + 0.055) / 1.055, 2.4); | |
} | |
vec3 srgb_to_rgb(vec3 color) { | |
return vec3(stl(color.r), stl(color.g), stl(color.b)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment