cross_f.glsl 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. uniform sampler2D tex0;
  2. uniform float time = 5.0;
  3. uniform float rt_w = 1280.0;
  4. uniform float rt_h = 720.0;
  5. uniform float stitching_size = 6.0;
  6. uniform int invert = 0;
  7. vec4 PostFX(sampler2D tex, vec2 uv, float time)
  8. {
  9. vec4 c = vec4(0.0);
  10. float size = stitching_size;
  11. vec2 cPos = uv * vec2(rt_w, rt_h);
  12. vec2 tlPos = floor(cPos / vec2(size, size));
  13. tlPos *= size;
  14. int remX = int(mod(cPos.x, size));
  15. int remY = int(mod(cPos.y, size));
  16. if (remX == 0 && remY == 0)
  17. tlPos = cPos;
  18. vec2 blPos = tlPos;
  19. blPos.y += (size - 1.0);
  20. if ((remX == remY) ||
  21. (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
  22. {
  23. if (invert == 1)
  24. c = vec4(0.2, 0.15, 0.05, 1.0);
  25. else
  26. c = texture2D(tex, tlPos * vec2(1.0/rt_w, 1.0/rt_h)) * 1.4;
  27. }
  28. else
  29. {
  30. if (invert == 1)
  31. c = texture2D(tex, tlPos * vec2(1.0/rt_w, 1.0/rt_h)) * 1.4;
  32. else
  33. c = vec4(0.0, 0.0, 0.0, 1.0);
  34. }
  35. return c;
  36. }
  37. void main (void)
  38. {
  39. vec2 uv = gl_TexCoord[0].st;
  40. if (uv.y > 0.5)
  41. {
  42. gl_FragColor = PostFX(tex0, uv, time);
  43. }
  44. else
  45. {
  46. uv.y += 0.5;
  47. vec4 c1 = texture2D(tex0, uv);
  48. gl_FragColor = c1;
  49. }
  50. }