Icosahedron
Code Example
#define PHI (1.618033988749895)
#define _3 normalize(vec3(1, 1, 1 ))
#define _4 normalize(vec3(-1, 1, 1))
#define _5 normalize(vec3(1, -1, 1))
#define _6 normalize(vec3(1, 1, -1))
#define _7 normalize(vec3(0, 1, PHI + 1.))
#define _8 normalize(vec3(0, -1, PHI + 1.))
#define _9 normalize(vec3(PHI + 1., 0, 1))
#define _10 normalize(vec3(-PHI - 1., 0, 1))
#define _11 normalize(vec3(1, PHI + 1., 0))
#define _12 normalize(vec3(-1, PHI + 1., 0))
#define _(v) d = max(d, abs(dot(p, v)));
float icosahedronSDF(vec3 p, float r) {
float d = 0.;
_(_3) _(_4) _(_5) _(_6)
_(_7) _(_8) _(_9) _(_10)
_(_11) _(_12)
return d - r;
}
More