summaryrefslogtreecommitdiff
path: root/common/shaders/sdf_primitives.wgsl
diff options
context:
space:
mode:
Diffstat (limited to 'common/shaders/sdf_primitives.wgsl')
-rw-r--r--common/shaders/sdf_primitives.wgsl5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/shaders/sdf_primitives.wgsl b/common/shaders/sdf_primitives.wgsl
index 31bbe2d..407fb29 100644
--- a/common/shaders/sdf_primitives.wgsl
+++ b/common/shaders/sdf_primitives.wgsl
@@ -12,3 +12,8 @@ fn sdTorus(p: vec3<f32>, t: vec2<f32>) -> f32 {
fn sdPlane(p: vec3<f32>, n: vec3<f32>, h: f32) -> f32 {
return dot(p, n) + h;
}
+
+fn sdBox2D(p: vec2<f32>, b: vec2<f32>) -> f32 {
+ let d = abs(p) - b;
+ return length(max(d, vec2<f32>(0.0))) + min(max(d.x, d.y), 0.0);
+}