My recent post, Swarm Chemistry in SideFX Houdini, illustrates an interesting effect, but tweaking the values in the swarm chemistry solver is a pain. What would be great is a user interface to vary the simulation parameters rather than having to edit the VEX by hand.

Luckily, Houdini offers two approaches to do this: HUD sliders and Digital Assets. In this post, I'll take a quick look at the latter.

A digital asset wraps up a network into a reusable node. The asset can expose a custom user interface containing sliders, buttons, color choosers and other UI controls.

The first step is to right-click the node you wish to convert to a digital asset and select "Create Digital Asset". After confirming the asset's name and location, you're presented with this slightly daunting dialog:


Here, you can define the UI controls you wish to create and the parameters they're bound to. In the figure above, the color of Genome One is selected and that refers to the color parameter, genomeOneColor.

For my swarm chemistry asset, my UI looks like:



Parameter values can be accessed inside the asset using the VEX channel functions such as ch() for floats and chv()for vectors. For example, the metaball checkbox at the top of the form is bound to a parameter named useMetaballs. A Switch node inside my network selects between the raw points or the copied metaballs, and its input parameter is controlled by an expression:



To access the asset's parameters in the VEX solver that is deeper in the network, I changed  the wrangle node's Evaluation Node Path property to the top level of the network. This means I don't need to worry about how deep the node and I can avoid prefixing multiple "../" to each parameter name. For example, I can access genome one's color and cohesion with this code:
@Cd = chv("genoneOneColor"); 
c1_cohesion = 100 * ch("cohesionOne");
Because the asset is saved locally, it's available to any other projects. My tab menu now has a new entry!




Powerful stuff! 

Addendum: Adding Depth-of-Field

Here's a render after a little tweaking to the VEX to add a radial gravitation force at the centre of the simulation and adding depth-of-field to the Mantra node:


0

Add a comment

About Me
About Me
Labels
Labels
Blog Archive
Loading