Blobs

paradox/vivid

Hey all. Ever wondered how/why blob effects work? This is a tutorial about blobs. I think the proper name is "metaballs" (from the Greek "meta" meaning like or similar), but I'll just call them blobs for now.

For the moment, forget you're a computer programmer (this is what works for me :)) and think totally abstractly, the following explanation is how I think people thought up the blob effect (from the real world, electromagnetics I think).

Suppose we have a space of points, and that we have what we call a potential associated with each point, the potential at a point is just a scalar. Now suppose we have a set of potential sources, which are special points in our space which contribute a potential to every point in the space. It doesn't matter what the potentials they contribute really are, just that they are there for every point in the space. We introduce a potential function, and this is any decreasing function of the distance from a potential source. The total potential for a point p is defined as:

t(p) = S P(i){p}

Where t(p) is the total potential at point p, P(i){p} means the potential on the point p exerted by potential source number i and we are summing over all potential sources in the space. p can be a point of any dimensionality, e.g. p = (x, y, z) or p = (x, y) for 3d or 2d respectively.

Suppose we calculate the total potential for every point in our space, and if the potential on a particular point is greater than some constant, c, then we plot that point (a slight variation on this is to only plot points which have potential exactly c, as is done in 3D).

Ok, that was pretty abstract from computing, but that is exactly how blobs are done. The only thing left to do is to choose a potential function, the simplest (and probably best) one is: 1 / d^2 where d is the distance of a point from a potential source. I said any decreasing function, but if you choose something crazy like 1 / d^500, you won't get blobs - probably just dots.

Let's think about what our plot should look like, in 2d. Think about points which are just outside the circle which is being drawn, their potential is only just too small to be considered part of the blob, call these points JOP (Just Outside Points), so, when another blob gets close enough to it, the JOP's potential will be increased by a small amount, making them be included in the surface. Here's a diagram of how blobs look:

We haven't explained why they look like they do in that diagram. It's simple. The JOPs are always around the circumference of the circle making up the blob, so their distances increase in a circular fashion from the blob they are joining up with, so they bulge around the line between the two centres of the blobs and the bulge decreases as the potential does, since less and less points are included in the surface as the distance increases.

Ok. Now I have one final piece of information to add. In 3D Blobs, we only add points in the space to our surface which have potential equal to c and then we triangulate them. So we are solving an equation. However, I believe that this equation isn't just soluble via trial and error (as is done in realtime these days), we can just solve it on paper, and then we get a function of potential source positions which gives use the plot of the blobs, this would make the calculation of metaballs in realtime REALLY fast.

I hope this wasn't too confusing or too full of mistakes or whatever, you can always send me an email about it.

--paradox