simple.frag 852 B

12345678910111213141516171819202122232425262728293031323334
  1. uniform sampler2D tex;
  2. uniform sampler2D videoTex;
  3. uniform vec4 cnst;
  4. uniform vec3 texStepX; // = vec3(vec2(1.0 / texSize.x), 0.0);
  5. in vec2 scaled;
  6. in vec3 misc;
  7. in vec2 videoCoord;
  8. out vec4 fragColor;
  9. void main()
  10. {
  11. float scan_a = cnst.x;
  12. float scan_b = cnst.y;
  13. float scan_c = cnst.z;
  14. float alpha = cnst.w;
  15. vec3 t = (vec3(floor(scaled.x)) + alpha * vec3(fract(scaled.x))) * texStepX + misc;
  16. vec4 col1 = texture(tex, t.xz);
  17. vec4 col2 = texture(tex, t.yz);
  18. float scan = scan_c + scan_b * abs(fract(scaled.y) - scan_a);
  19. #if SUPERIMPOSE
  20. vec4 col = (col1 + col2) / 2.0;
  21. vec4 vid = texture(videoTex, videoCoord);
  22. fragColor = mix(vid, col, col.a) * scan;
  23. #else
  24. // optimization: in case of not-superimpose, we moved the division by 2
  25. // '(col1 + col2) / 2' to the 'scan_b' and 'scan_c' variables.
  26. fragColor = (col1 + col2) * scan;
  27. #endif
  28. }