Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # define WARP 2.
- # define FREQ_RANGE 20.
- # define PI 3.141592653589793
- # define SOUNDSOURCE iChannel2
- # define WAVELENGTH 0.17
- // http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
- // Converting (x,y) to range [0,1]
- vec3 hsv2rgb(vec3 c)
- {
- vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
- vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
- return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
- }
- float getfrequency(float x) {
- return texture(SOUNDSOURCE, vec2(floor(x * FREQ_RANGE + 1.0) / FREQ_RANGE, .25)).x + 0.06;
- }
- float getfrequency_smooth(float x) {
- float index = floor(x * FREQ_RANGE) / FREQ_RANGE;
- float next = floor(x * FREQ_RANGE + 1.0) / FREQ_RANGE;
- return mix(getfrequency(index), getfrequency(next), smoothstep(0.0, 1.0, fract(x * FREQ_RANGE)));
- }
- float getfrequency_blend(float x) {
- return mix(getfrequency(x), getfrequency_smooth(x), 0.5);
- }
- float getMaxFreq(){
- return texture(SOUNDSOURCE, vec2(1.)).x;
- }
- vec3 gradients( in vec2 coord ) {
- return hsv2rgb(vec3 (
- 0.5+0.5*sin(0.4*iTime*WARP)*(
- sqrt(
- (pow(0.5-0.6*cos(0.3*WARP*iTime)*(coord.x*1.77-0.385),2.))
- +
- (pow(0.7-0.4*sin(0.15*WARP*iTime)*coord.y,2.))
- )
- ),
- 0.8+0.2*cos(0.2*WARP*iTime)*(
- sqrt(
- (pow(0.5-0.6*cos(0.3*WARP*iTime)*(coord.x*1.77-0.385),2.))
- +
- (pow(-0.1*cos(0.3*WARP*iTime)*coord.y,2.))
- )
- ),
- 0.9+0.1*sin(WARP*iTime)*(
- sqrt(
- (pow(0.6-sin(2.*WARP*iTime)*(coord.x*1.77-0.385),2.))
- +
- (pow(0.2-cos(WARP*iTime)*coord.y,2.))
- )
- )
- ));
- }
- vec3 ripples( in vec2 uv, in vec2 cent ){
- float r = max(length(cent-uv),0.03);
- float wave_speed = 5.*WARP*iTime;
- return vec3 (
- 1.-0.9*sin(500.*WAVELENGTH*r-wave_speed)
- );
- }
- vec2 yscale( float pos_x, float pos_y ){
- float y_scale = iResolution.y/iResolution.x;
- return vec2 ( pos_x, pos_y*y_scale );
- }
- float fade( in float f_in, in float f_out){
- float warp_time = iTime*WARP;
- float fade_duration = f_out-f_in;
- return max(0.,min(1./(f_out-f_in)*(f_out-warp_time),1.));
- }
- void mainImage( out vec4 fragColor, in vec2 fragCoord )
- {
- float weight = 0.9;
- float pi = 3.141592653589793;
- vec2 uv = fragCoord/iResolution.xy;
- vec2 uv_c = yscale(uv.x-0.5 , uv.y-0.5);
- vec2 cent = vec2(0.5);
- float scale = iResolution.x/1920.;
- vec2 offset = yscale(-10.*WAVELENGTH, -10.*WAVELENGTH);
- vec2 cent2 = yscale(-0.7, -0.7);
- vec2 cent3 = yscale(0.7,0.7);
- vec2 cent4 = yscale(-0.7,0.7);
- vec2 cent5 = yscale(0.7,-0.7);
- vec2 cent6 = yscale(-0.05, 0.55);
- vec2 cent7 = yscale(0.05, -0.65);
- vec3 col = fade(60.,80.)*gradients(uv)*weight
- +fade(80.,60.)*(
- hsv2rgb(vec3 (
- 0.6*sin(1./60.*iTime)
- -0.5*getfrequency_smooth(
- sin(min(0.25,
- max(0.07,
- 0.8*length(uv_c)
- )))),
- 0.99,
- 0.3
- )))
- -(
- fade(25.,40.)*(
- cos(-iTime*WARP*0.02)*ripples(uv_c,cent3)
- +cos(-iTime*WARP*0.02)*ripples(uv_c,cent3+offset)
- +cos(-iTime*WARP*0.02)*ripples(uv_c,cent2)
- +cos(-iTime*WARP*0.02)*ripples(uv_c,cent2+offset)
- +cos(-iTime*WARP*0.02)*ripples(uv_c,cent4)
- +cos(-iTime*WARP*0.02)*ripples(uv_c,cent4+offset)
- +cos(-iTime*WARP*0.02)*ripples(uv_c,cent5)
- +cos(-iTime*WARP*0.02)*ripples(uv_c,cent5+offset)
- )
- +fade(37.,20.)*fade(50.,60.)*(
- +2.*cos(-iTime*WARP*0.1)*ripples(uv_c,cent6)
- +2.*cos(-iTime*WARP*0.1)*ripples(uv_c,cent6-offset)
- +2.*cos(-iTime*WARP*0.1)*ripples(uv_c,cent7)
- +2.*cos(-iTime*WARP*0.1)*ripples(uv_c,cent7+offset)
- )
- /*+fade(0.,300.)*(
- +cos(-iTime*WARP/10.)*ripples(uv_c,cent)
- +cos(-iTime*WARP/10.)*ripples(uv_c,cent+offset)
- )*/
- +fade(80.,40.)*(0.2+0.8*getfrequency_smooth(mod(iTime,1000.)))*(
- ripples(
- uv_c,
- (0.9+0.1*getfrequency_smooth(mod(iTime,1000.)))
- *vec2(-WAVELENGTH*sin(0.1*iTime*WARP),
- -WAVELENGTH*cos(0.1*iTime*WARP))
- +(0.95+0.05*getfrequency_smooth(0.001*mod(iTime,1000.)))
- *0.1*vec2(1.5*WAVELENGTH*sin(2.1*iTime*WARP),
- 1.5*WAVELENGTH*cos(2.1*iTime*WARP))
- )
- +ripples(
- uv_c,
- (0.9+0.1*getfrequency_smooth(mod(iTime,1000.)))
- *vec2(-WAVELENGTH*sin(0.1*iTime*WARP),
- -WAVELENGTH*cos(0.1*iTime*WARP))
- +(0.95+0.05*getfrequency_smooth(0.001*mod(iTime,1000.)))
- *0.1*vec2(-1.5*WAVELENGTH*sin(2.1*iTime*WARP),
- -1.5*WAVELENGTH*cos(2.1*iTime*WARP))
- ))
- )*(1.-weight);
- fragColor = vec4(0.2+0.8*sqrt(col),1.);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement