Parameters
Name | Type | Description |
---|---|---|
position | vec3<f32> | 3D position to transform. |
amount | f32 | Taper amount (0 = no taper, 1 = full taper). |
axis | vec3<f32> | Taper axis direction. |
height | f32 | Height over which to apply the taper. |
offset | f32 | Offset along the taper axis. |
Returns
vec3<f32>position.
WGSL Code
fn sdfTaper(position: vec3<f32>, amount: f32, axis: vec3<f32>, height: f32, offset: f32) -> vec3<f32> {let axisNorm = normalize(axis);// Project position onto the taper axislet axisPos = dot(position, axisNorm) - offset;// Calculate taper factor based on position along axislet t = clamp(axisPos / height, 0.0, 1.0);let taperFactor = 1.0 - amount * t;// Apply taper to the perpendicular componentslet axisComponent = axisPos * axisNorm;let perpComponent = position - dot(position, axisNorm) * axisNorm;return axisComponent + perpComponent * taperFactor;}