Parameters
Name | Type | Description |
---|---|---|
position | vec3<f32> | 3D position to evaluate. |
size | vec3<f32> | Half-extents of the box. |
radius | f32 | Rounding radius for the edges. |
Returns
WGSL Code
fn sdfRoundBox(position: vec3<f32>, size: vec3<f32>, radius: f32) -> f32 {let q = abs(position) - size;return length(max(q, vec3<f32>(0.0))) +min(max(q.x, max(q.y, q.z)), 0.0) -radius;}