-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDots.fs
67 lines (49 loc) · 1.22 KB
/
Dots.fs
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
55
56
57
58
59
60
61
62
63
64
65
66
67
/*{
"DESCRIPTION": "https://www.shadertoy.com/view/4lVyDt",
"CREDIT": "3d dot ring by iridule",
"CATEGORIES": [
"dots"
],
"INPUTS": [
],
}*/
#define R RENDERSIZE.xy
#define T TIME
vec2 polarRep(vec2 U, float n) {
n = 6.283/n;
float a = atan(U.y, U.x),
r = length(U);
a = mod(a+n/2.,n) - n/2.;
U = r * vec2(cos(a), sin(a));
return .5* ( U+U - vec2(1,0) );
}
mat2 rotate(float a) {
float c = cos(a),
s = sin(a);
return mat2(c, s, -s, c);
}
float ring(vec2 uv, float n, float s, float f) {
uv = polarRep(uv, n);
return smoothstep(s + f, s, length(uv));
}
void mainImage(out vec4 O, in vec2 I) {
vec2 uv = (2. * I - R) / R.y;
vec3 col = vec3(0.);
uv.x += .1 * cos(T * .2);
uv.y += .1 * sin(T * .2);
float k = 12.;
float n = 8.;
for (float i = 0., s = 1. / n; i < 1.; i += s) {
float t = fract(T * .1 + i);
float z = smoothstep(1., .1, t);
float f = smoothstep(0., 1., t) *
smoothstep(1., .8, t);
uv *= rotate(i * .15);
col += ring(uv * z, k, .03, .0085) * f;
}
col *= col;
O = vec4(col, 1.);
}
void main(void) {
mainImage(gl_FragColor, gl_FragCoord.xy);
}