Thursday, April 26, 2012

Exploring Houdini 12: SDF Fluid Madness



As this test was to decipher the SDF system in Houdini 12, the render is minimal and not terribly artistic.  I HAD modeled a super detailed high-poly fountain in ZBrush that was going to be snapped up to snuff using a displacement map...if anyone knows how to get the ZBrush to Houdini workflow to produce good results please let me know as I am still looking for a solution.

At first I was not sure what the white mesh at the center was near the end of the animation, but then realized that it was a reflection of the light source above the entire setup.  Moral of the story, when lighting, light for water and not the scene.  This will not complicate things too much as the water is usually a separate pass that is later comped into the scene, so from a workflow standpoint lighting the water separately will not screw anything up at all!

Loading...
  
First we will create several Geo containers, one to be the fountain .obj import or landscape and the second to be the emitter of water.


Next we will make a Liquid Container from the Fluid Container tab on the shelf by Ctrl + Clicking on the blue box icon.

 That One

It will automatically create an AutoDopNetwork for you as well as import_fluid and import_fluid_interior nodes.  Dive into that and select the fluid node to adjust the Size.  Make sure that both the landscape and the emitter you have created are within the Liquid Container.







Select the object that is your emitter, then click on the Source from Surface button in the Populate Containers tab on the shelf.  Next select your Liquid Container and press Enter.  

If you press the play button on the bottom left, you should see particles begin to flow from your emitter, notice how it does not interact with your landscape object.                      

We'll fix that next.






Select the landscape geometry and click the Static Object button in the Rigid Bodies tab on the shelf.


Now when you start playing the simulation, the water will pool around your object.  Sadly, the liquid seems to be ignoring a lot of the detail in our landscape object.  We can fix that.  Dive into the AutoDopNetwork.


There will be a node in the AutoDopNetwork with the same title as whatever you called your landscape geometry, mine is called Landscape_Geo and has the same icon as the Static Object button on the shelf.  Select that node.


In the parameters, click on the Collisions tab.  Under the Volumes sub-tab, at the very bottom check the Show Collision Guide Geometry box.  The red mesh that appears represents the actual surface the liquid will interact with...it would not make sense to calculate every nook and cranny unnecessarily, so Houdini takes it from this rough approximation of our landscape's surface.  It is easier to view this difference in wireframe mode (easy to get into if you are in the viewport and press w.


In order to better wrap the liquid around the object, raise the Uniform Divisions number.  It defaults to 30 but 86 worked much better for me.

30 Uniform Divisions, the liquid kind of ignores the bumps.

86 Uniform Divisions, notice how the water runs between and over the bumps.
This result is much more dynamic.

Be sure to uncheck the Show Collision Guide Geometry box when you are finished.  As is, the liquid will pool up inside your Liquid Container, creating a box-like shape,  this can be circumvented through the parameters in the fluid node (still inside your AutoDopNetwork).  Unchecking the Closed Boundaries box in the Initial Data tab or just the specific sides, will help better control how and if the fluid disappears instead of hitting the container. 

 All Boundaries Closed

The water can flow out the +Z now, so there is less buildup in that direction.

All Closed Boundaries

All Boundaries Open (box unchecked)


At the moment our emmitter is streaming water as though it were from a hose or the kitchen sink.  For producing more of a natural result, it is important to add some chaos to the water before it even hits your object or landscape.  In order to do this we need to animate our emmission object.

To better illustrate this I will jump into the fountain project I showed at the top of the post...unlike the sphere I've been showing up until this point, in the fountain project I used a grid as the base geometry for the emitter.  There is no reason why you could not apply this process to any other type of emitter though.

Pretty Basic Emmitter


In order to produce variation I have attached a mountain node to my grid.  In the Offset I have typed the expression $FF/20.  This will allow the emitter to change shape every frame which then allow the water to splash with a random and natural feel from the emitter before it even hits the object.

There is, of course, much more involved in making a fluid sim but this is more than enough to get started.
I will continue to post when I have time!
Josh Evans 

2 comments: