Smooth union. Joins two SDFs together smoothly
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | d1 |
SDF_1 distance |
||
real(kind=wp), | intent(in) | :: | d2 |
SDF_2 distance |
||
real(kind=wp), | intent(in) | :: | k |
smoothing factor. |
pure function SmoothUnion(d1, d2, k) result(res) !! Smooth union. Joins two SDFs together smoothly !> SDF_1 distance real(kind=wp), intent(IN) :: d1 !> SDF_2 distance real(kind=wp), intent(IN) :: d2 !> smoothing factor. real(kind=wp), intent(IN) :: k real(kind=wp) :: res, h h = max(k - abs(d1 - d2), 0._wp) / k res = min(d1, d2) - h*h*h*k*(1._wp/6._wp) end function SmoothUnion