Advection in Fields

file Banner.png
Click here to get to the Guided Houdini Files.


In this tutorial we will work with special nodes in order to visualize the flow of particles inside vector fields. This will be an opportunity to experience the strengths of houdini in action. To accomplish this we will look at many individual tasks that each teach a valuable lesson.

Example flow.
Flow made up of lots of little points.






big graph.PNG
This is our big network that we will need to fulfill our job.



First stage of our network. The creation of the Velocity field.

Volumes in houdini represent the segmentation of space into a grid of voxels (like pixels) that each contain some information such as a scalar, a vector etc… . We can also choose 2D volumes which are like grids but will allow us to use Fourier transforms. Place a Volume node and check the Two Dimensional XY plane box, pass on the name for our scalar values (automatically type float) and adjust the sampling of the volume. Now is an attribute of the volume ( @f ).

Inside the volume node.

Now we want to have not just one value in each volume element but many. To do this we place a copy and transform node and duplicate the source group @name=f eight times.

copy and transform.PNG
Inside the copy and transform node.

To enable us to reference these copies we will name them using a name node. Just go through the numbers and insert each name once.

name things.PNG
Inside the name node.

Now we have access to 8 attributes in each voxel (volume element) of type float. Here we choose these attributes:

  • f = real part of potential field
  • g = imaginary part of potential field (=0). Important for Fourier transform.
  • gradf_x, gradg_x, gradf_y, gradg_y, sgradf_x, sgradf_y = gradient values and simplectic gradient of f and g to later specify.

At last we can define the field simply by defining f in the volume wrangler.

Optional: inspect potential field
view height.PNG
View height network.

Place a volume slice node to color encode the volume and then transform the height to get a graph like view. The source group of the volume slice must be @name=f.

volume slice.PNG
Inside the volume slice node.

The attribute wrangler can shift the points along the normal @N and as far as the @density which is an important attribute of volumes.


Gradient Computation, Fourier transforms

Next we want to compute the gradient of f. We will archive this with sneaky mathematical tricks who’s explanation would blow up the scope of this course.

gradient computation.PNG
Gradient computation network.

We can transform and through Fourier transformation back and forth while checking center DC.

Forward transform. Only use f and g.
Inverse transform. Use everything and check invert box.

The inverse transform carries the source groups:
@name=f  @name=g @name=gradf_x @name=gradg_x @name=gradf_y @name=gradg_y @name=sgradf_x @name=sgradf_y

In between the Fourier transformations you can run the following volume wrangler to compute the gradients.

gradient wrangler.PNG
Gradient computations inside the volume wrangler.


The Advection of Points

Now we would like to have some points to advect along the simplectic gradient. In order to do that we first need points. We can create a set of points by connecting a circle node with a scatter node. These will be linked to the first input of the solver node.

advection nodes.PNG
Advection network. Points are created on the right.

Before we can advect the flow we need to convert the simplectic gradient volumes into a vdb volumes using the convert VDB node. This is a type of volume used especially for these computations (sparse representation).

Inside the convert VDB node.

We then merge the x and y components into one vector using the VDB Vector merge node.

vector merge vbd.PNG
Inside the VDB vector merge node.

Next we set up a solver node and dive into it. There we connect the input_2 (our points that will flow) and the previous frame node with an VDB advectpoints node and highlight it.

solver node advection.PNG
Inside the solver node. The vdb advect points node does all the computations.

If we now highlight the solver node we can already see the flow moving when play is pressed.

Remember from the previous tutorial on solver nodes that if you want to see the start before the first advection that you need to uncheck something in the options as seen in the gif below.

Disable creation frame solve as in a previous tutorial.
Visualizing the Flow

Next we want to take a look at the flow lines. We can archive this by making another volume slice as done and connecting the output of the gradient with a volume trail node.

Visualizing the volume trail.

The volume trail node should should have the simplectic gradients as it’s inputs.

volume trail.PNG
Inside the volume trail node.

The volume trail itself lets you view the flow lines as seen in the following image.

volume trail image.PNG
The flow lines made by the simplectic gradient of our potential function.

With a few nodes and very little code we have now archived a functional flow visualization. This is the strength of houdini.

First we show the flow with the flow lines.

Look at this beauty. Go try out different fields.

And here we show the same flow without the flow lines.

Just points flowing through life.

Also keep in mind that a lot of the code that we learned here can be reused. Here we had a constant 2D field but one might as well change the field at every frame for instance to simulate a fluid.

Print Friendly, PDF & Email