mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 17:41:19 +00:00
888fba12ea
# Conflicts: # src/gl/renderer/gl_postprocess.cpp # src/gl/renderer/gl_renderbuffers.h # Conflicts: # wadsrc/static/shaders/glsl/present.fp
36 lines
942 B
GLSL
36 lines
942 B
GLSL
|
|
in vec2 TexCoord;
|
|
out vec4 FragColor;
|
|
|
|
uniform sampler2D InputTexture;
|
|
uniform float InvGamma;
|
|
uniform float Contrast;
|
|
uniform float Brightness;
|
|
uniform float Saturation;
|
|
uniform int GrayFormula;
|
|
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);
|
|
}
|
|
|
|
vec4 Dither(vec4 c, float colorscale)
|
|
{
|
|
vec2 texSize = vec2(textureSize(DitherTexture, 0));
|
|
float threshold = texture(DitherTexture, gl_FragCoord.xy / texSize).r;
|
|
return vec4(floor(c.rgb * colorscale + threshold) / colorscale, c.a);
|
|
}
|
|
|
|
void main()
|
|
{
|
|
FragColor = Dither(ApplyGamma(texture(InputTexture, TexCoord)), 255.0);
|
|
}
|