Debian Codegraph @

screensaver.shadertoy/resources/shaders/noiseanimwatery.frag.glsl

raw
1 // Taken from https://www.shadertoy.com/view/MssSRS
2
3 //Noise animation - Watery by nimitz (twitter: @stormoid)
4
5 //The domain is rotated by the values of a preliminary fbm call
6 //then the fbm function is called again to color the screen.
7 //Turbulent fbm (aka ridged) is used for better effect.
8 //define centered to see the rotation better.
9
10 //#define CENTERED
11
12 #define time iTime*0.2
13
14 mat2 makem2(in float theta){float c = cos(theta);float s = sin(theta);return mat2(c,-s,s,c);}
15 float noise( in vec2 x ){return texture(iChannel0, x*.01).x;}
16
17 mat2 m2 = mat2( 0.80, 0.60, -0.60, 0.80 );
18 float fbm( in vec2 p )
19 {
20 float z=2.;
21 float rz = 0.;
22 for (float i= 1.;i < 7.;i++ )
23 {
24 rz+= abs((noise(p)-0.5)*2.)/z;
25 z = z*2.;
26 p = p*2.;
27 p*= m2;
28 }
29 return rz;
30 }
31
32 void mainImage( out vec4 fragColor, in vec2 fragCoord )
33 {
34 vec2 p = fragCoord.xy / iResolution.xy*2.-1.;
35 p.x *= iResolution.x/iResolution.y;
36 vec2 bp = p;
37 #ifndef CENTERED
38 p += 5.;
39 p *= 0.6;
40 #endif
41 float rb = fbm(p*.5+time*.17)*.1;
42 rb = sqrt(rb);
43 #ifndef CENTERED
44 p *= makem2(rb*.2+atan(p.y,p.x)*1.);
45 #else
46 p *= makem2(rb*.2+atan(p.y,p.x)*2.);
47 #endif
48
49 //coloring
50 float rz = fbm(p*.9-time*.7);
51 rz *= dot(bp*5.,bp)+.5;
52 rz *= sin(p.x*.5+time*4.)*1.5;
53 vec3 col = vec3(.04,0.07,0.45)/(.1-rz);
54 fragColor = vec4(sqrt(abs(col)),1.0);
55 }