liveBook · Manning

Metaball

As explained in Geometry for Programmers

A metaball is a smooth implicit-shape blending technique that combines field contributions from multiple centers to produce organic-looking forms.

A metaball blends field contributions from several centers into one smooth, organic-looking shape. In 3D, merged balls resemble a soft form with continuous borders; the same idea can glue different SDF-based shapes together. section 10.3.3 section 10.0

The common construction averages inverse distances to the centers, then applies an offset controlling thickness. Three points and one offset are enough to produce a complete shape. section 10.3.3

Useful extensions make the technique more expressive and practical:

  • Blend metarectangles, metasegments, balls, or other SDFs into one smooth organic form. section 10.3.3
  • Replace the unlimited inverse with a quasi-inverse that becomes zero beyond a chosen range, making each metaball local. section 10.3.4
  • Gather nearby centers instead of evaluating every distance; neighbor lookup is described as O(log(n)) rather than the O(N) cost of collecting all distances. section 10.3.4

Three-point metaball

Set balls = [(-6, -5), (9, -8), (0, 9)] and offset = -1.25, then compute the normalized sum of inverse point-to-center distances. The resulting contour forms one smooth shape from three inputs. section 10.3.3

balls = [(-6, -5), (9, -8), (0, 9)]   #1
offset = -1.25                        #2
SDF = (1.
      / sum([1 / distance_p2p(X, Y, ball[0], ball[1]) for ball in balls])
      / len(balls)
      + offset)                       #3

The listing makes the centers, normalization, inverse-distance accumulation, and thickness offset directly inspectable. section 10.3.3

How Geometry for Programmers covers it

How deep it goes
Derives an inverse-distance formula, demonstrates Python computation, and adds localized evaluation for efficiency.
Examples
Demonstrates three balls, metarectangles, metasegments, mixed shapes, and a quasi-inverse with adjustable locality.
What it assumes
Assumes familiarity with distance-based shape functions and introduces metaball blending through geometric intuition and formulas.
What you can do after
Build it from scratch with center points and an offset, then optimize evaluation using a localized quasi-inverse.
How it connects
Connects metaballs to signed distance functions, offsets, primitive shapes, and organic geometry.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Geometry for Programmers. The section links point to the parts of the book it draws on.