dot-mask.fs 767 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #version 150
  2. uniform sampler2D source[];
  3. uniform vec4 sourceSize[];
  4. uniform vec4 targetSize;
  5. #define mod_factor (texCoord.x * targetSize.x)
  6. in Vertex {
  7. vec2 texCoord;
  8. };
  9. //#define MONOCHROME //emulates a black-and-white television
  10. out vec4 fragColor;
  11. vec3 desaturate(vec3 col)
  12. {
  13. return vec3(dot(col, vec3(0.2126, 0.7152, 0.0722)));
  14. }
  15. void main() {
  16. vec3 screen = texture(source[0], texCoord).rgb;
  17. #ifdef MONOCHROME
  18. screen = desaturate(screen);
  19. #endif
  20. // Output pixels are alternately tinted green and magenta.
  21. vec3 dotMaskWeights = mix(
  22. vec3(1.0, 0.7, 1.0),
  23. vec3(0.7, 1.0, 0.7),
  24. floor(mod(mod_factor, 2.0))
  25. );
  26. screen *= dotMaskWeights;
  27. screen *= 1.15; //compensate for darkening
  28. fragColor = vec4(screen, 1.0);
  29. }