メインコンテンツまでスキップ

Dodecahedron

Code Example

#define PHI (1.618033988749895)
#define _13 normalize(vec3(0, PHI, 1))
#define _14 normalize(vec3(0, -PHI, 1))
#define _15 normalize(vec3(1, 0, PHI))
#define _16 normalize(vec3(-1, 0, PHI))
#define _17 normalize(vec3(PHI, 1, 0))
#define _18 normalize(vec3(-PHI, 1, 0))
#define _(v) d = max(d, abs(dot(p, v)));
float dodecahedronSDF(vec3 p, float r) {
        float d = 0.;
        _(_13) _(_14) _(_15) _(_16)
        _(_17) _(_18)
        return d - r;
}

More