lygia
/sdf
/dodecahedronSDF
)generate the SDF of a dodecahedron
Dependencies:
Use:
<float> dodecahedronSDF( in <vec3> pos [, in <float> size] )
#ifndef FNC_DODECAHEDRONSDF
#define FNC_DODECAHEDRONSDF
float dodecahedronSDF(vec3 p) {
vec3 n = normalize(vec3(PHI,1.0,0.0));
p = abs(p);
float a = dot(p,n.xyz);
float b = dot(p,n.zxy);
float c = dot(p,n.yzx);
// return max(max(a,b),c)-PHI*n.y;
return (max(max(a,b),c)-n.x);
}
float dodecahedronSDF(vec3 p, float radius) {
vec3 n = normalize(vec3(PHI,1.0,0.0));
p = abs(p / radius);
float a = dot(p, n.xyz);
float b = dot(p, n.zxy);
float c = dot(p, n.yzx);
return (max(max(a,b),c)-n.x) * radius;
}
#endif
Dependencies:
Use:
<float> dodecahedronSDF( in <float3> pos [, in <float> size] )
#ifndef FNC_DODECAHEDRONSDF
#define FNC_DODECAHEDRONSDF
float dodecahedronSDF(float3 p) {
float3 n = normalize(float3(PHI,1.0,0.0));
p = abs(p);
float a = dot(p,n.xyz);
float b = dot(p,n.zxy);
float c = dot(p,n.yzx);
// return max(max(a,b),c)-PHI*n.y;
return (max(max(a,b),c)-n.x);
}
float dodecahedronSDF(float3 p, float radius) {
float3 n = normalize(float3(PHI,1.0,0.0));
p = abs(p / radius);
float a = dot(p, n.xyz);
float b = dot(p, n.zxy);
float c = dot(p, n.yzx);
return (max(max(a,b),c)-n.x) * radius;
}
#endif
Dependencies:
Use:
<float> dodecahedronSDF( <float3> pos [, <float> size] )
#ifndef FNC_DODECAHEDRONSDF
#define FNC_DODECAHEDRONSDF
float dodecahedronSDF(float3 p) {
float3 n = normalize(float3(PHI,1.0,0.0));
p = abs(p);
float a = dot(p,n.xyz);
float b = dot(p,n.zxy);
float c = dot(p,n.yzx);
// return max(max(a,b),c)-PHI*n.y;
return (max(max(a,b),c)-n.x);
}
float dodecahedronSDF(float3 p, float radius) {
float3 n = normalize(float3(PHI,1.0,0.0));
p = abs(p / radius);
float a = dot(p, n.xyz);
float b = dot(p, n.zxy);
float c = dot(p, n.yzx);
return (max(max(a,b),c)-n.x) * radius;
}
#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