Parameters
Name | Type | Description |
---|---|---|
position | vec3<f32> | 3D position to transform. |
normal | vec3<f32> | Normal vector of the mirror plane. |
offset | f32 | Distance offset of the mirror plane. |
Returns
vec3<f32>position.
WGSL Code
fn sdfMirror(position: vec3<f32>, normal: vec3<f32>, offset: f32) -> vec3<f32> {let n = normalize(normal);let d = dot(position, n) - offset;return position - 2.0 * max(0.0, d) * n;}