Created
July 4, 2017 07:37
-
-
Save Chlumsky/693a5d9cfe324d8d113a493385c52a4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
glsl { | |
// Signed distance from half-plane defined by oriented line segment (a, b) | |
float halfPlaneDistance(vec2 pos, vec2 a, vec2 b) { | |
return dot(normalize(vec2(b.y-a.y, a.x-b.x)), a-pos); | |
} | |
// Anti-aliased half-plane defined by oriented line segment (a, b) | |
float halfPlaneSmooth(vec2 pos, vec2 a, vec2 b, float border) { | |
return clamp(halfPlaneDistance(pos, a, b)/border+0.5, 0.0, 1.0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment