aboutsummaryrefslogtreecommitdiff
path: root/toy-braids.vert
blob: df7f2bf2197b24507734def76da20a06cf79e8c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const float step = 0.02;
const float mag = 0.3;
const float size = 0.6;
const float turns = 9.0;

const float pi_2 = 6.28318530718;

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
	vec2 norm = (fragCoord / iResolution.xy - 0.5) * 2.0;
	float offset = iTime * 2.0;

	fragColor = vec4(0.0, 0.0, 0.0, 1.0);
	for (float t = 0.0; t < pi_2; t += step) {
		// <https://www.desmos.com/calculator/e0kq6z1ndd>
		vec2 f = vec2(
			size * (cos(t) + mag * cos(turns * t + offset)),
			size * (sin(t) + mag * sin(turns * t + offset))
		);
		if (length(f - norm) < 0.04) {
			fragColor = vec4(1.0, 1.0, 1.0, 1.0);
		}
	}
}