Thursday, February 26, 2015

What's Up with Houdini Pyro2? The power of custom buoyancy fields.

The Houdini Pyro2 solver is pretty excellent, out of the box it generates very good smoke, fire, steam, explosions etc. I'm not going to cover the basics of how to use pyro. There are plenty of tutorials about this already.

http://www.sidefx.com/docs/houdini14.0/nodes/dop/pyrosolver

However, once you have the knack of getting a good result out of pyro the subject of art direction becomes more important.

Want to make something explode in a natural way. Cool no problem.

Want to direct the flow of fire in an un-natural and artistic way? Maybe not so obvious. What about a shockwave? Or a spiral of smoke, or some other more complicated shape?

How can you manipulate the forces necessary to achieve this?

The naive answer to pushing a sim like this around is to apply forces directly to the sim. Want the smoke to go left? Apply a wind force (e.g. a uniform force with a bit of noise.). Unfortunately this has a very obviously streaky effect that feels like wind.

Let's go back to basics for a sec.

Below we have a simple video where the video on the left has the default pyro buoyancy as the only force acting on the solver. On the right, buoyancy is turned off and a uniform force approximates the same direction.

Note how the buoyancy provides a nice natural curling behavior. This is because pyro is using the temperature attribute of the smoke to make the smoke rise. This is not uniform so the leading edge is cooling faster than the trailing edge and so you get this toroid like rolling mushroom cloud behavior. Whereas on the right, there is just a simple uniform force that is pushing the smoke.


This is the fundamental difference in the quality of the smokes behaviour.

So instead of simply applying a force directly to the sim we can slightly hack our pyro solver to get a much more natural looking result for art directed and unnatural behavior.

How do we do this?

Say hello to the Gas Field VOP

http://www.sidefx.com/docs/houdini14.0/nodes/dop/gasfieldvop

With this node you can directly manipulate attributes in the pyro sim, including density, temperature, velocity, etc.

Let us begin with the naive approach. i.e. directly modifying the velocity of our sim, i.e. a direct force.

For this example I'm going to try and make a shockwave. A radial disc of force emanating from an explosive origin point.
We can implement this vector by sampling the position of each voxel in our sim and stripping the Y component. Then normalizing the result.

e.g.

In this simple case we are directly applying this radial planar force vector to the velocity attribute of the sim.
(See the demo file for more specific parameter settings if you're not sure about how to modify velocity in a gas field VOP). Note that in the following examples I have completely disabled the standard pyro buoyancy. The only force acting is the one I am specifically talking about. No shaping, disturbance, turbulence, noise or anything else.



Not super interesting right?

Well now instead of applying the force directly. Let us use the same calculated vector with a simple implementation of buoyancy. Let's let this non uniform vector be the new UP vector for our buoyancy calculation. Pyro will allow our smoke to cool over time so we can trust that the heat in our initial smoke sim will cool. Therefore we can use our temperature attribute to modulate our force. e.g.


Because our temperature dissipates in a non uniform way, we get a much more interesting behavior. e.g.


In essence, the smoke is "rising" towards whatever direction we tell it to go!

From here the sky is the limit.

Let's construct a completely arbitrary buoyancy field in SOPs.

For this example I'm going to make a curve in which each point has a vector pointing to the next point in the curve. e.g.

Specific implementation of this technique can be found in the example file. I then use a copy SOP with a radial transform to produce this:

I then bake this out into a volume velocity field with a point cloud lookup.

e.g.
I wont delve into point cloud lookups in this post as it's beyond the scope of this post. However if you don't use them you are missing out! Suffice to say that I have baked out a volume velocity field which can now be sampled in our gas field VOP.

We can point this file read at our up_field by using the "op:[path to sop]" expression. E.g.


So now we have a custom non uniform buoyancy field with which we can drive our simulation.
Note that our sim has no shaping of any sort here. Just buoyancy with an irregular vortex field defining which way is up.

Let's throw some shaping on, turbulence, disturbance & confinement.
Obviously these are all just low res flipbooks. However this technique definitely scales up and provides a degree of control and realism that is much harder to achieve with more brute force methods.

Example hip file is  here .

Friday, February 6, 2015

In the beginning...

Learning Houdini is not easy.
There is a steep learning curve and many weird tricks that are not always obvious for the beginner. Over the years I've learned much from being able to access various Houdini scene files. Mostly I've just been lucky enough to find the right thing, or pick the brains (and .hip files) of various wizards I've met along the way. Doing fx is about being able to take apart the image or animation that you see and reconstruct it in such a way that you have the control you need to do what you want. This means knowing a *lot* of little tricks. Occasionally I've stumbled over something useful and thought it'd be great to put this somewhere so people may be able to use it, and build on it. This blog is where I've decided to post such bits and pieces I think stand out and are useful to understanding Houdini and how to think more deeply about doing things outside the box.