GTU-pass4.fs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #version 150
  2. ////////////////////////////////////////////////////////
  3. // GTU version 0.40
  4. // Author: aliaspider - aliaspider@gmail.com
  5. // License: GPLv3
  6. ////////////////////////////////////////////////////////
  7. ////////////////////////////////////////////////////////
  8. // SETTINGS
  9. ////////////////////////////////////////////////////////
  10. //#define CROP_OVERSCAN
  11. #define TV_COLOR_LEVELS
  12. //#define COMPOSITE_CONNECTION
  13. //#define NO_SCANLINES
  14. #define TV_HORIZONTAL_RESOLUTION 400.0
  15. #define TV_VERTICAL_RESOLUTION 300.0
  16. #define SIGNAL_RESOLUTION 280.0
  17. #define SIGNAL_RESOLUTION_I 83.0
  18. #define SIGNAL_RESOLUTION_Q 25.0
  19. #define TV_DISPLAY_GAMMA 2.4
  20. #define OUTPUT_DISPLAY_GAMMA 2.2
  21. ////////////////////////////////////////////////////////
  22. //
  23. ////////////////////////////////////////////////////////
  24. #define SCANLINE_WIDTH (1.5*sourceSize[0].y/TV_VERTICAL_RESOLUTION)
  25. uniform sampler2D source[];
  26. uniform sampler2D texture[];
  27. uniform vec4 sourceSize[];
  28. in Vertex {
  29. vec2 texCoord;
  30. };
  31. out vec4 fragColor;
  32. #define GAMMAOUT(c0) (pow(c0, vec3(1.0/OUTPUTG2)))
  33. #define pi 3.14159265358
  34. #define GAUSS(x,w) ((sqrt(2.0) / (w)) * (exp((-2.0 * pi * (x) * (x)) / ((w) * (w)))))
  35. #define Y(j) (offset.y-(j))
  36. #define a(x) abs(x)
  37. #define d(x,b) (pi*b*min(a(x)+0.5,1.0/b))
  38. #define e(x,b) (pi*b*min(max(a(x)-0.5,-1.0/b),1.0/b))
  39. #define STU(x,b) ((d(x,b)+sin(d(x,b))-e(x,b)-sin(e(x,b)))/(2.0*pi))
  40. #define SOURCE(j) vec2(texCoord.x,texCoord.y - Y(j)*sourceSize[0].w)
  41. #define C(j) (texture2D(source[0], SOURCE(j)).xyz)
  42. #ifdef NO_SCANLINES
  43. #define VAL(j) (C(j)*STU(Y(j),(TV_VERTICAL_RESOLUTION*sourceSize[0].w)))
  44. #else
  45. #define VAL(j) (C(j)*GAUSS(Y(j),SCANLINE_WIDTH))
  46. #endif
  47. void main() {
  48. vec2 offset = fract((texCoord.xy * sourceSize[0].xy) - 0.5);
  49. vec3 tempColor = vec3(0.0);
  50. tempColor+=VAL(-3.0);
  51. tempColor+=VAL(-2.0);
  52. tempColor+=VAL(-1.0);
  53. tempColor+=VAL(0.0);
  54. tempColor+=VAL(1.0);
  55. tempColor+=VAL(2.0);
  56. tempColor+=VAL(3.0);
  57. tempColor+=VAL(4.0);
  58. fragColor = vec4(pow(tempColor,vec3(1.0/OUTPUT_DISPLAY_GAMMA)), 1.0);
  59. }