Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. // Fragment shader
  2. precision highp float;
  3.  
  4. varying vec2 UV;
  5. varying vec3 v_position;
  6. uniform float time;
  7. uniform float ratio;
  8. uniform vec2 mouse;
  9.  
  10.  
  11.  
  12. /*
  13. Complex square
  14. */
  15. highp vec2 to_the_2(highp vec2 z){
  16. highp vec2 old_z;
  17. // Keep the current (old) value
  18. old_z = z;
  19.  
  20. // Set new values according to math
  21. z.x = pow(z.x,2.0) - pow(z.y,2.0);
  22. z.y = 2.0 * old_z.x * old_z.y;
  23.  
  24. return z;
  25. }
  26.  
  27. void main(void){
  28. float x = -(UV.y - 0.3)*3.0;
  29. float y = (UV.x - 0.5)*3.0;
  30.  
  31. vec4 col = vec4(54.0, 70.0, 93.0, 0.0)/255.0;
  32. col.a = 1.0;
  33.  
  34. float sintime = sin(2.0 * 3.1416 * time);
  35.  
  36. highp vec2 z = vec2(0.0, 0.0);
  37. highp vec2 c = vec2(x, y);
  38.  
  39. float maxit = 0.0;
  40.  
  41. for(int i = 0; i < 20; i++){
  42. z = to_the_2(z) + c;
  43.  
  44. if(length(z) > 20.0){
  45. maxit = float(i);
  46. break;
  47. }
  48. }
  49.  
  50. if(length(z) < sintime + 0.6){
  51. col.r = z.x;
  52. col.b = z.y;
  53. }
  54.  
  55. gl_FragColor = col;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement