From 132f7a2ec9f69bfb05a8f8b64715eeb3fad75adc Mon Sep 17 00:00:00 2001 From: yum Date: Fri, 10 Apr 2026 15:31:28 -0700 Subject: check in quilez.cginc --- quilez.cginc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 quilez.cginc 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 + -- cgit v1.2.3