summaryrefslogtreecommitdiff
path: root/assets/platform_f.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'assets/platform_f.glsl')
-rw-r--r--assets/platform_f.glsl2
1 files changed, 2 insertions, 0 deletions
diff --git a/assets/platform_f.glsl b/assets/platform_f.glsl
index 1969a46..82c8740 100644
--- a/assets/platform_f.glsl
+++ b/assets/platform_f.glsl
@@ -5,11 +5,13 @@ uniform float thickness;
void main() {
// thanks to https://www.youtube.com/watch?v=PMltMdi1Wzg
+ // (calculates distance to line segment p1-p2)
float h = clamp(dot(pos-p1, p2-p1) / dot(p2-p1, p2-p1), 0.0, 1.0);
float d = length(pos - p1 - (p2-p1) * h);
float v = max(thickness - d, 0.0);
v /= thickness;
+ v *= v;
gl_FragColor = color * v;
}