diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-11-11 14:55:22 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-11-11 15:02:53 +0530 |
| commit | dcd918162dcb4d70b905cc562ae92d98a10045ce (patch) | |
| tree | f89aafc8f9092ce913623c373c4063d81e7b7c49 /sketches/03 | |
| parent | ada4af0a94ba5723ec8366d9f75ef86f8650a512 (diff) | |
| parent | 67f58242d43caa9ab3f1530ef90a560343debc77 (diff) | |
| download | creative-coding-playground-dcd918162dcb4d70b905cc562ae92d98a10045ce.tar.gz creative-coding-playground-dcd918162dcb4d70b905cc562ae92d98a10045ce.zip | |
Merge branch 'main' of github.com:phenax/creative-coding-playground
Diffstat (limited to 'sketches/03')
| -rw-r--r-- | sketches/03/flow.frag | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/sketches/03/flow.frag b/sketches/03/flow.frag index 8402b2e..b878df9 100644 --- a/sketches/03/flow.frag +++ b/sketches/03/flow.frag @@ -17,21 +17,16 @@ bool is_between(vec2 pos, vec2 min, vec2 max) { 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); + vec2 pos = (v_position.xy + 1.)/2./vec2(1.0, ratio); float cell_size = 1.0/CELL_COUNT; + vec2 cell_pos = cell_size * abs(floor(pos / cell_size)); - 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); - } - } + gl_FragColor = vec4(0., 0., 0., 1.); + if (is_between(pos, cell_pos, cell_pos + 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); } } |
