diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-05-21 21:43:13 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-05-21 21:43:13 +0200 |
commit | 33deac9462906c5e7b084665df3194cfa5e73249 (patch) | |
tree | b49b70e3cfa8ce4d8d6f9d037caa73f5c267656c | |
parent | 6bbc2ca9f50137ff718152df8622e600282d489f (diff) |
add shadertoy "braids" effect
-rw-r--r-- | toy-braids.vert | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/toy-braids.vert b/toy-braids.vert new file mode 100644 index 0000000..df7f2bf --- /dev/null +++ b/toy-braids.vert @@ -0,0 +1,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); + } + } +} + |