Advertisement
HyperMitch

The Universe Within (mod by Glitch)

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