Initializing 3D Canvas...

Sdf Blending

2 min read1 page

Blending combines multiple SDF primitives into organic shapes. Unlike hard boolean operations, blending smoothly interpolates between distance fields using weight functions.

SDF Blending:

1. Evaluate multiple SDFs at each query point. 2. Combine using weighted interpolation functions. 3. Result produces smooth, organic transitions at boundaries.
python
1# SDF Blending concept
2# Unlike boolean operations (hard min/max), blending
3# creates smooth organic transitions between shapes.
4
5def blend_linear(d1, d2, t):
6 """Linear interpolation: simplest blend."""
7 return d1 * (1.0 - t) + d2 * t
8
9# Smooth blending is essential for organic modeling,
10# metaballs, character modeling, and procedural shapes.
1 min read1 page

The exponential smooth min uses log-sum-exp to create smooth transitions. Parameter k controls the sharpness of the blend.

Exponential Blend:

1. Compute exp(-k * d) for each SDF. 2. Sum the exponentials and take negative log. 3. Divide by k. Higher k approaches hard min.
python
1# Exponential smooth minimum
2import math
3
4def exp_smooth_min(d1, d2, k=32):
5 """Exponential smooth min blending."""
6 e1 = math.exp(-k * d1)
7 e2 = math.exp(-k * d2)
8 return -math.log(e1 + e2) / k
9
10# Higher k values produce sharper transitions.
11# Lower k values produce wider, softer blends.
Sharpness (k)
8.00
2 min read1 page

Polynomial smooth min uses cubic interpolation for smoother C1 continuous transitions. The blend radius k controls the width.

Polynomial Blend:

1. Compute blending factor h from distance difference. 2. Apply cubic correction: h^3 * k / 6. 3. Produces smoother results than quadratic blending.
python
1# Polynomial smooth minimum (cubic)
2def poly_smooth_min(d1, d2, k):
3 """Polynomial smooth min with blend radius k."""
4 h = max(k - abs(d1 - d2), 0.0) / k
5 return min(d1, d2) - h * h * h * k * (1.0 / 6.0)
6
7# Cubic version of smooth min. The h^3 term
8# produces a smoother C1 continuous transition
9# compared to the quadratic h^2 variant.
Blend Radius (k)
2.00
2 min read1 page

Weighted blending assigns per-primitive influence weights. Each SDF contribution is scaled by its normalized weight.

Weight Blend:

1. Assign weight to each SDF primitive. 2. Normalize weights to sum to 1. 3. Output is weighted sum of SDF values.
python
1# Weighted blend of multiple SDFs
2def blend_weighted(sdfs, weights):
3 """Blend N distance fields with per-field weights."""
4 total_w = sum(weights)
5 result = 0.0
6 for sdf_val, w in zip(sdfs, weights):
7 result += sdf_val * (w / total_w)
8 return result
9
10# Weights control each primitive's contribution.
11# Higher weight makes that primitive dominate.
Weight A
0.50
2 min read1 page

When blending SDFs, material properties like color can be interpolated using the same blend factor, creating smooth color gradients at the junction.

Color Blend:

1. Compute SDF blend factor from distance difference. 2. Use same factor to interpolate between material A and B colors. 3. Smooth color transition matches the geometric blend.
python
1# Color interpolation alongside SDF blending
2def blend_with_color(sdf_a, sdf_b, color_a, color_b, k):
3 """Blend SDFs and interpolate colors in blend region."""
4 h = max(k - abs(sdf_a - sdf_b), 0.0) / k
5 blended_dist = min(sdf_a, sdf_b) - h*h*k*0.25
6 # Interpolate color using same blend factor
7 t = 0.5 + 0.5 * (sdf_b - sdf_a) / (k + 1e-6)
8 t = max(0, min(1, t))
9 color = lerp(color_a, color_b, t)
10 return blended_dist, color
Blend Radius
2.00
2 min read1 page

Linear interpolation between two SDFs creates a smooth morph. At t=0 the shape is entirely A, at t=1 entirely B, and in between a smooth transition occurs.

SDF Morph:

1. Evaluate both SDFs at query point. 2. Linearly interpolate: d = dA*(1-t) + dB*t. 3. Animate t from 0 to 1 for morphing animation.
python
1# Shape morphing via linear SDF interpolation
2def sdf_morph(sdf_a, sdf_b, point, t):
3 """Morph between two shapes by interpolating SDFs."""
4 da = sdf_a(point)
5 db = sdf_b(point)
6 return da * (1.0 - t) + db * t
7
8# t=0 gives shape A, t=1 gives shape B,
9# intermediate values create smooth transitions.
Morph Factor (t)
0.50
2 min read1 page

Applying smooth blending to the Stanford Bunny point cloud with a sphere primitive demonstrates organic shape fusion in practice.

Bunny Blend:

1. Sample bunny SDF from point cloud approximation. 2. Evaluate sphere SDF at same locations. 3. Apply smooth min to fuse both shapes organically.
python
1# Organic blending applied to Stanford Bunny
2# Blend bunny point cloud with a sphere SDF
3def blend_bunny_sphere(bunny_sdf, sphere_center, sphere_r, k):
4 """Smooth union of bunny SDF with a sphere."""
5 for each point P in space:
6 d_bunny = bunny_sdf(P)
7 d_sphere = length(P - sphere_center) - sphere_r
8 d = smooth_min(d_bunny, d_sphere, k)
9 # Extract zero isosurface of blended field
Sphere Radius
3.00