summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-04-10 15:31:28 -0700
committeryum <yum.food.vr@gmail.com>2026-04-10 15:31:28 -0700
commit132f7a2ec9f69bfb05a8f8b64715eeb3fad75adc (patch)
tree0973e4836947648c1fe76b1670ec1b5c050d592a
parent34f3001c0ae2ac20ad02f02434a2e13c50c8b6d8 (diff)
check in quilez.cginc
-rw-r--r--quilez.cginc22
1 files changed, 22 insertions, 0 deletions
diff --git a/quilez.cginc b/quilez.cginc
new file mode 100644
index 0000000..ecfca9b
--- /dev/null
+++ b/quilez.cginc
@@ -0,0 +1,22 @@
+#ifndef __QUILEZ_INC
+#define __QUILEZ_INC
+
+// The MIT License
+// Copyright © 2019-2024 Inigo Quilez
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+float distance_from_hex_prism(float3 p, float2 h)
+{
+ float3 q = abs(p);
+
+ const float3 k = float3(-0.8660254, 0.5, 0.57735);
+ p = abs(p);
+ p.xy -= 2.0*min(dot(k.xy, p.xy), 0.0)*k.xy;
+ float2 d = float2(
+ length(p.xy - float2(clamp(p.x, -k.z*h.x, k.z*h.x), h.x))*sign(p.y - h.x),
+ p.z-h.y );
+ return min(max(d.x,d.y),0.0) + length(max(d,0.0));
+}
+
+#endif // _QUILEZ_INC
+