summaryrefslogtreecommitdiff
path: root/apps/web/src/lib/masks/shaders
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-03-27 00:55:15 +0100
committerMaze Winther <mazewinther@gmail.com>2026-03-29 15:56:48 +0200
commit4d127a038bf768eded68aae3cfa5c1b12241bdac (patch)
tree16bbb801caf6770546cff4fdb37b6408ec9ead98 /apps/web/src/lib/masks/shaders
parent82817cb50cb0487350573d6129130aec705f924b (diff)
downloadopencut-4d127a038bf768eded68aae3cfa5c1b12241bdac.tar.gz
chore: normalize line endings
Diffstat (limited to 'apps/web/src/lib/masks/shaders')
-rw-r--r--apps/web/src/lib/masks/shaders/jfa-distance.frag.glsl72
1 files changed, 36 insertions, 36 deletions
diff --git a/apps/web/src/lib/masks/shaders/jfa-distance.frag.glsl b/apps/web/src/lib/masks/shaders/jfa-distance.frag.glsl
index 4ba2c5a1..9d9a8773 100644
--- a/apps/web/src/lib/masks/shaders/jfa-distance.frag.glsl
+++ b/apps/web/src/lib/masks/shaders/jfa-distance.frag.glsl
@@ -1,36 +1,36 @@
-precision mediump float;
-
-uniform sampler2D u_texture;
-uniform sampler2D u_jfa_outside;
-uniform vec2 u_resolution;
-uniform float u_feather_half;
-
-varying vec2 v_texCoord;
-
-vec2 decodeSeed(vec4 encoded) {
- float x = floor(encoded.r * 255.0 + 0.5) * 256.0 + floor(encoded.g * 255.0 + 0.5);
- float y = floor(encoded.b * 255.0 + 0.5) * 256.0 + floor(encoded.a * 255.0 + 0.5);
- return vec2(x, y);
-}
-
-bool isNoSeed(vec4 encoded) {
- return encoded.r > 0.99 && encoded.g > 0.99 && encoded.b > 0.99 && encoded.a > 0.99;
-}
-
-void main() {
- vec2 pixelCoord = floor(v_texCoord * u_resolution);
-
- vec4 insideEncoded = texture2D(u_texture, v_texCoord);
- vec4 outsideEncoded = texture2D(u_jfa_outside, v_texCoord);
-
- bool hasInside = !isNoSeed(insideEncoded);
- bool hasOutside = !isNoSeed(outsideEncoded);
-
- float distToInside = hasInside ? distance(pixelCoord, decodeSeed(insideEncoded)) : 1e5;
- float distToOutside = hasOutside ? distance(pixelCoord, decodeSeed(outsideEncoded)) : 1e5;
-
- float signedDist = distToOutside - distToInside;
- float alpha = smoothstep(-u_feather_half, u_feather_half, signedDist);
-
- gl_FragColor = vec4(alpha, alpha, alpha, alpha);
-}
+precision mediump float;
+
+uniform sampler2D u_texture;
+uniform sampler2D u_jfa_outside;
+uniform vec2 u_resolution;
+uniform float u_feather_half;
+
+varying vec2 v_texCoord;
+
+vec2 decodeSeed(vec4 encoded) {
+ float x = floor(encoded.r * 255.0 + 0.5) * 256.0 + floor(encoded.g * 255.0 + 0.5);
+ float y = floor(encoded.b * 255.0 + 0.5) * 256.0 + floor(encoded.a * 255.0 + 0.5);
+ return vec2(x, y);
+}
+
+bool isNoSeed(vec4 encoded) {
+ return encoded.r > 0.99 && encoded.g > 0.99 && encoded.b > 0.99 && encoded.a > 0.99;
+}
+
+void main() {
+ vec2 pixelCoord = floor(v_texCoord * u_resolution);
+
+ vec4 insideEncoded = texture2D(u_texture, v_texCoord);
+ vec4 outsideEncoded = texture2D(u_jfa_outside, v_texCoord);
+
+ bool hasInside = !isNoSeed(insideEncoded);
+ bool hasOutside = !isNoSeed(outsideEncoded);
+
+ float distToInside = hasInside ? distance(pixelCoord, decodeSeed(insideEncoded)) : 1e5;
+ float distToOutside = hasOutside ? distance(pixelCoord, decodeSeed(outsideEncoded)) : 1e5;
+
+ float signedDist = distToOutside - distToInside;
+ float alpha = smoothstep(-u_feather_half, u_feather_half, signedDist);
+
+ gl_FragColor = vec4(alpha, alpha, alpha, alpha);
+}