cross.frag 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #version 120
  2. uniform sampler2D texture;
  3. uniform sampler2D desktop;
  4. uniform int desktopWidth;
  5. uniform int desktopHeight;
  6. uniform float time;
  7. varying vec2 uvCoord;
  8. void main() {
  9. float stitching_size = 6.0;
  10. int invert = 0;
  11. float size = stitching_size;
  12. vec2 cPos = uvCoord * vec2(desktopWidth, desktopHeight);
  13. vec2 tlPos = floor(cPos / vec2(size, size));
  14. tlPos *= size;
  15. int remX = int(mod(cPos.x, size));
  16. int remY = int(mod(cPos.y, size));
  17. if (remX == 0 && remY == 0)
  18. tlPos = cPos;
  19. vec2 blPos = tlPos;
  20. blPos.y += (size - 1.0);
  21. if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y))))) {
  22. if (invert == 1) {
  23. gl_FragColor = vec4(0.2, 0.15, 0.05, 1.0);
  24. } else {
  25. gl_FragColor = texture2D(texture, tlPos * vec2(1.0/desktopWidth, 1.0/desktopHeight)) * 1.4;
  26. }
  27. } else {
  28. if (invert == 1) {
  29. gl_FragColor = texture2D(texture, tlPos * vec2(1.0/desktopWidth, 1.0/desktopHeight)) * 1.4;
  30. } else {
  31. gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
  32. }
  33. }
  34. }