Voronoi diagrams have a long history with computer graphics. For me personally, the encounter that first taught me what Voronoi could be used for and more importantly, how to mispronounce the word, was through the Cinema4d plugin, Thrausi.

Around 8 years ago, having just freshly torrented the Cinema 4d* and wanting to copy some sweet internet tutorials I had found, I set off towards fracturing some text with Thrausi’s Voronoi Fracture feature. First though, I had to have a real heart to heart with my parents; I had never illegally downloaded a program before Cinema 4d and freaked the fuck out. Legit I thought that SWAT + Adobe + Maxon would burst through my parent’s front door. My mental ultimatum was either tell them, or something greater would punish me.

Wrong choice. With tears shed, a bruised posterior and a freshly cleared conscience, I booted up some sweet YouTube tutorials. No where else can one find more broken English paired with such high quality knowledge bombs. However Voronoi quickly showed up in all related videos; I was obsessed.

So why was I obsessed? Because I’m a freak. But also Voronoi diagrams look incredibly neat, and not only that, they’re also very good at partitioning data, and by extension, point clouds and meshes.

Two important things to note before moving onto the actual goodness that is Voronoi diagrams. First my previous blog post on Dual Graphs is required reading, if you want to fully understand this post. The second thing I want to make it clear, is that this post is definitely going to go super in depth on Voronoi stuff. And because of that, I highly recommend checking out the Houdini Wiki to brush up on your vex skills, before we get to far: SOAK IT ALL UP

I hope this isn’t too technical too quick, but the way I think about what a Voronoi diagram even is, is first take a surface S (in our case a grid in Houdini), and some points scattered on that surface, P, with a random color on each point. Find the nearest colored point in the scatter P, to each of the points making up our grid S. Finally color S based off the nearest P color.

Visualizing Voronoi generation through expanding circles

To abstract further, that basically means a Voronoi diagram is a method of partitioning anything, in this case point positions, by the distance to another point in a separate data set. But it doesn’t need to be positions. As long as you can come up with a distance function for your given problem, you can make a Voronoi diagram. So really one could make a Voronoi diagram all in excel with no visuals. It’d suck and wouldn’t get dem precious Medium reads (FEED ME ATTENTION), but you could definitely do it.

We use Houdini though, so visuals are par for the course. Plus we have some incredible tools at our disposal for finding near points, specifically the near points tools and the point cloud tools.

Enough waiting! Let’s make some goddamn magic.

Here’s a link to a project file (CLICK ME) that we’ll be building off of in each example, for this pass let’s dive into the geometry object “Example 1.”

I’m ready for the hardest coding challenge of my life.

int np = nearpoint(1, @P);

@Cd = rand(np);

Wait what.

That’s it?

That’s how easy it is to get an ultra basic Voronoi cell pattern in Houdini. Two lines of code.

s a d b o i s

Wow! We can check Voronoi construction off our list, maybe add it to our resume. But Jake, this looks like Boring-Town, USA. I made a sad face with it, because it’s so boring :(

Not only that but the output from this example is color on a surface and not actual geometry that can be used for explosions or other goodness. Luckily that’s where that obsession I mentioned earlier comes in.