Houdini 22.0 Character KineFX

Creating custom rig functionality

On this page

The APEX AutoRig Component SOP provides different ways to create your own custom tools, including the use of rig component scripts, a built-in code interface that accepts APEX Script snippets, and the ability to merge rig functionality from a graph into an existing rig.

Working with APEX Script

The APEX AutoRig Component SOP provides an interface for writing APEX Script code. On the APEX AutoRig Component SOP, set Component Source to Snippet. You can enter APEX Script code into the Snippet parameter and save the script functionality as its own rig component.

Working with fuse graphs

The fuse graph operation on the APEX AutoRig Component SOP merges a graph you build by hand (a fuse graph) into an existing rig. It’s a modular, hands-on way to change a rig. You edit the part you want to update in the APEX network view, then fuse it back in while keeping the whole rig procedural.

You build the fuse graph in an APEX Graph SOP, then set Component Source to Fuse Graph on a second APEX AutoRig Component SOP to merge it into the rig.

Workflow for merging a graph into an existing rig

Because you can build and test complex node networks and matrix calculations visually, the fuse graph is also a good way to prototype an idea before fusing it into your final rig.

The fuse graph operation adds the new nodes introduced in the APEX Graph SOP, connects them, and can rewire existing connections. It can’t remove nodes that already exist in the rig, however.

Note

It is not recommended to put new nodes into a subnet in your fuse graph (the APEX Graph SOP). If you rename the subnet later on, your graph will no longer work. The fuse graph operation also cannot take existing nodes from a fuse graph and add it into a new subnet. It can, however, insert an entirely new subnet into an existing rig.

On this page, we demonstrate the following uses of the fuse graph operation:

  • Adding a control shape to a rig.

  • Adding custom IK functionality to a rig.

  • A range of other fuse graph techniques: mirroring functionality to the other side of the character, reusing a setup from another graph, fetching rest transforms with reference value nodes, pruning nodes, and recreating deleted nodes.

Add a control shape

In this example, we add a control shape to a character’s spine joint:

Note

Here, we set the control shape’s values directly in the graph to demonstrate the workflow. You can set up control shapes in two ways: setting a value inside the fuse graph re-applies it every time the rig runs - the right choice when you want the shape to update live - but it also overrides any changes made further down the line, so you can’t adjust those controls afterward. For shapes you want to keep adjusting, which is the more common case, use the Configure Controls SOP instead: that stores the shape as an adjustable property on the control.

  1. We start with a character’s skeleton and add it to a character folder structure using the APEX Pack Character SOP.

  2. Create an FK rig graph - on the APEX AutoRig Component SOP, fk, set Component Source to FK Transform. See rigging a simple geometry and rigging a character for more information about the FK transform component.

    The FK rig graph can be seen in the APEX network view. The green nodes are the TransformObject nodes that represent the skeleton joints:

    FK rig graph
  3. Build the fuse graph in the APEX Graph SOP. The APEX Graph SOP can take in a character folder structure and automatically find the rig graph in the folder structure. You can also tell the APEX Graph SOP to find a specific rig in the character folder structure by setting the Graph Path parameter. Once the APEX Graph SOP has a starting graph, you can edit the graph manually in the APEX network view.

    In this example, the APEX Graph SOP contains a copy of the entire FK rig graph as a starting point. From here, you have the option of simplifying the graph to make it easier to work with in the APEX network view.

  4. Select the APEX Graph SOP and go to the APEX network view to manually update the graph. Add a control shape to the spine joint by connecting a new rig::ControlShape node to one of the spine’s TransformObject nodes:

    Add a spine control shape
  5. Select the rig::ControlShape node and press P over the APEX network view to open the node parameter window. Set color to (1,0,0) and shapetype to box_wires.

  6. In the animate state, you can see a visual representation of the rig in the viewport as you update the graph in the APEX network view. To enter the animate state, select the APEX Graph SOP, turn on its display flag, and click Animate on the left toolbar:

    Original rig (left), added spine control shape (right)
  7. Merge the graph from the APEX Graph SOP into the original FK rig graph - on the second APEX AutoRig Component SOP, merge_graph, set Component Source to Fuse Graph. The fuse graph operation finds the new node and connects it into the original graph.

    See the merged graph in the APEX network view. On the APEX AutoRig Component SOP, merge_graph, the rig::ControlShape node is added to the FK rig graph from the first APEX AutoRig Component SOP, fk. The new node is in green:

    Updated FK rig graph with the new node

Simplify the graph

If your change only affects certain parts of the rig, you can simplify the fuse graph by removing the TransformObject nodes that aren’t relevant to your change:

  1. As a starting point, the fuse graph (in the APEX Graph SOP) contains the FK rig graph from the previous example. Remove all the TransformObject nodes except the spine_01 node:

    See graphs for deforming geometry for more information about the skel::SetPointTransforms node.

  2. We had removed spine_01's parent in the process, so we need to place the joint back at its proper position on the skeleton:

    • On the APEX Graph SOP, in the Rigging Scripts section, click Update Rest Transforms From Skeleton.

    • Enter the animate state on the APEX Graph SOP to see the TransformObject node on the spine joint:

  3. Add a control shape to the spine joint by connecting a new rig::ControlShape node to the spine’s TransformObject node.

    • Select the rig::ControlShape node.

    • In the node parameter window, set color to (1,0,0) and shapetype to box_wires.

    The added control shape can be seen in the animate state:

  4. The fuse graph operation in the APEX AutoRig Component SOP, merge_graph, finds the new node, rig::ControlShape, and connects it into the original FK rig graph at the spine_01 TransformObject node.

Add custom IK functionality

The fuse graph operation allows you to create flexible tools that can be applied to different parts of a character’s rig. In this example, we manually construct a fuse graph that adds IK functionality to a character’s leg. We then mirror and transfer the IK functionality to the character’s arms:

  1. In the APEX Graph SOP, we manually build a fuse graph that contains IK functionality for the character’s leg.

    Note

    The TransformObject node names in the fuse graph should match the joint names of the input skeleton.

    Select the APEX Graph SOP, turn on its display flag, and enter the animate state:

  2. On the APEX AutoRig Component SOP, merge_graph, set Component Source to Fuse Graph. The fuse graph operation adds the new IK functionality to the original FK rig graph.

  3. Select the APEX AutoRig Component SOP, merge_graph, turn on its display flag, and enter the animate state.

  4. Set the IK functionality to be mirrored on both sides of the rig. On our rig, the joints are named <joint>_l and <joint>_r, so set From to *_l, To to *_r, and Fuse Graph Body Side to *_l. The Mirror parameter is already turned on, so mirroring is performed by default once the patterns are set:

    IK functionality mirrored on both legs
  5. We can now transfer the IK functionality to other joint chains like the arms. Click beside Mapping and add three mappings, one for each of the root, mid, and tip joints in the IK chain. Mappings are performed between TransformObject nodes, which represent the skeleton joints.

  6. For each joint to map:

    • Click the icon beside the From parameter. This is the joint that has the existing functionality.

    • Select the joint in the viewport and press Enter. This populates the From parameter with the joint name.

      Note

      Select the joint, not the control that’s on the joint.

    • Click the icon beside the To parameter. This is the joint you want to put the functionality on.

    • Select the joint in the viewport and press Enter. This populates the To parameter with the joint name.

    In our example, the three mappings are:

    • From = thigh_l, To = upperarm_l

    • From = calf_l, To = lowerarm_l

    • From = foot_l, To = hand_l

  7. The IK functionality is placed on the arms:

Mirror a fuse graph

You can build functionality on one side of the character and have the fuse graph mirror it to the other side. Build only one side and let the operation generate the other - delete the mirrored side from your fuse graph so the joint names don’t collide. On the APEX AutoRig Component SOP, turn on Mirror, then set the mirror patterns. The mirror copies the functionality from the joints matching From over to the joints matching To.

For a rig whose joints are named <joint>_l and <joint>_r, with the functionality built on the left, set From to *_l, To to *_r, and Fuse Graph Body Side to *_l. Once the patterns are set, mirroring happens by default because Mirror is already turned on.

The fuse graph component’s mirror settings

To transfer the functionality to other joint chains (for example, from a leg to an arm), add entries to the Mapping multiparm, one per joint. For the full mirroring and joint-mapping walkthrough, see Add custom IK functionality.

Reuse a setup in another graph

Because a fuse graph is just a graph, you can build a tool once in a separate graph node, then copy and paste it into your own graph to reuse it and fuse it into the rig. The control names have to match your rig for this to work - if they don’t, update them in the graph first.

Fetch data with reference value nodes

The fuse graph operation recognizes specially named Value nodes as reference nodes. A reference node is a placeholder: at merge time, the operation reads data into whatever the node is wired to (or uses it to drive behavior), then removes the reference node itself. You name a reference node with a suffix so the operation knows what to do with it.

The suffixes it recognizes:

Suffix

Node type What it does

<jointname>__REST

Value<Matrix4> | Fetches the joint’s rest transform from the guides. See Fetch a joint’s rest transform.

<name>__MIRROR

Value<Bool> | Acts as a switch driven by the Mirror state. See Control mirroring with a switch.

Fetch a joint’s rest transform

To fetch a joint’s rest transform from the guides, add a Value<Matrix4> node named <jointname>__REST (for example, foot_l__REST for the joint foot_l). At merge time, the operation looks up that joint’s rest transform, writes it into whatever the node is wired to, and removes the __REST node - the value stays baked into the downstream node.

A rest reference node: a Value<Matrix4> named point_1__REST

Keep the following in mind:

  • The __REST node has to be wired into something. The operation only writes the fetched value into the connected node - it doesn’t leave the reference node behind to hold it.

  • A __REST node can’t feed a variadic input directly. For example, wiring point_0__REST straight into a Multiply node’s variadic input doesn’t work:

    A rest reference node wired straight into a variadic input, which doesn’t work

    To do this, store the rest value in a second Value<Matrix4> node (for example, point_0_rest) and wire that node into the variadic input:

    Store the rest value in a second Value node, then wire it into the variadic input
  • Wiring a __REST node into a non-variadic input works directly. For example, wiring rest reference nodes into a transform::Blend node works as expected.

Control mirroring with a switch

Rig-builder mirroring is rotational rather than scaled. Because the rest positions are rotated and not scaled, any offsets you add to your controls can come out flipped on the mirrored side.

To control this, give a Value<Bool> node a name ending in __MIRROR. The operation turns it into a switch that reflects whether the component is being mirrored. Wire the switch into a small boolean setup - for example, to choose between two transforms and get the correct offset on the X axis for each side:

A __MIRROR switch selecting between two transform offsets

Exclude nodes from the fuse graph

The Exclude Nodes parameter lets you leave nodes out of the fuse graph so they don’t merge into the rig, using a path pattern that matches nodes by tag. For example, this pattern excludes the nodes tagged #a_tag, while keeping /parms and /output:

#REFERENCE #a_tag -/parms -/output
The Exclude Nodes parameter with a tag pattern

Reference nodes are tagged #REFERENCE, so this is a handy way to strip setup and reference nodes out of the merged result.

Recreate deleted nodes

Bringing nodes back after you've deleted them from a fuse graph is no problem. If you've selected a set of nodes and realize you need one you already deleted, just recreate it. As long as the name is correct, the fuse graph operation reconnects it into the rig.

A recreated node reconnects into the rig when its name matches

Save and reuse rig functionality

You can save your custom rig functionality as its own rig component, then reuse it like you would any of the prebuilt components:

  1. On the APEX AutoRig Component SOP, go to the Save tab. The Save tab is available when Component Source is set to Use Second Input, Snippet, or Fuse Graph.

  2. Specify a name for the component in the Component Name parameter. For example, if you set the namespace field to test, the name field to hello, and version to 2.0, the component will be named test::hello::2.0.

  3. You can also specify a label (Component Label) for the component as well as a .png file (Component Icon) to use as an icon for the component in the Autorig Builder’s component catalog.

  4. In the Component Output File, set the path to save the component to, $HOUDINI_PATH/apexcomponent/<component_name>.bgeo. Graphs saved as .bgeo files in $HOUDINI_PATH/apexcomponent are added to the component registry.

  5. Click Save to Disk.

  6. Click the icon beside the Component Source parameter to update your library of components. The new component will appear in the Component Source drop-down, and you can use it like any other component.

  7. Once you select the new component from the Component Source drop-down, you can edit its source as an APEX Script snippet. Click beside Component Source, which decompiles the component into the Snippet parameter where you can make additional changes to the component.

    Note

    For components created using the Fuse Graph operation, go to the Settings ▸ Header section and set Template to Fuse Graph.

Preparing components for the Autorig Builder

On the APEX AutoRig Component SOP, you can make a custom component available as an interactive tool for the Autorig Builder using the parameters in the Rig Builder tab. The Rig Builder tab is available when Use with Rig Builder is turned on in the Save tab.

To prepare a custom component for use in the Autorig Builder:

  1. If applicable, define a “segments” parameter that specifies where to apply the component. The Autorig Builder picks up on the “segments” keyword and allows the user to apply the component to different parts of the character in the drag-and-drop interaction. In APEX Script, you could define the “segments” parameter with something like:

    segments: String = BindInput('', preset='tags')
    

    If you create the component using an APEX graph, you would have “segments” as an input parameter.

  2. In the Rig Builder tab, specify the component’s input parameters that you want to appear in the Autorig Builder’s gear menu:

    • Click Generate from Component Parms to automatically populate the Config Control Parms multiparm with the component’s parameters that are in the parameter interface. For APEX Script, define the input parameters with BindInput(), then click the button to have the parameters appear in the parameter editor. See creating graph interfaces for more information.

      or

    • Manually add the parameters to the Config Control Parms multiparm.

    For the component parameters that are not specified in Config Control Parms, the Autorig Builder uses the default values that are set on the parameter (for example, when defining the parameter using BindInput()).

  3. Set Drag Drop Interaction to Skeleton.

  4. Set the Skeleton Source.

  5. In the Joint Group parameter, select the joints in the Skeleton Source that are relevent to the component. For example, if you build a component that adds functonality to the arm, only the arm joints of the left side of the character should be included in this parameter. These joints are used as a reference skeleton when performing the drag-and-drop interaction in the Autorig Builder.

  6. Set the Remove Side Indicator. This pattern is removed from the joint names so that the component can be used on both sides of the character.

  7. Save the component.

  8. In the Autorig Builder’s component catalog, click the Reload Rig Components button to update your library of components. The new component will appear in the component catalog, and you can drag and drop it onto the guide character like any other component.

Component created using fuse graph

In this example, we prepare the previous IK leg functionality for use in the Autorig Builder:

  1. On the APEX AutoRig Component SOP, Save tab, turn on Use with Rig Builder.

  2. Set Drag Drop Interaction to Skeleton.

  3. Set Skeleton Source to From Guide Skeleton. This uses the skeleton specified in Guide Skeleton.

  4. In the Joint Group parameter, select the joints that the component applies to. These joints provide default positions for the fuse graph’s TransformObject nodes. The TransformObject node names in the fuse graph should match the joint names of the input skeleton:

    • Click the button beside Joint Group.

    • In the rig tree view, select the joints, in our case, thigh_l, calf_l, and foot_l.

    • Click Accept.

    The Joint Group parameter is populated with the selected joints.

  5. Set Remove Side Indicator to *_l. This removes *_l from the joint names so that the component can be used on both sides of the character.

  6. Save the component.

  7. In the Autorig Builder’s component catalog, click the Reload Rig Components button to update your library of components. The new component will appear in the component catalog, and you can drag and drop it onto the guide character.

KineFX

Overview

Preparing character elements

Rigging with APEX graphs

Building rig graphs with APEX Script

Rigging with rig components

Animating in the viewport

Customizing the animate state

SOP-based animation

Deformation

Animation retargeting

Pre-H20

Panes

Appendix