Authoring Scenegraph Instancing#

Now, let’s talk about how to author instancing in OpenUSD, including:

  • The meaning of instanceable metadata

  • Explicit Instances & Implicit Prototypes

  • Composition arcs and how they enable instancing

Scenegraph Instancing#

Setting instanceable = true tells OpenUSD to create one shared version (prototype) of an object that many instances can use as long as they share composition arcs.

Our warehouse has two references to “RobotArm” with instancing enabled. This should generate one prototype subgraph. Two instances of that prototype subgraph

 1#usda 1.0
 2
 3(
 4    defaultPrim = "Warehouse"
 5    metersPerUnit = 0.01
 6    upAxis = "Z"
 7)
 8def Xform "Warehouse"
 9{
10    def "RobotArm_01" (
11        references = @./RobotArm.usd@
12        instanceable = true
13    )
14    {
15    }
16    def "RobotArm_02" (
17        references = @./RobotArm.usd@
18        instanceable = true
19    )
20    {
21    }
22    def "Converyor_01" (
23        references = @./Conveyor.usd@
24        instanceable = true
25    )
26    {
27    }
28    
29}

Proxies and instance subgraphs are immutable, but the instanceable prim is mutable.

It has to be, if you couldn’t edit the instanceable prim, all of our crates would be on top of each other.

 1#usda 1.0
 2
 3(
 4    defaultPrim = "Warehouse"
 5    metersPerUnit = 0.01    
 6    upAxis = "Z"
 7)
 8def Xform "Warehouse"
 9{
10    def "RobotArm_01" (
11        references = @./RobotArm.usd@
12        instanceable = true
13    )
14    {        double3 xformOp:translate = (10, 20, 0)
15    }
16    def "RobotArm_02" (
17        references = @./RobotArm.usd@
18        instanceable = true
19    )
20    {
21        double3 xformOp:translate = (10, 30, 0)
22    }
23    def "Conveyor_01" (
24        references = @./Conveyor.usd@
25        instanceable = true
26    )
27    {
28        double3 xformOp:translate = (40, 20, 0)
29    }
30}

A common explainer mantra in learning OpenUSD is “explicit instances, implicit prototypes”.

You tell OpenUSD the candidates for instancing, it figures out the prototypes implicitly from the authored composition arcs.

Authoring Puzzle#

How many prototypes or instances get generated?

 1#usda 1.0
 2
 3(
 4    defaultPrim = "World"
 5    metersPerUnit = 0.01    
 6    upAxis = "Z"
 7)
 8def Xform "Warehouse"
 9{
10    def "Crate_01" (instanceable = True) {
11       double3 xformOp:translate = (10, 20, 0)
12    }
13
14    def "Crate_02" (instanceable = True) {
15       double3 xformOp:translate = (10, 30, 0)
16    }
17
18    def "Crate_03" (instanceable = True) {
19       double3 xformOp:translate = (10, 40, 0)
20    }
21}

None, There’s no composition arcs on the instanceable prim so there’s nothing to generate prototypes from.

Instancing is an “opportunity” but not a “mandate” for optimization. We’re going to introduce one more concept.

OpenUSD surfaces “proxies” as a read only scene graph element. If you’re writing a script, you can traverse the scene without considering instancing.