22 lines
534 B
Plaintext
22 lines
534 B
Plaintext
|
const float GAMMA = 2.2;
|
||
|
const float INV_GAMMA = 1.0 / GAMMA;
|
||
|
|
||
|
// linear to sRGB approximation
|
||
|
// see http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html
|
||
|
vec3 linearTosRGB(vec3 color)
|
||
|
{
|
||
|
return pow(color, vec3(INV_GAMMA));
|
||
|
}
|
||
|
|
||
|
// sRGB to linear approximation
|
||
|
// see http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html
|
||
|
vec3 sRGBToLinear(vec3 srgbIn)
|
||
|
{
|
||
|
return vec3(pow(srgbIn.xyz, vec3(GAMMA)));
|
||
|
}
|
||
|
|
||
|
vec4 sRGBToLinear(vec4 srgbIn)
|
||
|
{
|
||
|
return vec4(sRGBToLinear(srgbIn.xyz), srgbIn.w);
|
||
|
}
|