🔧 Tweak effect

This commit is contained in:
Simon Schneegans
2022-01-24 11:15:17 +01:00
parent 9b59dd942c
commit 638613a190
3 changed files with 42 additions and 9 deletions
+18
View File
@@ -33,6 +33,24 @@ function standardUniforms() {
`;
}
function math2D() {
return `
float distToLine(vec2 origin, vec2 direction, vec2 point) {
vec2 perpendicular = vec2(direction.y, -direction.x);
return abs(dot(normalize(perpendicular), origin - point));
}
float getWinding(vec2 a, vec2 b) {
return cross(vec3(a, 0.0), vec3(b, 0.0)).z;
}
vec2 rotate(vec2 a, float angle) {
return vec2(a.x * cos(angle) - a.y * sin(angle),
a.x * sin(angle) + a.y * cos(angle));
}
`;
}
// This method returns a mask which smoothly transitions towards zero when approaching
// the window's borders. There is a variant which takes the transition area width in
// pixels and one which takes this as a percentage.