qzdoom/wadsrc/static/shaders/glsl/present.fp

32 lines
872 B
Text
Raw Normal View History

in vec2 TexCoord;
layout(location=0) out vec4 FragColor;
layout(binding=0) uniform sampler2D InputTexture;
2018-08-07 22:54:12 +00:00
layout(binding=1) uniform sampler2D DitherTexture;
vec4 ApplyGamma(vec4 c)
{
vec3 valgray;
if (GrayFormula == 0)
valgray = vec3(c.r + c.g + c.b) * (1 - Saturation) / 3 + c.rgb * Saturation;
else
valgray = mix(vec3(dot(c.rgb, vec3(0.3,0.56,0.14))), c.rgb, Saturation);
vec3 val = valgray * Contrast - (Contrast - 1.0) * 0.5;
val += Brightness * 0.5;
val = pow(max(val, vec3(0.0)), vec3(InvGamma));
return vec4(val, c.a);
}
2018-08-07 01:03:40 +00:00
vec4 Dither(vec4 c, float colorscale)
{
2018-08-07 22:54:12 +00:00
vec2 texSize = vec2(textureSize(DitherTexture, 0));
float threshold = texture(DitherTexture, gl_FragCoord.xy / texSize).r;
2018-08-07 01:03:40 +00:00
return vec4(floor(c.rgb * colorscale + threshold) / colorscale, c.a);
}
void main()
{
2018-08-07 01:03:40 +00:00
FragColor = Dither(ApplyGamma(texture(InputTexture, TexCoord)), 255.0);
}