diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-11-10 12:10:41 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-11-10 12:10:41 +0530 |
| commit | 20ce1dbcb54fba0f4147c502ca16c904bf4ef0da (patch) | |
| tree | fc1dc28d31292fff2d9cdc7ea34d4d90c147956a /sketches/04/polka.frag | |
| parent | a6c771d3ae775476b6637903ea5c12de89ff3f85 (diff) | |
| download | creative-coding-playground-20ce1dbcb54fba0f4147c502ca16c904bf4ef0da.tar.gz creative-coding-playground-20ce1dbcb54fba0f4147c502ca16c904bf4ef0da.zip | |
feat: polka dolkta
Diffstat (limited to 'sketches/04/polka.frag')
| -rw-r--r-- | sketches/04/polka.frag | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sketches/04/polka.frag b/sketches/04/polka.frag new file mode 100644 index 0000000..1a93292 --- /dev/null +++ b/sketches/04/polka.frag @@ -0,0 +1,37 @@ +varying vec4 v_position; +uniform vec2 u_resolution; +uniform float u_time; + +#define MAX_ITERATIONS 100 +#define DOTS 32. + +void main() { + float time = u_time * 2.; + + float ratio = u_resolution.x / u_resolution.y; + vec2 pos = v_position.xy/vec2(1.0, ratio); + + gl_FragColor = vec4(0., 0., 0., 1.); + + float segment = 2.0 / (DOTS + 1.); + + for (float i = 0.; i < DOTS; i++) { + for (float j = 0.; j < DOTS; j++) { + int alt = int(mod(i + j, 2.)); + vec2 step = vec2(segment * (i + 1.0), segment * (j + 1.0)); + float radius = (sin(time - length(pos)) + 1.)*0.02; + if (alt == 0) { + radius = (0.04 - radius); + } + + if (length(pos - 1. + step) < radius) { + if (alt == 0) { + gl_FragColor = vec4(.17, .24, .31, 1.); + } else { + gl_FragColor = vec4(0.75, 0.22, 0.17, 1.); + } + } + } + } +} + |
