You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3 KiB

пре 8 година
пре 8 година
пре 8 година
пре 9 година
пре 8 година
пре 8 година
пре 8 година
  1. #version 330
  2. // Input vertex attributes (from vertex shader)
  3. in vec2 fragTexCoord;
  4. in vec4 fragColor;
  5. // Input uniform values
  6. uniform sampler2D texture0;
  7. uniform vec4 fragTintColor;
  8. // Output fragment color
  9. out vec4 finalColor;
  10. // NOTE: Add here your custom variables
  11. const float renderWidth = 1280.0;
  12. const float renderHeight = 720.0;
  13. float stitchingSize = 6.0;
  14. uniform int invert = 0;
  15. vec4 PostFX(sampler2D tex, vec2 uv)
  16. {
  17. vec4 c = vec4(0.0);
  18. float size = stitchingSize;
  19. vec2 cPos = uv * vec2(renderWidth, renderHeight);
  20. vec2 tlPos = floor(cPos / vec2(size, size));
  21. tlPos *= size;
  22. int remX = int(mod(cPos.x, size));
  23. int remY = int(mod(cPos.y, size));
  24. if (remX == 0 && remY == 0) tlPos = cPos;
  25. vec2 blPos = tlPos;
  26. blPos.y += (size - 1.0);
  27. if ((remX == remY) || (((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
  28. {
  29. if (invert == 1) c = vec4(0.2, 0.15, 0.05, 1.0);
  30. else c = texture(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
  31. }
  32. else
  33. {
  34. if (invert == 1) c = texture(tex, tlPos * vec2(1.0/renderWidth, 1.0/renderHeight)) * 1.4;
  35. else c = vec4(0.0, 0.0, 0.0, 1.0);
  36. }
  37. return c;
  38. }
  39. void main()
  40. {
  41. vec3 tc = PostFX(texture0, fragTexCoord).rgb;
  42. finalColor = vec4(tc, 1.0);
  43. }