Skip to main content

Octahedron

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 _(v) d = max(d, abs(dot(p, v)));
float octahedronSDF(vec3 p, float r) {
        float d = 0.;
        _(_3) _(_4) _(_5) _(_6)
        return d - r;
}

More