Add sRGB conversions to shaders.

This commit is contained in:
Geenz 2016-04-25 23:52:33 -04:00
parent a2142646bb
commit d6ee569963

View file

@ -11,9 +11,14 @@
<@if not GPU_COLOR_SLH@>
<@def GPU_COLOR_SLH@>
float sRGBFloatToLinear(float value) {
const float SRGB_ELBOW = 0.04045;
return (value <= SRGB_ELBOW) ? value / 12.92 : pow((value + 0.055) / 1.055, 2.4);
}
vec3 colorToLinearRGB(vec3 srgb) {
const float GAMMA_22 = 2.2;
return pow(srgb, vec3(GAMMA_22));
return vec3(sRGBFloatToLinear(srgb.r), sRGBFloatToLinear(srgb.g), sRGBFloatToLinear(srgb.b));
}
vec4 colorToLinearRGBA(vec4 srgba) {