Payload under Instances | Prim Pattern under Instances

   447   2   1
User Avatar
Member
30 posts
Joined: Sept. 2023
Offline
Hi,

I'm making optimizations to our USD scene structure, and the asset structure goes something like this:
asset (assembly, instanceable)
- payload_a (component)
- payload_b (some other component)

In the main stage, I would reference these assets in. And within Houdini, I start with a Configure Stage to load nothing at first, then using another Configure Stage, I try loading the component with a prim pattern "%kind:component". This works great for non-instanceable prims, but it stops working when the prims are instanceable. The traversal seems to stop at the instances.


I did a quick experiment in Python, and it shows the desired behavior is possible via a modified traversal predicate:
rules = Usd.StageLoadRules.LoadNone()
predicate = Usd.PrimIsActive & Usd.PrimIsDefined
predicate = Usd.TraverseInstanceProxies(predicate)
for prim in stage.Traverse(predicate):
    model = Usd.ModelAPI(prim)
    if model.GetKind() == "component" and prim.HasPayload():
        rules.LoadWithDescendants(prim.GetPath())
stage.SetLoadRules(rules)

This works well on very complicated stages as well. It took only about 0.1 second. I included the full script in the attachment.

Does anyone know if something like this possible in Solaris? I could do this via a Python node, but the stage seems to remember the rules for other nodes as well. Thanks!
Edited by nd_sliu - Oct. 11, 2024 15:36:40

Attachments:
payload-under-instance.zip (724.1 KB)
houdini-setup.png (99.7 KB)

User Avatar
Member
30 posts
Joined: Sept. 2023
Offline
Update:

I kind of got this working by using the following Python snippet in the Configure Stage "Load Paths" parameter:
from pxr import Usd

stage = pwd().input(0).stage()

paths = ""
predicate = Usd.PrimIsActive & Usd.PrimIsDefined
predicate = Usd.TraverseInstanceProxies(predicate)
for prim in stage.Traverse(predicate):
    model = Usd.ModelAPI(prim)
    if model.GetKind() == "component" and prim.HasPayload():
        paths += prim.GetPath().pathString + " "

return paths

This feels a bit hacky lol. Wondering if there's a more Houdini-esque way of achieving this
Edited by nd_sliu - Oct. 11, 2024 21:00:39
User Avatar
Staff
4518 posts
Joined: July 2005
Offline
I'm surprised that you can have different payloads loaded under instanceable prims, but it looks like USD supports it... given this fact, the Configure Stage LOP should be allowing instance proxies on the "load paths from input" pattern, and the fact that it's not doing this is a bug. If you could please submit a bug report to support@sidefx.com someone can look into addressing this. Thanks!
  • Quick Links