< Traversing a Stage Main USD Tutorials Page >


Authoring Variants

This tutorial focuses on creating and authoring a variant set using the HelloWorld layer from the Inspecting and Authoring Properties tutorial, using the operators from Shift_USD catalog.

The USD file HelloWorld.usda can be found in the following path in the Shift installation folder: <path_to_the_shift_installation_folder>/shift/examples/USD/tutorials/tutorial_02_authoring_properties/result/.

Tutorial

  1. Open Shift application. A new window instance of Shift should appear like the following one:
Shift UI.
Figure 1: Shift UI.
NOTE

Before creating the USD workflow, ensure that the USD nodes appear in the Node List widget. The catalogs combobox should show sUSD and sUSDTypes if USD is correctly loaded in Shift. If this is not the case, please check again the Shift_USD installation page.

  1. Add a new UsdStageOpen node to the board and rename it to StageOpen. Using the Inspector widget, set as the value for the filepath input plug a filepath pointing to the HelloWorld.usda file downloaded for the example. The board should look like the following:
Added the 'StageOpen' node to the board for opening a given USD file.
Figure 2: Added the 'StageOpen' node to the board for opening a given USD file.
  1. Add a new UsdPrimGet node to the board and rename it to WorldGet. Connect the stage output plug from the StageOpen node to the stage input plug of the new node. Set /hello/world as the value to the primpath input plug. The board should look like the following:
Added the 'WorldGet' node to the board connected to the 'StageOpen' node.
Figure 3: Added the 'WorldGet' node to the board connected to the 'StageOpen' node.
  1. Add a new UsdAttributeGet node to the board and rename it to DisplayColorAttrGet. Connect the prim output plug from the WorldGet node to the prim input plug of the new node. Set primvars:displayColor as the value to the name input plug. The board should look like the following:
Added the 'DisplayColorAttrGet' node to the board connected to the 'WorldGet' node.
Figure 4: Added the 'DisplayColorAttrGet' node to the board connected to the 'WorldGet' node.
  1. For cleaning the authored value of the primvars:displayColor attribute, add a new UsdAttributeClear node to the board and rename it to DisplayColorAttrClear. Connect the attribute output plug from DisplayColorAttrGet node to the attribute input plug of the new node. Set the value False to the useTime input plug and 0 as the value to the time input plug. The board should look like the following:
Added the 'DisplayColorAttrClear' node to the board connected to the 'DisplayColorAttrGet' node.
Figure 5: Added the 'DisplayColorAttrClear' node to the board connected to the 'DisplayColorAttrGet' node.
  1. Add a new UsdPrimStageGet node to the board and rename it to WorldStageGet. Connect the prim output plug from the WorldGet node to the prim input plug of the new node. The board should look like the following:
Added the 'WorldStageGet' node to the board connected to the 'WorldGet' node.
Figure 6: Added the 'WorldStageGet' node to the board connected to the 'WorldGet' node.
  1. For saving the modifications done to the HelloWorld.usda file, add a new UsdStageSave node to the board and rename it to StageSave. Connect the stage output plug from the WorldStageGet node to the stage input plug of the new node. Leave empty the value for the filepath input plug, doing this, the original file will be overridden. The board should look like the following:
Added the 'StageSave' node to the board connected to the 'WorldStageGet' node.
Figure 7: Added the 'StageSave' node to the board connected to the 'WorldStageGet' node.
  1. Add a new UsdPrimGet node to the board and rename it to HelloGet. Connect the stage output plug from WorldStageGet node to the stage input plug of the new node, also, connect the out-trigger output plug from the StageSave node to the in-trigger input plug. Set /hello as the value to the primpath input plug. The board should look like the following:
Added the 'HelloGet' node to the board connected to the 'WorldStageGet' and 'StageSave' nodes.
Figure 8: Added the 'HelloGet' node to the board connected to the 'WorldStageGet' and 'StageSave' nodes.
  1. Add a new UsdVariantSetAdd node to the board and rename it to ShadingVariantSetAdd. Connect the prim output plug from the HelloGet node to the prim input plug of the new node and set shadingVariant as the value for the variantSetName input plug. The board should look like the following:
Added the 'ShadingVariantSetAdd' node to the board connected to the 'HelloGet' node.
Figure 9: Added the 'ShadingVariantSetAdd' node to the board connected to the 'HelloGet' node.
  1. For adding the variants to the new variant set, add a new UsdVariantAdd node and rename it to RedVariantAdd. Connect the variantSet output plug from the ShadingVariantSetAdd node to the variantSet input plug of the new node and set red as the value for the variantName input plug. The board should look like the following:
Added the 'RedVariantAdd' node to the board connected to the 'ShadingVariantSetAdd' node.
Figure 10: Added the 'RedVariantAdd' node to the board connected to the 'ShadingVariantSetAdd' node.
  1. As done in the previous step, add another UsdVariantAdd node and rename it to BlueVariantAdd. Connect the variantSet output plug from the RedVariantAdd node to the variantSet input plug of the new node and set blue as the value for the variantName input plug. The board should look like the following:
Added the 'BlueVariantAdd' node to the board connected to the 'RedVariantAdd' node.
Figure 11: Added the 'BlueVariantAdd' node to the board connected to the 'RedVariantAdd' node.
  1. As done in the previous step, add another UsdVariantAdd node and rename it to GreenVariantAdd. Connect the variantSet output plug from the BlueVariantAdd node to the variantSet input plug of the new node and set green as the value for the variantName input plug. The board should look like the following:
Added the 'GreenVariantAdd' node to the board connected to the 'BlueVariantAdd' node.
Figure 12: Added the 'GreenVariantAdd' node to the board connected to the 'BlueVariantAdd' node.
  1. Add a new UsdVariantSetSelected node and rename it to GreenVariantSelect. Connect the variantSet output plug from the GreenVariantAdd node to the variantSet input plug of the new node and set green as the value for the variantName input plug. The board should look like the following:
Added the 'GreenVariantSelect' node to the board connected to the 'GreenVariantAdd' node.
Figure 13: Added the 'GreenVariantSelect' node to the board connected to the 'GreenVariantAdd' node.
  1. Follow the steps done in the section Creating a variant workflow and add a new UsdVariantWorkflow node and rename it to RedVariantDCSet. Set the path to the workflow created in the Creating a variant workflow section as the value for the file input plug of the node, which should be named set_variant_display_color.sft. Once the file is properly set, the node will be automatically updated to show the inputs and outputs from the nested workflow. Then, connect the variantSet output plug from the GreenVariantSelect node to the variantSet input plug of the new node, also, connect the prim output plug from the WorldGet node to the prim input plug of the new node. Set red as the value for the variant input plug and [1,0,0] as the value of the color input plug. The board should look like the following:
Added the 'RedVariantDCSet' node to the board connected to the 'WorldGet' and 'GreenVariantSelect' node.
Figure 14: Added the 'RedVariantDCSet' node to the board connected to the 'WorldGet' and 'GreenVariantSelect' node.
  1. Duplicate the RedVariantDCSet node and rename it as BlueVariantDCSet. As done before, connect the variantSet output plug from the BlueVariantSelect node to the variantSet input plug of the new node, also, connect the prim output plug from the WorldGet node to the prim input plug of the new node. Set blue as the value for the variant input plug and [0,0,1] as the value of the color input plug. The board should look like the following:
Added the 'BlueVariantDCSet' node to the board connected to the 'WorldGet' and 'GreenVariantSelect' node.
Figure 15: Added the 'BlueVariantDCSet' node to the board connected to the 'WorldGet' and 'GreenVariantSelect' node.
  1. Duplicate the RedVariantDCSet node again and rename it as GreenVariantDCSet. As done before, connect the variantSet output plug from the GreenVariantSelect node to the variantSet input plug of the new node, also, connect the prim output plug from the WorldGet node to the prim input plug of the new node. Set green as the value for the variant input plug and [0,1,0] as the value of the color input plug. The board should look like the following:
Added the 'BlueVariantDCSet' node to the board connected to the 'WorldGet' and 'GreenVariantSelect' node.
Figure 16: Added the 'GreenVariantDCSet' node to the board connected to the 'WorldGet' and 'GreenVariantSelect' node.
  1. Add a new UsdPrimStageGet node and rename it to StageFinalGet. Connect the prim output plug from the GreenVariantDCSet node to the prim input plug of the new node. Then, connect the out-trigger output plug from the RedVariantDCSet and BlueVariantDCSet nodes to the in-trigger input plug of the new node. The board should look like the following:
Added the 'StageFinalGet' node to the board connected to the 'GreenVariantDCSet', 'RedVariantDCSet' and 'BlueVariantDCSet' nodes.
Figure 17: Added the 'StageFinalGet' node to the board connected to the 'GreenVariantDCSet', 'RedVariantDCSet' and 'BlueVariantDCSet' nodes.
  1. Finally, to save the modifications done in the stage, add a new UsdStageSave node and rename it to StageFinalSave. Connect the stage output plug from the StageFinalGet node to the stage input plug of the new node. Leave empty the value for the filepath input plug, doing this, the original file will be overridden. The board should look like the following:
Added the 'StageFinalSave' node to the board connected to the 'StageFinalGet' node.
Figure 18: Added the 'StageFinalSave' node to the board connected to the 'StageFinalGet' node.
  1. Execute the workflow, the HelloWorld.usda should appear as modified containing the latest changes for the variants.

Creating a variant workflow

  1. In a new workflow, add a new UsdPrimDisplayColorSet node to the board and rename it to PrimDisplayColorSet. The board should look like the following:
Added the 'PrimDisplayColorSet' node to a new empty board.
Figure 19: Added the 'PrimDisplayColorSet' node to a new empty board.
  1. Now, add a new Input node to the board and rename it to Input. Drag and drop the connection from the PrimDisplayColorSet node's prim input plug over the Input node, using the Add Plug dialog, use the preselected options for creating the new plug. Repeat the same steps for the color input plug from the PrimDisplayColorSet node, creating the plug with the default selected values in the Add Plug dialog. The board should look like the following:
Added the 'Input' node and added the new plugs.
Figure 20: Added the 'Input' node and added the new plugs.
  1. Finally, add a new Output node to the board and rename it to Output. Drag and drop the connection from the PrimDisplayColorSet node's prim output plug over the Output node, using the Add Plug dialog, use the preselected options for creating the new plug. The board should look like the following:
Added the 'Output' node and added the new plug.
Figure 21: Added the 'Output' node and added the new plug.
  1. Save the workflow with a proper name like set_variant_display_color.sft. This workflow will be reused for the main workflow driving the example.

Visualising the Stage

Shift is shipped with native plugins to visualise and inspect the stage. They can be accessed from the USD top menu:

  • USD Outliner: Shows the user the stage hierarchy sourced from specific Usd nodes in the active board workflow.

  • USD Viewer: Shows the stage in the USD viewer sourced from specific USD nodes in the active board workflow.

Shift USD Outliner and USD Viewer plugins.
Figure 22: Shift USD Outliner and USD Viewer plugins.

The USD viewer tool shipped with USD is used to visualise and inspect the stage viewport:

Visualising the stage.
Figure 23: Visualising the stage.

Workflow Resources

The workflows corresponding to this tutorial can be found in the following path in the Shift installation folder: <path_to_the_shift_installation_folder>/shift/examples/USD/tutorials/tutorial_06_authoring_variants/


< Traversing a Stage Main USD Tutorials Page >


Inbibo Logo

consultancy, automation and digital creatures

65 Compton Street, London, United Kingdom, EC1V 0BN

info@inbibo.co.uk

Information

Products

© 2024 Inbibo LTD. - All rights reserved - Design & Development: def:studio