Truncated Octahedron
Code Example
#define PHI (1.618033988749895)
#define _0 vec3(1, 0, 0)
#define _1 vec3(0, 1, 0)
#define _2 vec3(0, 0, 1)
#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 _(v) d = max(d, abs(dot(p, v)));
float truncatedOctahedronSDF(vec3 p, float r) {
float d = 0.;
_(_0) _(_1) _(_2) _(_3) _(_4) _(_5) _(_6)
return d - r;
}