Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. /* FOR THIS TO WORK, YOU MUST SET PASSES TO 3 in GIF TOOLS PANEL */
  2.  
  3. precision highp float;
  4.  
  5. varying vec2 UV;
  6. varying vec2 lastUV;
  7. uniform float time;
  8. uniform int pass;
  9. uniform sampler2D lastPass;
  10. uniform float ratio;
  11.  
  12. #define PI 3.14159265359
  13. #define PI2 6.28318
  14.  
  15. void main(void){
  16. float x = UV.x * ratio;
  17. float y = UV.y;
  18.  
  19. vec2 pos = vec2(x, y);
  20.  
  21. vec4 col = vec4(0.0);
  22.  
  23. if(pass == 1){
  24. // Original pass: a simple circle
  25. vec2 center = vec2(0.5,0.5);
  26. float distance_from_center = distance(pos, center);
  27.  
  28. if(distance_from_center < 0.3){
  29. col.rgba = vec4(0.4, 0.5, 0.6, 1.0);
  30. }
  31. } else if (pass == 2){
  32. // Second pass: have fun with position via an offset
  33. vec2 pos_offset = vec2(0.0);
  34.  
  35. pos_offset.x += 0.002 * cos(time * PI2 + pos.y * 100.0);
  36. col = texture2D(lastPass, lastUV + pos_offset);
  37.  
  38. float size = 80.0;
  39. vec2 pixels = 1.0/size * floor(size * pos);
  40. vec2 inpixel = vec2(0.0);
  41. inpixel = mod(pos * size, 1.0);
  42.  
  43. if(inpixel.x < 0.31){
  44. col.rgb *= vec3(1.0, 0.0, 0.0);
  45. }
  46. if(inpixel.x > 0.34 && inpixel.x < 0.6){
  47. col.rgb *= vec3(0.0, 1.0, 0.0);
  48. }
  49. if(inpixel.x > 0.68){
  50. col.rgb *= vec3(0.0, 0.0, 1.0);
  51. }
  52. if(inpixel.y > 0.9 || inpixel.y < 0.1){
  53. col.rgb *= 0.0;
  54. }
  55.  
  56. col += 0.02 * (floor(cos(pos.y * 10.0 - pos.x * 0.4 + time * PI2) * 3.0) + 1.0);
  57. } else if (pass == 3){
  58. // Pass3 glow
  59. float blurf = 0.002;
  60.  
  61. vec4 blur = vec4(0.0);
  62.  
  63. for(int i = 0; i < 2; i++){
  64. blurf *= 1.8;
  65. blur +=
  66. texture2D(lastPass, lastUV + vec2(blurf, 0.00)) +
  67. texture2D(lastPass, lastUV + vec2(-blurf, 0.00)) +
  68. texture2D(lastPass, lastUV + vec2(0.00, -blurf)) +
  69. texture2D(lastPass, lastUV + vec2(0.00, blurf));
  70. }
  71.  
  72. col = texture2D(lastPass, lastUV) * 0.4 + 0.2 * blur;
  73. }
  74.  
  75. col.a = 1.0;
  76.  
  77. gl_FragColor = col;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement