aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LICENSE21
-rw-r--r--README.md1
-rw-r--r--sketches/03/flow.frag19
3 files changed, 29 insertions, 12 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..ba5b8af
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 Akshay Nair
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b6b6037
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# creative-coding-playground \ No newline at end of file
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);
}
}