Advertisement
HyperMitch
Oct 30th, 2024 (edited)
5
0
Never
This is comment for paste The Universe Within (mod by Glitch)
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // The Universe Within - by Martijn Steinrucken aka BigWings 2018
  2. // Email:countfrolic@gmail.com Twitter:@The_ArtOfCode
  3. // License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
  4.  
  5. // After listening to an interview with Michael Pollan on the Joe Rogan
  6. // podcast I got interested in mystic experiences that people seem to
  7. // have when using certain psycoactive substances.
  8. //
  9. // For best results, watch fullscreen, with music, in a dark room.
  10. //
  11. // I had an unused 'blockchain effect' lying around and used it as
  12. // a base for this effect. Uncomment the SIMPLE define to see where
  13. // this came from.
  14. //
  15. // Use the mouse to get some 3d parallax.
  16.  
  17. // Music - Terrence McKenna Mashup - Jason Burruss Remixes
  18. // https://soundcloud.com/jason-burruss-remixes/terrence-mckenna-mashup
  19. //
  20. // YouTube video of this effect:
  21. // https://youtu.be/GAhu4ngQa48
  22. //
  23. // YouTube Tutorial for this effect:
  24. // https://youtu.be/3CycKKJiwis
  25.  
  26.  
  27. #define S(a, b, t) smoothstep(a, b, t)
  28. #define NUM_LAYERS 4.
  29.  
  30. //#define SIMPLE
  31.  
  32.  
  33. float N21(vec2 p) {
  34.     vec3 a = fract(vec3(p.xyx) * vec3(213.897, 653.453, 253.098));
  35.     a += dot(a, a.yzx + 79.76);
  36.     return fract((a.x + a.y) * a.z);
  37. }
  38.  
  39. vec2 GetPos(vec2 id, vec2 offs, float t) {
  40.     float n = N21(id+offs);
  41.     float n1 = fract(n*10.);
  42.     float n2 = fract(n*100.);
  43.     float a = t+n;
  44.     return offs + vec2(sin(a*n1), cos(a*n2))*.4;
  45. }
  46.  
  47. float GetT(vec2 ro, vec2 rd, vec2 p) {
  48.     return dot(p-ro, rd);
  49. }
  50.  
  51. float LineDist(vec3 a, vec3 b, vec3 p) {
  52.     return length(cross(b-a, p-a))/length(p-a);
  53. }
  54.  
  55. float df_line( in vec2 a, in vec2 b, in vec2 p)
  56. {
  57.     vec2 pa = p - a, ba = b - a;
  58.     float h = clamp(dot(pa,ba) / dot(ba,ba), 0., 1.);  
  59.     return length(pa - ba * h);
  60. }
  61.  
  62. float line(vec2 a, vec2 b, vec2 uv) {
  63.     float r1 = .04;
  64.     float r2 = .01;
  65.    
  66.     float d = df_line(a, b, uv);
  67.     float d2 = length(a-b);
  68.     float fade = S(1.5, .5, d2);
  69.    
  70.     fade += S(.05, .02, abs(d2-.75));
  71.     return S(r1, r2, d)*fade;
  72. }
  73.  
  74. float NetLayer(vec2 st, float n, float t) {
  75.     vec2 id = floor(st)+n;
  76.  
  77.     st = fract(st)-.5;
  78.    
  79.     vec2 p[9];
  80.     int i=0;
  81.     for(float y=-1.; y<=1.; y++) {
  82.         for(float x=-1.; x<=1.; x++) {
  83.             p[i++] = GetPos(id, vec2(x,y), t);
  84.         }
  85.     }
  86.    
  87.     float m = 0.;
  88.     float sparkle = 0.;
  89.    
  90.     for(int i=0; i<9; i++) {
  91.         m += line(p[4], p[i], st);
  92.  
  93.         float d = length(st-p[i]);
  94.  
  95.         float s = (.005/(d*d));
  96.         s *= S(1., .7, d);
  97.         float pulse = sin((fract(p[i].x)+fract(p[i].y)+t)*5.)*.4+.6;
  98.         pulse = pow(pulse, 20.);
  99.  
  100.         s *= pulse;
  101.         sparkle += s;
  102.     }
  103.    
  104.     m += line(p[1], p[3], st);
  105.     m += line(p[1], p[5], st);
  106.     m += line(p[7], p[5], st);
  107.     m += line(p[7], p[3], st);
  108.    
  109.     float sPhase = (sin(t+n)+sin(t*.1))*.25+.5;
  110.     sPhase += pow(sin(t*.1)*.5+.5, 50.)*5.;
  111.     m += sparkle*sPhase;//(*.5+.5);
  112.    
  113.     return m;
  114. }
  115.  
  116. void mainImage( out vec4 fragColor, in vec2 fragCoord )
  117. {
  118.     vec2 uv = (fragCoord-iResolution.xy*.5)/iResolution.y;
  119.     vec2 M = iMouse.xy/iResolution.xy-.5;
  120.    
  121.     float t = iTime*.1;
  122.    
  123.     float s = sin(t);
  124.     float c = cos(t);
  125.     mat2 rot = mat2(c, -s, s, c);
  126.     vec2 st = uv*rot;  
  127.     M *= rot*2.;
  128.    
  129.     float m = 0.;
  130.     for(float i=0.; i<1.; i+=1./NUM_LAYERS) {
  131.         float z = fract(t+i);
  132.         float size = mix(15., 1., z);
  133.         float fade = S(0., .6, z)*S(1., .8, z);
  134.        
  135.         m += fade * NetLayer(st*size-M*z, i, iTime);
  136.     }
  137.    
  138.     float fft  = texelFetch( iChannel0, ivec2(.7,0), 0 ).x;
  139.     float glow = -uv.y*fft*2.;
  140.    
  141.     vec3 baseCol = vec3(s, cos(t*.4), -sin(t*.24))*.4+.6;
  142.     vec3 col = baseCol*m;
  143.     col += baseCol*glow;
  144.    
  145.     #ifdef SIMPLE
  146.     uv *= 10.;
  147.     col = vec3(1)*NetLayer(uv, 0., iTime);
  148.     uv = fract(uv);
  149.     //if(uv.x>.98 || uv.y>.98) col += 1.;
  150.     #else
  151.     col *= 1.-dot(uv,uv);
  152.     t = mod(iTime, 230.);
  153.     col *= S(0., 20., t)*S(224., 200., t);
  154.     #endif
  155.    
  156.     fragColor = vec4(col,1);
  157. }
  158.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement