aboutsummaryrefslogtreecommitdiff
path: root/pass1.frag
diff options
context:
space:
mode:
Diffstat (limited to 'pass1.frag')
-rw-r--r--pass1.frag31
1 files changed, 25 insertions, 6 deletions
diff --git a/pass1.frag b/pass1.frag
index 784a9a2..8917b61 100644
--- a/pass1.frag
+++ b/pass1.frag
@@ -9,16 +9,35 @@ layout(location = U_LOC_TIME) uniform float time;
layout(location = U_LOC_PASS1) uniform sampler2D buf;
ivec2 res = ivec2(RES_H, RES_V);
+const float step = 0.04;
+const float turns = 9.0;
+
void main() {
- vec2 point = vec2(sin(time), cos(time)) * 0.7;
- point.x *= float(res.y) / float(res.x); // adjust for aspect ratio
- point = ((point + 1.0) / 2.0) * res.xy; // convert to screen coords
+ vec2 uv = gl_FragCoord.xy / res.xy;
float r = 20.0; // circle radius
+
+ vec2 norm = (uv - 0.5) * 2.0;
+ norm.x *= float(res.x) / float(res.y); // adjust for aspect ratio
+
+ float offset = time * 7.0;
+
+ float mag = 1.3 + 0.5 * sin(2 * time);
+ float size = 0.4 + 0.1 * sin(3 * time);
color = vec4(0.0);
- if (length(gl_FragCoord.xy - point) < r)
- color = vec4(1.0);
- color += texture(buf, gl_FragCoord.xy / res.xy) * 0.95;
+ for (float t = 0.0; t < PI_2; t += step) {
+ // <https://www.desmos.com/calculator/e0kq6z1ndd>
+ vec2 f = vec2(
+ cos(t) + mag * cos(turns * t + offset),
+ sin(t) + mag * sin(turns * t + offset)
+ );
+ f *= size;
+ if (length(f - norm) < 0.01) {
+ color = vec4(1.0, 1.0, 1.0, 1.0);
+ }
+ }
+
+ color += texture(buf, ((uv - 0.5) * 0.99) + 0.5) * 0.97;
}