Debian Codegraph @

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

raw
1 // Based on https://www.shadertoy.com/view/ldlXRS
2
3 //Noise animation - Electric
4 //by nimitz (stormoid.com) (twitter: @stormoid)
5
6 //The domain is displaced by two fbm calls one for each axis.
7 //Turbulent fbm (aka ridged) is used for better effect.
8
9 #define time iTime*0.15
10 #define tau 6.2831853
11
12 mat2 makem2(in float theta){float c = cos(theta);float s = sin(theta);return mat2(c,-s,s,c);}
13 float noise( in vec2 x ){return texture(iChannel0, x*.01).x;}
14
15 float fbm(in vec2 p)
16 {
17 float z=2.;
18 float rz = 0.;
19 vec2 bp = p;
20 for (float i= 1.;i < 6.;i++)
21 {
22 rz+= abs((noise(p)-0.5)*2.)/z;
23 z = z*2.;
24 p = p*2.;
25 }
26 return rz;
27 }
28
29 float dualfbm(in vec2 p)
30 {
31 //get two rotated fbm calls and displace the domain
32 vec2 p2 = p*.7;
33 vec2 basis = vec2(fbm(p2-time*1.6),fbm(p2+time*1.7));
34 basis = (basis-.5)*.2;
35 p += basis;
36
37 //coloring
38 return fbm(p*makem2(time*0.2));
39 }
40
41 float circ(vec2 p)
42 {
43 float r = length(p);
44 r = log(sqrt(r));
45 return abs(mod(r*4.,tau)-3.14)*3.+.2;
46
47 }
48
49 void mainImage( out vec4 fragColor, in vec2 fragCoord )
50 {
51 //setup system
52 vec2 p = fragCoord.xy / iResolution.xy-0.5;
53 p.x *= iResolution.x/iResolution.y;
54 p*=4.;
55
56 float rz = dualfbm(p);
57
58 //rings
59 p /= exp(mod(time*10.,3.14159));
60 rz *= pow(abs((0.1-circ(p))),.9);
61
62 //final color
63 vec3 col = vec3(.2,0.1,0.4)/rz;
64 col=pow(abs(col),vec3(.99));
65 fragColor = vec4(col,1.);
66 }