Parameters
Name | Type | Description |
---|---|---|
position | vec3<f32> | 3D position to evaluate. |
radius | f32 | Radius of the cylinder. |
height | f32 | Height of the cylinder. |
Returns
WGSL Code
fn sdfCylinder(position: vec3<f32>, radius: f32, height: f32) -> f32 {let d = vec2<f32>(length(position.xz), abs(position.y)) - vec2<f32>(radius, height * 0.5);return min(max(d.x, d.y), 0.0) + length(max(d, vec2<f32>(0.0)));}