lygia
/sdf
/tetrahedronSDF
)generate the SDF of a tetrahedron
Use:
<float> tetrahedronSDF( in <vec3> pos, in <float> h )
#ifndef FNC_TETRAHEDRONSDF
#define FNC_TETRAHEDRONSDF
float tetrahedronSDF(vec3 p, float h) {
vec3 q = abs(p);
float y = p.y;
float d1 = q.z-max(0.,y);
float d2 = max(q.x*.5 + y*.5,.0) - min(h, h+y);
return length(max(vec2(d1,d2),.005)) + min(max(d1,d2), 0.0);
}
#endif
Use:
<float> tetrahedronSDF( in <float3> pos, in <float> h )
#ifndef FNC_TETRAHEDRONSDF
#define FNC_TETRAHEDRONSDF
float tetrahedronSDF(float3 p, float h) {
float3 q = abs(p);
float y = p.y;
float d1 = q.z-max(0.,y);
float d2 = max(q.x*.5 + y*.5,.0) - min(h, h+y);
return length(max(float2(d1,d2),.005)) + min(max(d1,d2), 0.0);
}
#endif
Use:
<float> tetrahedronSDF( <float3> pos, <float> h )
#ifndef FNC_TETRAHEDRONSDF
#define FNC_TETRAHEDRONSDF
float tetrahedronSDF(float3 p, float h) {
float3 q = abs(p);
float y = p.y;
float d1 = q.z-max(0.,y);
float d2 = max(q.x*.5 + y*.5,.0) - min(h, h+y);
return length(max(float2(d1,d2),.005)) + min(max(d1,d2), 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