add tonemapping shaders

This commit is contained in:
2020-05-22 19:59:34 +08:00
parent eb0b29275e
commit 23685cd868
18 changed files with 606 additions and 59 deletions

View 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);
}