Jeff Hube

Metaballs

This 2D metaball implementation uses point sprites. It maps density and time to uv coordinates of a texture, which allows for neat effects and animations.

Implementation (C++/OpenGL)

For the first pass, the metaballs are drawn as point sprites using additive blending. The texture for the point sprite generated using the formula 1/r^2, where r is the distance from the center of the texture. The second pass uses the values from the first pass and the current time as UV coordinates to sample a texture. This creates a mapping from density to color that can optionally be varied based on time. The textures are generated procedurally.

Media