lygia
/v1.1.6
/sdf
/boxFrameSDF
)generate the SDF of a bounding box
Use:
<float> boxFrameSDF( <vec3> p, <vec3> b, <float> e )
#ifndef FNC_BOXFRAMESDF
#define FNC_BOXFRAMESDF
float boxFrameSDF( vec3 p, vec3 b, float e ) {
p = abs(p) - b;
vec3 q = abs(p + e) - e;
return min(min(
length(max(vec3(p.x,q.y,q.z),0.0))+min(max(p.x,max(q.y,q.z)),0.0),
length(max(vec3(q.x,p.y,q.z),0.0))+min(max(q.x,max(p.y,q.z)),0.0)),
length(max(vec3(q.x,q.y,p.z),0.0))+min(max(q.x,max(q.y,p.z)),0.0));
}
#endif
Use:
<float> boxFrameSDF( <float3> p, <float3> b, <float> e )
#ifndef FNC_BOXFRAMESDF
#define FNC_BOXFRAMESDF
float boxFrameSDF( float3 p, float3 b, float e ) {
p = abs(p) - b;
float3 q = abs(p + e) - e;
return min(min(
length(max(float3(p.x,q.y,q.z),0.0))+min(max(p.x,max(q.y,q.z)),0.0),
length(max(float3(q.x,p.y,q.z),0.0))+min(max(q.x,max(p.y,q.z)),0.0)),
length(max(float3(q.x,q.y,p.z),0.0))+min(max(q.x,max(q.y,p.z)),0.0));
}
#endif
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository