# VEX in Houdini: Diffusion Limited Aggregation (Plus Rendering in Mantra & Redshift)

Free Tutorials

When we saw Andy Lomas’ “Aggregation” series a few years back we were struck. How could you generate those intricate particle sculptures? The series’ title hinted at one possible solution: Diffusion limited aggregation or DLA. In this tutorial we’ll build a basic DLA setup using VEX and volumes. Also we’ll talk a bit about rendering our result in Mantra and Redshift.

DLA simulated particles wandering freely in a solution until they stick to a seed and grow into bigger branching structures. One real life example can be seen in this image from Wikipedia:

A DLA cluster. Copper aggregate formed from a copper sulfate solution in an electrode position cell.
Photo By Kevin R Johnson. (Wikimedia Commons)

While the algorithm’s speed is reasonable in 2D, it can get quite slow in 3D. If anyone has hints on how to speed up the whole simulation – please let us know!

Paul Bourke has a more detailed introduction to the principles behind DLA and the actual algorithm.

Have fun with it!

Download Project Files (.hipnc)

### 17 Comments

1. Kevin Sutherland

Another gem! I cant tell you how much I look forward to these releases. Long may you have the time, creativity and patience to continue. I’m sure I speak for everyone when I say we’re all very grateful for the inspiration and learnings.

• Nic

Agreed !

• Moritz

Thanks guys! It’s comments like yours that keep us going!

Cheers,
Mo

2. Maurits laanbroek

Hey
Love the video, I think you can increase the speed a bit by letting the pointwrangle2 only run over points in the move group. This reduces the number of points being processed.

3. Simple silly question: Why is your Materials tab icon more exciting than mine? I have the cardboard box with stuff in it icon. Other than that, great stuff!

• Moritz

Honestly I have no clue. Are you using a current build?

Cheers,
Mo

• Ah yes, thats it. I wasnt on 16.0.600 yet.

4. Great tutorial, Moritz! I think one of your main reasons for the increasing slowdown at later frames is that your number of moving points is essentially unbounded. With your updated targetnum calculation you already have >209,000 points to update / frame once the bounding sphere radius >= 1. I’d at least wrap this all in a min(targetnum, 10000) to keep a lid on runtime per frame. So I will try to re-implement an alternative approach (which I also used back in the day for toxiclibs): Use a single/fixed number of moving points and don’t spawn them in a single global bounding sphere, but each one in a much smaller search sphere around a randomly chosen static point. Additionally, use another attrib, to keep track of search iters per moving point. If no static point has been found after N frames, respawn that search point… You can find more details (and various additional options to control growth behavior) here: https://toxiclibs.org/2010/02/new-package-simutils/

• Moritz

Hi Karsten and thanks so much for sharing all of this! Amazing collection of assets on your git. I realize now that (as soon as I find the time – whenever that might be) I might have to do a re-implementation of this 🙂 Did you also work on toxiclibs?

Thanks again and sorry for the delayed answer – the past weeks have been a bit busy 🙂
Cheers,
Mo

• No prob, Moritz! 🙂 And yes, toxiclibs was my labour of love…

5. max

is there an easy way not to use a curl noise? but maybe a vector field from a particle emitter field?
sorry if this is a stupid question, but I’m really new to houdini.
but anyway great work guys, I really love you stuff!!! big shout out!!

6. Matt

Thank you for this tutorial! A Noob question: how can i render actual spheres instead of points? Is it possible to ‘bake’ this object snd animation into Unity?
Thank you!

• You can either copy spheres to those points or adjust the particle point size in the render setting of your object (at object level). If you export it to fbx it should migrate smoothly into Unity

7. da.dub

thank you for all your great tutorials
I learned a lot during this project.

my try: vimeo.com/261851155

8. Grayden

Loving these videos!

Note that you can call curlnoise through vex in your wrangle inside the solver. This is arguably more expensive in the long run since you have to keep evaluating on each step, but it means your volume isn’t constrained (since it will evaluate wherever the point is), and so you don’t have to worry about granularity in the field and/or memory overhead.

To change frequency, just multiply @P as you pass it into curlnoise, and add an arbitrary offset as the equivalent of a random seed.

As for speedups, one possibility is to fake the *outcome* of diffusion.

Version A: For each static point, keep track of the local density of the structure around it. If the density is below a target threshold, spawn a new static point within the attachment radius. If the density is above ignore. You can add per-point noise to the threshold to get better variance.

Version B: For each static point, keep track of the number of failed additions. If below threshold, generate a new candidate point (within the attachment radius). If the candidate overlaps other points, increment the failure counter, otherwise add it to the geometry.