On this page |
Overview ¶
Houdini lets you add your own custom spare parameters to an individual node’s user interface. You can then use the value of the spare parameters in expressions. This lets you set up an interface that lets you tweak parts of an expression without having to hand-edit numbers.
(Spare parameters only exist on a single node. If you want to create a new type of node that lets you create multiple nodes with the same customized user interface, you want a digital asset.)
Example ¶
For example, you might have a Point geometry node that randomly jitters point positions up and down in Y using the expression:
Position Y |
|
---|
(Where @P.y
is the current point’s position in Y, rand returns a number between 0 and 1, @ptnum
is the current point’s number used as a random seed, and 0.5
is subtracted to change the random range from -0.5
to +0.5
.)
You could add a multiplier to change the scale of the jitter:
Position Y |
|
---|
…but if you want to play with the multiplier, it’s tedious to hand-edit the number in the expression. What you want is a parameter on the node that modifies the multiplier value in the expression.
You can change the expression to reference a parameter using the ch function:
Position Y |
|
---|
…and add a spare parameter named jitter_scale
. Then you can use the parameter interface to set the scale interactively using a slider.
(See the expression cookbook for more information on writing expressions.)
How to ¶
-
In the node’s parameter editor, click ▸ Edit parameter interface.
-
In the Create Parameters list, drag a parameter type over to the Existing parameters list and drop it where you want it to go in the interface.
For example, to add a floating point parameter under the Group field, drag Float from the left pane and drop it under Group in the Existing parameters list.
-
Under Parameter description, set the options for the new parameters:
-
Set the Name to an internal name for the parameter. This is the value you will use in
ch("name")
function calls. It must not contain spaces, and can’t be the same as the name of any other parameters on the node. -
Set the Label. This will be the label for the parameter in the user interface.
-
-
Use ch in other parameters to reference the value of the new parameter (or chs for string parameters).
For example, in an expression you can reference the value of the
jitter_scale
parameter on the same node using:ch('jitter_scale')
VEX snippets ¶
Some nodes, such as the Attribute Wrangle geometry node let you write short VEX scripts to modify the node’s behavior. You can use parameter references in these snippets and automatically add the corresponding spare parameters.
-
In a VEX snippet, use the chi, chf, chv, or chs functions wherever you want parameters.
For example:
@P.x += (random(@ptnum) - 0.5) * chf("scale");
-
Click the Create Parameters button.
Houdini finds any channel references in the snippet that don’t have corresponding parameters and creates parameters for them automatically. The parameters appear in the editor below the snippet.