GTU-pass2.fs 2.2 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 YIQ_to_RGB mat3x3( 1.0 , 1.0 , 1.0 , 0.9563 , -0.2721 , -1.1070 , 0.6210 , -0.6474 , 1.7046 )
  25. #define pi 3.14159265358
  26. #define a(x) abs(x)
  27. #define d(x,b) (pi*b*min(a(x)+0.5,1.0/b))
  28. #define e(x,b) (pi*b*min(max(a(x)-0.5,-1.0/b),1.0/b))
  29. #define STU(x,b) ((d(x,b)+sin(d(x,b))-e(x,b)-sin(e(x,b)))/(2.0*pi))
  30. #define X(i) (offset-(i))
  31. #define GETC (texture(source[0], vec2(texCoord.x - X*sourceSize[0].z,texCoord.y)).xyz)
  32. #ifdef COMPOSITE_CONNECTION
  33. #define VAL vec3((c.x*STU(X,(SIGNAL_RESOLUTION*sourceSize[0].z))),(c.y*STU(X,(SIGNAL_RESOLUTION_I*sourceSize[0].z))),(c.z*STU(X,(SIGNAL_RESOLUTION_Q*sourceSize[0].z))))
  34. #else
  35. #define VAL (c*STU(X,(SIGNAL_RESOLUTION*sourceSize[0].z)))
  36. #endif //COMPOSITE_CONNECTION
  37. #define PROCESS(i) X=X(i);c=GETC;tempColor+=VAL;
  38. uniform sampler2D source[];
  39. uniform vec4 sourceSize[];
  40. in Vertex {
  41. vec2 texCoord;
  42. };
  43. out vec4 fragColor;
  44. void main() {
  45. float offset = fract((texCoord.x * sourceSize[0].x) - 0.5);
  46. vec3 tempColor = vec3(0.0);
  47. float X;
  48. vec3 c;
  49. PROCESS(-6)PROCESS(-5)PROCESS(-4)PROCESS(-3)PROCESS(-2)PROCESS(-1)PROCESS( 0)
  50. PROCESS( 7)PROCESS( 6)PROCESS( 5)PROCESS( 4)PROCESS( 3)PROCESS( 2)PROCESS( 1)
  51. #ifdef COMPOSITE_CONNECTION
  52. tempColor=clamp(YIQ_to_RGB*tempColor,0.0,1.0);
  53. #endif
  54. tempColor=clamp(pow(tempColor,vec3(TV_DISPLAY_GAMMA)),0.0,1.0);
  55. fragColor = vec4(tempColor,1.0);
  56. }