Smooth Min
Regular min(a, b) produces a sharp crease where two shapes meet. smin (smooth minimum) blends two distance fields with a curve so shapes melt together:
min vs smin
min(d1, d2) picks the smaller distance — at the boundary where two circles meet, the distance field has a discontinuous fold, producing a hard corner in the rendered shape.
smin(d1, d2, k) smoothly mixes the two distance fields when shapes are near each other. The junction becomes a rounded connection, like pressing two pieces of clay together.
The third parameter k controls blend range
With k = 0.2, blending happens within about 0.2 units of where the shapes meet. Larger k means a wider, softer blend zone. As k approaches 0, the result approaches plain min.
What is in the scene
The canvas has two circular SDFs (signed distance fields) centered at (-0.12, 0) and (0.12, 0), both with radius 0.18. They slightly overlap. With min, the junction has a hard crease. With smin, the two circles merge like water droplets.
Try changing it
| Change | Effect |
|---|---|
0.2 → 0.05 | Narrow blend zone, almost the same as hard min |
0.2 → 0.5 | Very wide blend, circles strongly pulled together |
Circle separation 0.24 → 0.4 | Circles no longer overlap; smin still creates subtle merging near the gap |
Radius 0.18 → 0.12 | Smaller circles with a visible gap between them |
Exercise
Change float d = min(d1, d2); to use smin so the two circles merge smoothly.
Answer Breakdown
Starting state: min(d1, d2) produces a sharp corner at the junction — the two distance fields meet with no transition.
The fix: smin(d1, d2, 0.2) introduces a smooth blend curve within roughly 0.2 units of where the shapes meet. The distance field becomes continuous at the junction, and the rendered shape looks like two droplets merging.
Try changing k to 1.0 to see the entire shape soften into a single rounded blob with a very large blend zone.