# Metaballs

DevFeed: [Metaballs](<https://devfeed.tech/articles/metaballs-37311.md>)

Original publisher: [Read original article](<https://muffinman.io/blog/metaballs-generative-art/>)

Author: Stanko

Published: 2020-02-06T00:00:00Z

Content type: article

Language: en

Sources: [Stanko Tadić](<https://devfeed.tech/sources/stanko-tadic.md>)

Topics: [generative art](<https://devfeed.tech/topics/generative-art.md>), [creative coding](<https://devfeed.tech/topics/creative-coding.md>), [Graphics](<https://devfeed.tech/topics/graphics.md>), [coding](<https://devfeed.tech/topics/coding.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [render](<https://devfeed.tech/topics/render.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [art](<https://devfeed.tech/tags/art.md>), [coding](<https://devfeed.tech/tags/coding.md>), [computer-graphics](<https://devfeed.tech/tags/computer-graphics.md>), [creative-coding](<https://devfeed.tech/tags/creative-coding.md>), [exploration](<https://devfeed.tech/tags/exploration.md>), [generative](<https://devfeed.tech/tags/generative.md>), [generative-art](<https://devfeed.tech/tags/generative-art.md>), [graphics](<https://devfeed.tech/tags/graphics.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [projects](<https://devfeed.tech/tags/projects.md>), [render](<https://devfeed.tech/tags/render.md>)

## AI overview

A project write-up about creating Metaballs, a generative art project that combines spheres into organic shapes, slices them, and renders their outlines as vector files. The author describes exploring metaballs, learning about marching cubes and marching squares, using an existing solution, and building tooling for immediate visual feedback.

## Source excerpt

I'm all about generative art these days. Today, I present you Metaballs, my latest creation. It is one of those projects that I visualized in my head and managed to pull it off exactly how I imagined it. Somehow I came up with an idea to generate spheres, smoothly merge them to get organic looking shapes, which then I would slice up and render the outlines.I ordered a pen plotter and that is the reason I'm focused on producing vector files. One of the final images looks like this (click on it to see more): Exploration # Not sure how I started thinking about slicing these blobby objects, but I had a clear vision of what I wanted to achieve. At this point I had no idea they are called metaballs. I asked on our company's #tech-creative-coding channel, if anyone is familiar with making something like this, and my colleagues pointed out the term metaballs and marching cubes algorithm. Definition # Wikipedia defines metaballs as: 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. Which makes them perfect for what I had in mind - generating organic looking blobs. Implementation # The first try # Initially I wanted to implement it myself, but I didn't really know where to start. I had an idea to hack it by overlapping two spheres and calculate a curve between them. By rotating this curve, I would create a tube and merge everything together. It looks ok-ish for two spheres, but I wasn't completely satisfied. And it was impossible do it for more than two spheres. So I gave up early on this idea. Marching on # So I went back to the marching cubes algorithm. After some research I found a wonderful post, which very thoroughly explains implementation of marching squares.Marching squares are the same algorithm as marching cubes, but in 2D. Now I understood how algorithm works, but I gave up on implementing it myself. I was more interested in bei