2016-07-26 19:27:02 +00:00
|
|
|
|
|
|
|
in vec2 TexCoord;
|
|
|
|
out vec4 FragColor;
|
|
|
|
|
|
|
|
uniform sampler2D InputTexture;
|
2016-08-15 22:01:18 +00:00
|
|
|
uniform float InvGamma;
|
2016-07-26 19:27:02 +00:00
|
|
|
uniform float Contrast;
|
|
|
|
uniform float Brightness;
|
2017-06-25 23:33:07 +00:00
|
|
|
uniform float Saturation;
|
2017-06-26 10:33:59 +00:00
|
|
|
uniform int GrayFormula;
|
2016-07-26 19:27:02 +00:00
|
|
|
|
|
|
|
vec4 ApplyGamma(vec4 c)
|
|
|
|
{
|
2017-06-26 07:50:49 +00:00
|
|
|
vec3 valgray;
|
|
|
|
if (Saturation != 1.0) // attempt to cool things a bit, this calculation makes the GPU run really hot
|
2017-06-26 10:33:59 +00:00
|
|
|
if (GrayFormula == 0)
|
|
|
|
valgray = vec3(c.r + c.g + c.b) * (1 - Saturation) / 3 + c.rgb * Saturation;
|
|
|
|
else
|
|
|
|
valgray = vec3(0.3 * c.r + 0.56 * c.g + 0.14 * c.b) * (1 - Saturation) + c.rgb * Saturation;
|
2017-06-26 07:50:49 +00:00
|
|
|
else
|
|
|
|
valgray = c.rgb;
|
2017-06-25 23:33:07 +00:00
|
|
|
vec3 val = valgray * Contrast - (Contrast - 1.0) * 0.5;
|
2016-07-26 19:27:02 +00:00
|
|
|
val += Brightness * 0.5;
|
2016-09-21 19:13:10 +00:00
|
|
|
val = pow(max(val, vec3(0.0)), vec3(InvGamma));
|
2016-07-26 19:27:02 +00:00
|
|
|
return vec4(val, c.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
FragColor = ApplyGamma(texture(InputTexture, TexCoord));
|
|
|
|
}
|