rgb.frag 924 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. uniform sampler2D tex;
  2. uniform sampler2D videoTex;
  3. uniform vec4 cnsts;
  4. in vec4 scaled;
  5. in vec2 pos;
  6. in vec2 videoCoord;
  7. out vec4 fragColor;
  8. // saturate operations are free on nvidia hardware
  9. vec3 saturate(vec3 x)
  10. {
  11. return clamp(x, 0.0, 1.0);
  12. }
  13. void main()
  14. {
  15. float scan_a = cnsts.x;
  16. float scan_b_c2 = cnsts.y; // scan_b * c2
  17. float scan_c_c2 = cnsts.z; // scan_c * c2
  18. float c1_2_2 = cnsts.w; // (c1 - c2) / c2
  19. float scan_c2 = scan_c_c2 + scan_b_c2 * abs(fract(scaled.w) - scan_a);
  20. const float BIG = 128.0; // big number, actual value is not important
  21. vec3 m = saturate((-BIG * fract(scaled.zyx)) + vec3(2.0 * BIG / 3.0));
  22. vec4 col = texture(tex, pos);
  23. #if SUPERIMPOSE
  24. vec4 vid = texture(videoTex, videoCoord);
  25. vec4 p = mix(vid, col, col.a);
  26. #else
  27. vec4 p = col;
  28. #endif
  29. vec3 n = p.rgb * scan_c2;
  30. vec3 s_n = n * c1_2_2 + saturate((n - 1.0) / 2.0);
  31. fragColor.rgb = n + m * s_n;
  32. fragColor.a = p.a;
  33. }