Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.