summaryrefslogtreecommitdiffstats
path: root/math.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-03-24 00:16:32 -0700
committeryum <yum.food.vr@gmail.com>2026-03-24 00:16:32 -0700
commite19bf2d07048bf1b6a9c636380c52f44336c81e8 (patch)
tree0a70e23ff0410dd3f331e05d4163c36ffc3f0d53 /math.cginc
parent51930cd07ac1a17a05b9848ac8d6639170b3d571 (diff)
Pull in letter grid gimmick from 2ner
Diffstat (limited to 'math.cginc')
-rwxr-xr-xmath.cginc9
1 files changed, 9 insertions, 0 deletions
diff --git a/math.cginc b/math.cginc
index fa38553..c2ae26e 100755
--- a/math.cginc
+++ b/math.cginc
@@ -240,4 +240,13 @@ float voronoi_edge_distance(float3 x) {
return (d2 - d1) / (2.0 * max(1e-4, length(p2 - p1)));
}
+float median(float3 x) {
+ // Get the min and max.
+ float x_min= min(min(x.r, x.g), x.b);
+ float x_max = max(max(x.r, x.g), x.b);
+
+ // Compute (x.r + x.g + x.b) - (x_min + x_max). This gives us the median.
+ return (x.r + x.g + x.b) - (x_min + x_max);
+}
+
#endif // __MATH_INC