aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/shaders/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources/shaders/modules')
-rw-r--r--src/main/resources/shaders/modules/sdf.cs12
-rw-r--r--src/main/resources/shaders/modules/utils.cs4
2 files changed, 16 insertions, 0 deletions
diff --git a/src/main/resources/shaders/modules/sdf.cs b/src/main/resources/shaders/modules/sdf.cs
new file mode 100644
index 0000000..8121b18
--- /dev/null
+++ b/src/main/resources/shaders/modules/sdf.cs
@@ -0,0 +1,12 @@
+float sdf_circle(in vec3 p, in float radius) {
+ return length(p) - radius;
+}
+
+float sdf_plane(in vec3 p, in vec3 normal, in float offset) {
+ return dot(p, normal) + offset;
+}
+
+float sdf_box(in vec3 p, in vec3 dimens, in float rounding) {
+ vec3 q = abs(p) - dimens + rounding;
+ return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0) - rounding;
+}
diff --git a/src/main/resources/shaders/modules/utils.cs b/src/main/resources/shaders/modules/utils.cs
new file mode 100644
index 0000000..1616e8c
--- /dev/null
+++ b/src/main/resources/shaders/modules/utils.cs
@@ -0,0 +1,4 @@
+float smin(float a, float b, float k) {
+ float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);
+ return mix(b, a, h) - k * h * (1.0 - h);
+}