mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- add dithering to present shader
This commit is contained in:
parent
4c20553a62
commit
7362070504
1 changed files with 15 additions and 1 deletions
|
@ -17,7 +17,21 @@ vec4 ApplyGamma(vec4 c)
|
|||
return vec4(val, c.a);
|
||||
}
|
||||
|
||||
float DitherMatrix[16] = float[](
|
||||
0.0 / 16.0 - 0.5, 8.0 / 16.0 - 0.5, 2.0 / 16.0 - 0.5, 10.0 / 16.0 - 0.5,
|
||||
12.0 / 16.0 - 0.5, 4.0 / 16.0 - 0.5, 14.0 / 16.0 - 0.5, 6.0 / 16.0 - 0.5,
|
||||
3.0 / 16.0 - 0.5, 11.0 / 16.0 - 0.5, 1.0 / 16.0 - 0.5, 9.0 / 16.0 - 0.5,
|
||||
15.0 / 16.0 - 0.5, 7.0 / 16.0 - 0.5, 13.0 / 16.0 - 0.5, 5.0 / 16.0 - 0.5
|
||||
);
|
||||
|
||||
vec4 Dither(vec4 c, float colorscale)
|
||||
{
|
||||
ivec2 pos = ivec2(gl_FragCoord.xy) & 3;
|
||||
float threshold = DitherMatrix[pos.x + (pos.y << 2)];
|
||||
return vec4(floor(c.rgb * colorscale + threshold) / colorscale, c.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = ApplyGamma(texture(InputTexture, TexCoord));
|
||||
FragColor = Dither(ApplyGamma(texture(InputTexture, TexCoord)), 255.0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue