Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. #define PI 3.1416
  2. #define PI2 (2.0 * PI)
  3.  
  4. /*
  5. Complex square
  6. */
  7. highp vec2 to_the_2(highp vec2 z){
  8. highp vec2 old_z;
  9. // Keep the current (old) value
  10. old_z = z;
  11.  
  12. // Set new values according to math
  13. z.x = pow(z.x,2.0) - pow(z.y,2.0);
  14. z.y = 2.0 * old_z.x * old_z.y;
  15.  
  16. return z;
  17. }
  18.  
  19.  
  20. vec4 mandelbrot(vec2 UV){
  21. float x = UV.x / (iResolution.y / iResolution.x);
  22. float y = UV.y;
  23.  
  24. vec4 col = vec4(0.0);
  25.  
  26. vec2 c = vec2( -y + 0.5, x - 0.5);
  27. vec2 z = vec2(0.0, 0.0);
  28. c *= 4.0;
  29. c.x -= 0.5;
  30. float maxit = 0.0;
  31.  
  32. bool in_set = true;
  33.  
  34. for(int i = 0; i < 50; i++){
  35. z = to_the_2(z) + c;
  36.  
  37. if(length(z) > 2.0){
  38. maxit = float(i);
  39. in_set = false;
  40. break;
  41. }
  42. }
  43.  
  44. if(!in_set){
  45. col.g = maxit/50.0;
  46. } else {
  47. col.g = maxit/50.0;
  48. col.r = length(z);
  49. }
  50. col.b = maxit/50.0;
  51.  
  52. col.a = 1.0;
  53.  
  54. return col;
  55. }
  56.  
  57. vec4 glitch_ball(vec2 pos){
  58. float x = pos.x;
  59. float y = pos.y;
  60. vec4 col = vec4(0.0);
  61. float time = iGlobalTime;
  62. x = x - floor(x * 260.0) + time/100.0;
  63. y = y - floor(y * 30.0) + time/100.0;
  64.  
  65. col.r = sin(13.0 * x + y + PI2 * time + 0.3);
  66. col.g = sin((13.0 + 0.006 * cos(time*PI2 + 30.0 * pos.x)) * x + y + PI2 * time + 0.3);
  67. col.b = sin((13.0) * x + y + PI2 * time + 0.3);
  68.  
  69. col = abs(col);
  70.  
  71. if(distance(pos, vec2(0.5,0.5)) > 0.4){
  72. col *= 0.0;
  73. }
  74.  
  75. col.a = 1.0;
  76. return col;
  77. }
  78.  
  79.  
  80.  
  81. void mainImage( out vec4 fragColor, in vec2 fragCoord )
  82. {
  83. vec2 uv = fragCoord.xy / iResolution.xy;
  84. fragColor = mandelbrot(uv) * glitch_ball(uv);
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement