-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCellular.c
More file actions
54 lines (43 loc) · 1.46 KB
/
Cellular.c
File metadata and controls
54 lines (43 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#define PI 3.14159265359
vec3 col1 = vec3(0.216, 0.471, 0.698); // blue
vec3 col2 = vec3(1.00, 0.329, 0.298); // yellow
vec3 col3 = vec3(0.867, 0.910, 0.247); // red
const float dradius = 0.005; // 0.008
float disk(vec2 r, vec2 center, float radius) {
return 1.0 - smoothstep( radius-dradius, radius+dradius, length(r-center));
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
float t = iTime*0.05;
vec2 r = (2.0*fragCoord.xy - iResolution.xy) / iResolution.y;
const float amplitude = 0.15;// 0.05
r *= 1.0 + amplitude*sin(r.x*5.+t) + amplitude*sin(r.y*3.+t);
r *= 1.0 + 0.2*length(r);
float side = 0.5;
vec2 r2 = mod(r, side);
vec2 r3 = r2-side/2.;
float i = floor(r.x/side)+2.;
float j = floor(r.y/side)+4.;
float ii = r.x/side+2.;
float jj = r.y/side+4.;
vec3 pix = vec3(1.0);
float rad, disks;
rad = 0.15 + 0.05*sin(t+ii*jj);
disks = disk(r3, vec2(0.,0.), rad);
pix = mix(pix, col2, disks);
float speed = 2.0;
float tt = iTime*speed+0.1*i+0.08*j;
float stopEveryAngle = PI/2.0;
float stopRatio = 0.7;
float t1 = (floor(tt) + smoothstep(0.0, 1.0-stopRatio, fract(tt)) )*stopEveryAngle;
float x = -0.07*cos(t1+i);
float y = 0.055*(sin(t1+j)+cos(t1+i));
rad = 0.1 + 0.05*sin(t+i+j);
disks = disk(r3, vec2(x,y), rad);
pix = mix(pix, col1, disks);
rad = 0.2 + 0.05*sin(t*(1.0+0.01*i));
disks = disk(r3, vec2(0.,0.), rad);
pix += 0.2*col3*disks * sin(t+i*j+i);
pix -= smoothstep(0.3, 5.5, length(r));
fragColor = vec4(pix,1.0);
}