| 1 |
// Based on https://www.shadertoy.com/view/MdlXRS |
| 2 |
|
| 3 |
//Noise animation - Flow |
| 4 |
//by nimitz (stormoid.com) (twitter: @stormoid) |
| 5 |
|
| 6 |
|
| 7 |
//Somewhat inspired by the concepts behind "flow noise" |
| 8 |
//every octave of noise is modulated separately |
| 9 |
//with displacement using a rotated vector field |
| 10 |
|
| 11 |
//normalization is used to created "swirls" |
| 12 |
//usually not a good idea, depending on the type of noise |
| 13 |
//you are going for. |
| 14 |
|
| 15 |
//Sinus ridged fbm is used for better effect. |
| 16 |
|
| 17 |
#define time iTime*0.1 |
| 18 |
#define tau 6.2831853 |
| 19 |
|
| 20 |
mat2 makem2(in float theta){float c = cos(theta);float s = sin(theta);return mat2(c,-s,s,c);} |
| 21 |
float noise( in vec2 x ){return texture(iChannel0, x*.01).x;} |
| 22 |
mat2 m2 = mat2( 0.80, 0.60, -0.60, 0.80 ); |
| 23 |
|
| 24 |
float grid(vec2 p) |
| 25 |
{ |
| 26 |
float s = sin(p.x)*cos(p.y); |
| 27 |
return s; |
| 28 |
} |
| 29 |
|
| 30 |
float flow(in vec2 p) |
| 31 |
{ |
| 32 |
float z=2.; |
| 33 |
float rz = 0.; |
| 34 |
vec2 bp = p; |
| 35 |
for (float i= 1.;i < 7.;i++ ) |
| 36 |
{ |
| 37 |
bp += time*1.5; |
| 38 |
vec2 gr = vec2(grid(p*3.-time*2.),grid(p*3.+4.-time*2.))*0.4; |
| 39 |
gr = normalize(gr)*0.4; |
| 40 |
gr *= makem2((p.x+p.y)*.3+time*10.); |
| 41 |
p += gr*0.5; |
| 42 |
|
| 43 |
rz+= (sin(noise(p)*8.)*0.5+0.5) /z; |
| 44 |
|
| 45 |
p = mix(bp,p,.5); |
| 46 |
z *= 1.7; |
| 47 |
p *= 2.5; |
| 48 |
p*=m2; |
| 49 |
bp *= 2.5; |
| 50 |
bp*=m2; |
| 51 |
} |
| 52 |
return rz; |
| 53 |
} |
| 54 |
|
| 55 |
float spiral(vec2 p,float scl) |
| 56 |
{ |
| 57 |
float r = length(p); |
| 58 |
r = log(r); |
| 59 |
float a = atan(p.y, p.x); |
| 60 |
return abs(mod(scl*(r-2./scl*a),tau)-1.)*2.; |
| 61 |
} |
| 62 |
|
| 63 |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) |
| 64 |
{ |
| 65 |
vec2 p = fragCoord.xy / iResolution.xy-0.5; |
| 66 |
p.x *= iResolution.x/iResolution.y; |
| 67 |
p*= 3.; |
| 68 |
float rz = flow(p); |
| 69 |
p /= exp(mod(time*3.,2.1)); |
| 70 |
rz *= (6.-spiral(p,3.))*.9; |
| 71 |
vec3 col = vec3(.2,0.07,0.01)/rz; |
| 72 |
col=pow(abs(col),vec3(1.01)); |
| 73 |
fragColor = vec4(col,1.0); |
| 74 |
} |