# Metaballs

In computer graphics, metaballs are organic-looking n-dimensional isosurfaces, characterised by their ability to meld together when in close proximity to create single, contiguous objects. This "blobby" appearance makes them versatile tools, often used to model organic objects and also to create base meshes for sculpting.[1] The technique for rendering metaballs was invented by Jim Blinn in the early 1980s to model atom interactions for Carl Sagan's 1980 TV series Cosmos.[2] It is also referred to colloquially as the "jelly effect" in the motion and UX design community,[3] commonly appearing in UI elements such as navigations and buttons. Metaball behavior corresponds to mitosis in cell biology, where chromosomes generate identical copies of itself through cell division.

1: The influence of 2 positive metaballs on each other.
2: The influence of a negative metaball on a positive metaball by creating an indentation in the positive metaball's surface.

## Definition

Each metaball is defined as a function in n dimensions (e.g., for three dimensions, ${\displaystyle f(x,y,z)}$ ; three-dimensional metaballs tend to be most common, with two-dimensional implementations popular as well). A thresholding value is also chosen, to define a solid volume. Then,

${\displaystyle \sum _{i=0}^{m}{\mbox{metaball}}_{i}(x,y,z)\leq {\mbox{threshold}}}$

represents whether the volume enclosed by the surface defined by ${\displaystyle m}$  metaballs is filled at ${\displaystyle (x,y,z)}$  or not.

## Implementation

The interaction between two differently coloured 3D positive metaballs, created in Bryce.
Note that the two smaller metaballs combine to create one larger object.

A typical function chosen for metaballs is the inverse-square law, that is the contribution to the thresholding function falls off in a bell as the distance from the centre of the metaball increases.

For the three dimensional case ${\displaystyle f(x,y,z)=1/{\sqrt {(x-x_{0})^{2}+(y-y_{0})^{2}+(z-z_{0})^{2}}}}$ , where ${\displaystyle (x_{0},y_{0},z_{0})}$  is the center of the metaball. However, due to the division, it is computationally expensive. For this reason, approximate polynomial functions are typically used.[citation needed]

When seeking a more efficient falloff function, several qualities are desired:

• Finite support. A function with finite support goes to zero at a maximum radius. When evaluating the metaball field, any points beyond their maximum radius from the sample point can be ignored. Nearest neighbor search can ensure only adjacent metaballs need to be evaluated regardless of the total number in the field.
• Smoothness. Because the isosurface is the result of adding the fields together, its smoothness is dependent on the smoothness of the falloff curves.

The simplest falloff curve that satisfies these criteria is ${\displaystyle f(r)=(1/r^{2})^{2}}$ , where r is the distance to the point. This formulation avoids expensive square root calls.

More complicated models use a Gaussian potential constrained to a finite radius or a mixture of polynomials to achieve smoothness. The Soft Object model by the Wyvill brothers provides higher degree of smoothness and still avoids square roots.[citation needed]

A simple generalization of metaballs is to apply the falloff curve to distance-from-lines or distance-from-surfaces.

There are a number of ways to render the metaballs to the screen. In the case of three dimensional metaballs, the two most common are brute force raycasting and the marching cubes algorithm.

2D metaballs were a very common demo effect in the 1990s. The effect is also available as an XScreensaver module.

## References

1. ^ https://artofjoe.blogspot.com/2007/10/digital-sculpting-tutorial.html
2. ^ http://steve.hollasch.net/cgindex/misc/metaballs.html
3. ^ "The "jelly effect" has recently been very popular and used in lots of animations. … | After effect tutorial, Adobe after effects tutorials, Motion graphics tutorial". Pinterest. Retrieved 2020-08-11.