summaryrefslogtreecommitdiff
path: root/apps/web/src/lib/shaders/jfa-init.frag.glsl
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-03-25 16:47:22 +0100
committerMaze Winther <mazewinther@gmail.com>2026-03-29 15:48:22 +0200
commit8db3bead13441a5882d8689dfc6a9f09c82375d9 (patch)
treee9d0cafa93904ffcbec3188c37961bcc16c6422d /apps/web/src/lib/shaders/jfa-init.frag.glsl
parent39ea298a9ccba3104c549c0ca079c231981811f5 (diff)
downloadopencut-8db3bead13441a5882d8689dfc6a9f09c82375d9.tar.gz
feat: masks, properties refactor, shaders, storage migrations, and more
Diffstat (limited to 'apps/web/src/lib/shaders/jfa-init.frag.glsl')
-rw-r--r--apps/web/src/lib/shaders/jfa-init.frag.glsl25
1 files changed, 25 insertions, 0 deletions
diff --git a/apps/web/src/lib/shaders/jfa-init.frag.glsl b/apps/web/src/lib/shaders/jfa-init.frag.glsl
new file mode 100644
index 00000000..d199d234
--- /dev/null
+++ b/apps/web/src/lib/shaders/jfa-init.frag.glsl
@@ -0,0 +1,25 @@
+precision mediump float;
+
+uniform sampler2D u_texture;
+uniform vec2 u_resolution;
+uniform float u_invert;
+
+varying vec2 v_texCoord;
+
+void main() {
+ float mask = texture2D(u_texture, v_texCoord).r;
+ bool isSeed = u_invert > 0.5 ? mask < 0.5 : mask > 0.5;
+
+ if (isSeed) {
+ vec2 pixelCoord = floor(v_texCoord * u_resolution);
+ float x = pixelCoord.x;
+ float y = pixelCoord.y;
+ float xHi = floor(x / 256.0);
+ float xLo = x - xHi * 256.0;
+ float yHi = floor(y / 256.0);
+ float yLo = y - yHi * 256.0;
+ gl_FragColor = vec4(xHi / 255.0, xLo / 255.0, yHi / 255.0, yLo / 255.0);
+ } else {
+ gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
+ }
+}