Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # define WARP 2.
  2. # define FREQ_RANGE 20.
  3. # define PI 3.141592653589793
  4. # define SOUNDSOURCE iChannel2
  5. # define WAVELENGTH 0.17
  6. // http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
  7. // Converting (x,y) to range [0,1]
  8.  
  9. vec3 hsv2rgb(vec3 c)
  10. {
  11.     vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
  12.     vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
  13.     return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
  14. }
  15.  
  16. float getfrequency(float x) {
  17.     return texture(SOUNDSOURCE, vec2(floor(x * FREQ_RANGE + 1.0) / FREQ_RANGE, .25)).x + 0.06;
  18. }
  19.  
  20. float getfrequency_smooth(float x) {
  21.     float index = floor(x * FREQ_RANGE) / FREQ_RANGE;
  22.     float next = floor(x * FREQ_RANGE + 1.0) / FREQ_RANGE;
  23.     return mix(getfrequency(index), getfrequency(next), smoothstep(0.0, 1.0, fract(x * FREQ_RANGE)));
  24. }
  25.  
  26. float getfrequency_blend(float x) {
  27.     return mix(getfrequency(x), getfrequency_smooth(x), 0.5);
  28. }
  29.  
  30.  
  31. float getMaxFreq(){
  32.     return texture(SOUNDSOURCE, vec2(1.)).x;
  33. }
  34.  
  35. vec3 gradients( in vec2 coord ) {
  36.    
  37.     return hsv2rgb(vec3 (
  38.         0.5+0.5*sin(0.4*iTime*WARP)*(
  39.             sqrt(
  40.                (pow(0.5-0.6*cos(0.3*WARP*iTime)*(coord.x*1.77-0.385),2.))
  41.                +
  42.                (pow(0.7-0.4*sin(0.15*WARP*iTime)*coord.y,2.))
  43.             )
  44.         ),
  45.         0.8+0.2*cos(0.2*WARP*iTime)*(
  46.             sqrt(
  47.                (pow(0.5-0.6*cos(0.3*WARP*iTime)*(coord.x*1.77-0.385),2.))
  48.                +
  49.                (pow(-0.1*cos(0.3*WARP*iTime)*coord.y,2.))
  50.             )
  51.         ),
  52.         0.9+0.1*sin(WARP*iTime)*(
  53.             sqrt(
  54.                 (pow(0.6-sin(2.*WARP*iTime)*(coord.x*1.77-0.385),2.))
  55.                 +
  56.                 (pow(0.2-cos(WARP*iTime)*coord.y,2.))
  57.             )
  58.         )
  59.     ));
  60. }
  61.  
  62. vec3 ripples( in vec2 uv, in vec2 cent ){
  63.     float r = max(length(cent-uv),0.03);
  64.     float wave_speed = 5.*WARP*iTime;
  65.     return vec3 (
  66.         1.-0.9*sin(500.*WAVELENGTH*r-wave_speed)
  67.     );
  68. }
  69.  
  70. vec2 yscale( float pos_x, float pos_y ){
  71.     float y_scale = iResolution.y/iResolution.x;
  72.     return vec2 ( pos_x, pos_y*y_scale );
  73. }
  74.  
  75. float fade( in float f_in, in float f_out){
  76.     float warp_time = iTime*WARP;
  77.     float fade_duration = f_out-f_in;
  78.     return max(0.,min(1./(f_out-f_in)*(f_out-warp_time),1.));
  79. }
  80.  
  81. void mainImage( out vec4 fragColor, in vec2 fragCoord )
  82. {
  83.     float weight = 0.9;
  84.     float pi = 3.141592653589793;
  85.     vec2 uv = fragCoord/iResolution.xy;
  86.     vec2 uv_c = yscale(uv.x-0.5 , uv.y-0.5);
  87.     vec2 cent = vec2(0.5);
  88.     float scale = iResolution.x/1920.;
  89.     vec2 offset = yscale(-10.*WAVELENGTH, -10.*WAVELENGTH);
  90.     vec2 cent2 = yscale(-0.7, -0.7);
  91.     vec2 cent3 = yscale(0.7,0.7);
  92.     vec2 cent4 = yscale(-0.7,0.7);
  93.     vec2 cent5 = yscale(0.7,-0.7);
  94.     vec2 cent6 = yscale(-0.05, 0.55);
  95.     vec2 cent7 = yscale(0.05, -0.65);
  96.    
  97.     vec3 col = fade(60.,80.)*gradients(uv)*weight
  98.                +fade(80.,60.)*(
  99.                                hsv2rgb(vec3 (
  100.                                    0.6*sin(1./60.*iTime)
  101.                                    -0.5*getfrequency_smooth(
  102.                                         sin(min(0.25,
  103.                                                 max(0.07,
  104.                                                     0.8*length(uv_c)
  105.                                    )))),
  106.                                    0.99,
  107.                                    0.3
  108.                                )))
  109.                -(
  110.                    fade(25.,40.)*(
  111.                     cos(-iTime*WARP*0.02)*ripples(uv_c,cent3)
  112.                     +cos(-iTime*WARP*0.02)*ripples(uv_c,cent3+offset)
  113.                     +cos(-iTime*WARP*0.02)*ripples(uv_c,cent2)
  114.                     +cos(-iTime*WARP*0.02)*ripples(uv_c,cent2+offset)
  115.                     +cos(-iTime*WARP*0.02)*ripples(uv_c,cent4)
  116.                     +cos(-iTime*WARP*0.02)*ripples(uv_c,cent4+offset)
  117.                     +cos(-iTime*WARP*0.02)*ripples(uv_c,cent5)
  118.                     +cos(-iTime*WARP*0.02)*ripples(uv_c,cent5+offset)
  119.                    )
  120.                    +fade(37.,20.)*fade(50.,60.)*(
  121.                     +2.*cos(-iTime*WARP*0.1)*ripples(uv_c,cent6)
  122.                     +2.*cos(-iTime*WARP*0.1)*ripples(uv_c,cent6-offset)
  123.                     +2.*cos(-iTime*WARP*0.1)*ripples(uv_c,cent7)
  124.                     +2.*cos(-iTime*WARP*0.1)*ripples(uv_c,cent7+offset)
  125.                    )
  126.                    /*+fade(0.,300.)*(
  127.                     +cos(-iTime*WARP/10.)*ripples(uv_c,cent)
  128.                     +cos(-iTime*WARP/10.)*ripples(uv_c,cent+offset)
  129.                    )*/
  130.                    +fade(80.,40.)*(0.2+0.8*getfrequency_smooth(mod(iTime,1000.)))*(
  131.                      ripples(
  132.                          uv_c,
  133.                          (0.9+0.1*getfrequency_smooth(mod(iTime,1000.)))
  134.                          *vec2(-WAVELENGTH*sin(0.1*iTime*WARP),
  135.                                -WAVELENGTH*cos(0.1*iTime*WARP))
  136.                          +(0.95+0.05*getfrequency_smooth(0.001*mod(iTime,1000.)))
  137.                           *0.1*vec2(1.5*WAVELENGTH*sin(2.1*iTime*WARP),
  138.                                     1.5*WAVELENGTH*cos(2.1*iTime*WARP))
  139.                       )
  140.                     +ripples(
  141.                          uv_c,
  142.                          (0.9+0.1*getfrequency_smooth(mod(iTime,1000.)))
  143.                          *vec2(-WAVELENGTH*sin(0.1*iTime*WARP),
  144.                                -WAVELENGTH*cos(0.1*iTime*WARP))
  145.                          +(0.95+0.05*getfrequency_smooth(0.001*mod(iTime,1000.)))
  146.                           *0.1*vec2(-1.5*WAVELENGTH*sin(2.1*iTime*WARP),
  147.                                     -1.5*WAVELENGTH*cos(2.1*iTime*WARP))
  148.                      ))
  149.                )*(1.-weight);
  150.  
  151.     fragColor = vec4(0.2+0.8*sqrt(col),1.);
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement