summaryrefslogtreecommitdiff
path: root/src/mbgl/shader/linejoin.fragment.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/shader/linejoin.fragment.glsl')
-rw-r--r--src/mbgl/shader/linejoin.fragment.glsl14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mbgl/shader/linejoin.fragment.glsl b/src/mbgl/shader/linejoin.fragment.glsl
new file mode 100644
index 0000000000..705a57766e
--- /dev/null
+++ b/src/mbgl/shader/linejoin.fragment.glsl
@@ -0,0 +1,14 @@
+uniform vec4 u_color;
+uniform vec2 u_linewidth;
+
+varying vec2 v_pos;
+
+void main() {
+ float dist = length(v_pos - gl_FragCoord.xy);
+
+ // Calculate the antialiasing fade factor. This is either when fading in
+ // the line in case of an offset line (v_linewidth.t) or when fading out
+ // (v_linewidth.s)
+ float alpha = clamp(min(dist - (u_linewidth.t - 1.0), u_linewidth.s - dist), 0.0, 1.0);
+ gl_FragColor = u_color * alpha;
+}