Parameters
| Name | Type | Description |
|---|---|---|
| position | vec3<f32> | 3D position to evaluate. |
| size | f32 | Size of the icosahedron. |
Returns
WGSL Code
fn sdfIcosahedron(position: vec3<f32>, size: f32) -> f32 { var p = position; let s = size; // Constants for icosahedron let phi = 1.618033988749895; let a = s; let b = s * phi; // Compute distance to icosahedron p = abs(p / s); let d = p.x * p.y * p.z; let m = max(max(p.x, p.y), p.z); let n = min(min(p.x, p.y), p.z); let mid = p.x + p.y + p.z - m - n; // Calculate the signed distance let q = select(mid, d, m < phi * n); return (length(p) - phi) * s; }