smooth_join_2d

command
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2022 License: BSD-2-Clause Imports: 5 Imported by: 0

README

smooth_join_2d

This is a set of experiments for computing smooth unions of SDFs. I test both SmoothJoin() and SmoothJoinV2(), and show that the latter works better than the conventional algorithm used by the former.

Originally, I had implemented SmoothJoin() using the algorithm described in this blog post which is prevalent throughout the SDF literature. This algorithm appears to work for well-behaved examples, but has some rough edges.

For example, using the classic smooth SDF union algorithm, we can combine a square and a circle smoothly like so:

A square and a circle combined smoothly. This works well because the square intersects the circle at nearly right angles. What happens if we shrink the square along one dimension to make it intersect the circle at an obtuse angle, like so?

A rectangle intersecting a circle

In this case, the above algorithm breaks down and produces a weird "lump":

A bad smooth union of a rectangle and a circle

The issue is that this algorithm doesn't take into account the normals of the two SDFs at the intersection point, so it doesn't work when two SDFs are nearly parallel at the intersection. In the most degenerate case, we could apply the smooth join algorithm to take the union of a shape and itself, which would end up producing a slightly expanded version of the original shape (whereas it should simply be a no-op).

My SmoothJoinV2() method takes normals of SDFs into account. This allows us to do the same smoothing algorithm that works well for right angles, while preventing weird lumps at obtuse angles:

A better smoothed intersection of a union and a rectangle

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL