add tonemapping shaders
This commit is contained in:
21
shader/Functions/gamma.glsl
Normal file
21
shader/Functions/gamma.glsl
Normal file
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
Reference in New Issue
Block a user