diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-11-10 22:02:28 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-11-10 22:02:28 +0530 |
| commit | 73137f0315aa9080389f96170e7e7248e6c55c7d (patch) | |
| tree | ac68df7b5464995dddaf324305953c7288e8ceac /sketches/03 | |
| parent | 20ce1dbcb54fba0f4147c502ca16c904bf4ef0da (diff) | |
| download | creative-coding-playground-73137f0315aa9080389f96170e7e7248e6c55c7d.tar.gz creative-coding-playground-73137f0315aa9080389f96170e7e7248e6c55c7d.zip | |
feat: 03 just the grid (no flo bro)
Diffstat (limited to 'sketches/03')
| -rw-r--r-- | sketches/03/flow.frag | 37 | ||||
| -rw-r--r-- | sketches/03/test.png | bin | 0 -> 428196 bytes |
2 files changed, 37 insertions, 0 deletions
diff --git a/sketches/03/flow.frag b/sketches/03/flow.frag new file mode 100644 index 0000000..8402b2e --- /dev/null +++ b/sketches/03/flow.frag @@ -0,0 +1,37 @@ +#define CELL_COUNT 10.0 + +varying vec4 v_position; +uniform vec2 u_resolution; +uniform float u_time; + +uniform sampler2D testImage; + +struct Particle { + vec2 position; + vec2 velocity; +}; + +bool is_between(vec2 pos, vec2 min, vec2 max) { + return pos.x > min.x && pos.x < max.x && pos.y > min.y && pos.y < max.y; +} + +void main() { + float time = sin(u_time); + vec2 uv = gl_FragCoord.xy/u_resolution.xy; + float ratio = u_resolution.x / u_resolution.y; + vec2 pos = uv/vec2(1.0, ratio); + + float cell_size = 1.0/CELL_COUNT; + + for (float i = 0.; i < CELL_COUNT; i++) { + for (float j = 0.; j < CELL_COUNT; j++) { + vec2 cell_pos = vec2(i, j) * cell_size; + + if (is_between(pos, cell_pos, cell_pos + vec2(cell_size, cell_size))) { + vec4 tex = texture2D(testImage, cell_pos); + float value = (tex.r + tex.g + tex.b) / 3.; + gl_FragColor = vec4(value, value, value, 1.0); + } + } + } +} diff --git a/sketches/03/test.png b/sketches/03/test.png Binary files differnew file mode 100644 index 0000000..e81a1bb --- /dev/null +++ b/sketches/03/test.png |
