Write mute state of layers to USD output

   2951   4   3
User Avatar
Member
15 posts
Joined: Dec. 2019
Offline
Hi,

Is there a way to keep the mute state of a USD layer, when writing out a Stage to file?

Let's say you sublayer in two USD files (fileA.usd and fileB.usd).

In the graph, you mute fileB.usd using the Configure Stage lop node.

Then you write out this composed stage to a new file myStage.usd.

When loading in myStage.usd both the fileA.usd and fileB.usd are active and it doesn't look like the muting of fileB.usd has been preserved.
User Avatar
Staff
4525 posts
Joined: July 2005
Offline
Layer muting, population masks, and payload masks have no way to be expressed in the authored USD layers. If you flatten the USD stage to a single USD file these muting and masking decisions are essentially "baked in" to the resulting USD file, but obviously there are a lot of implications to flattening a stage that make it fairly unattractive for many workflows.
User Avatar
Member
15 posts
Joined: Dec. 2019
Offline
So there's no, none destructive/flattening way, to disable/mute a layer in the Solaris graph and have that propagate to the resulting USD file, that will be passed to HUSK?

I guess a workflow could be to save the state of each USD layer as metadata within the Stage and use a pre-render script within HUSK to mute layers based on that.
User Avatar
Member
136 posts
Joined: Oct. 2020
Offline
"Configure Stage" LOP can be used to mute layers and I think it will pass down to Husk.
https://www.youtube.com/channel/UC4NQi8wpYUbR9wLolfHrZVA [www.youtube.com]
User Avatar
Member
66 posts
Joined: May 2019
Offline
For me, muting only worked after using Python LOP which seems to have effect on the actual saved USD file, I guess (thanks to USD Survival Guide Layer Muting [lucascheller.github.io]):

from pxr import Sdf

# List of layer paths
layerPaths = [
    "<absolute-path-to-layer-file>/usd/LAYERS/moss-scatter-MID-SIDE-layer.usd",
    "<absolute-path-to-layer-file>/usd/LAYERS/moss-scatter-RIGHT-SIDE-layer.usd",
    "<absolute-path-to-layer-file>/usd/LAYERS/moss-scatter-LEFT-SIDE-layer.usd"
]

# Iterate over each layer path
for l in layerPaths:
    # Open the layer using FindOrOpen
    layer = Sdf.Layer.FindOrOpen(str(l))  # Ensure l is treated as a string
    if layer:  # Check if the layer was successfully opened
        Sdf.Layer.AddToMutedLayers(layer.identifier)
    else:
        print(f"Failed to open layer: {l}")


Then to load those muted layers back I replaced Sdf.Layer.AddToMutedLayers(layer.identifier)with Sdf.Layer.RemoveFromMutedLayers(layer.identifier)

To be clear, I'm not sure how it is supposed to be yet. I decided to share experiments.

You can also add a checkbox parameter, read it using Python, and use the same node to hide/unhide the same USD layer paths.

Edited by AnimGraphLab - Sept. 11, 2024 01:50:50

Attachments:
houdini_ydrua3p2Nm.gif (12.0 MB)

Generalist. Transforming still images to 3D animation 🔮
Socials: https://linktr.ee/AnimGraphLab [linktr.ee]
  • Quick Links