diff --git a/client/webgl_shaders.js b/client/webgl_shaders.js index a1c9131..d42f1a4 100644 --- a/client/webgl_shaders.js +++ b/client/webgl_shaders.js @@ -197,23 +197,8 @@ const sdf_fs_src = `#version 300 es vec2 b = v_line.zw; vec2 pa = v_texcoord - a.xy, ba = b.xy - a.xy; - float h = dot(pa, ba) / dot(ba, ba); - /* - float dist = length(pa - ba * h) - v_thickness.y / 2.0; - */ - - float dist; - float r1 = v_thickness.x; - float r2 = v_thickness.y; - - if (h < 0.0) { - dist = length(v_texcoord - a) - r1; - } else if (0.0 <= h && h < 1.0) { - vec2 Q = a + ba * h; - dist = length(v_texcoord - Q) - (r1 + (r2 - r1) * length(Q - a) / length(ba)); - } else { - dist = length(v_texcoord - b) - r2; - } + float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0); + float dist = length(v_texcoord - (a + ba * h)) - mix(v_thickness.x, v_thickness.y, h); float fade = 0.5 * length(fwidth(v_texcoord)); float alpha = 1.0 - smoothstep(-fade, fade, dist);