Metaballs

February 11th, 2013

Metaballs are interesting. Not really because they carry the promise to control organic-like shape with code, but mainly because they offer a support to easily try different rendering techniques. Here is two experiments involving metaballs I made to test two algorithms.
The first approach is based on the marching squares algorithm Sakri explains here, which is pretty much the same as the one described on this site.
Unfortunately this method is not very stable but you still can see it in action here, and eventually I managed to generate few images with it :

More recently I tried to use quadtrees to render the metaballs. The image is divided into an array of cells and the metaballs field's value is evaluated at each cell's corner. If all the values are on the same side of the theshold the cell is displayed with the corresponding color. Else the cell is divided into four new cells where the process is repeated until the cell reaches the size of a single pixel.
The downside here is that if a cell is too large, it may be evaluated incorrectly and the image is not rendered as it should.
Eventually I found it very interesting to display the cells' edges, so here is the result :