Hi folks,
I’ve been trying to figure out a way to make a layer that would work similarly to that of a Maya render layer workflow, at least in how one would construct them.
Here is what I have come up with, I’m hoping to get some feedback on the concept:
So assume we want to create a render layer for a shot, and say this shot is composed of many layers and references.
A “render layer” would be created by an additive process, meaning the user would pick the prim they would like to be part of this render layer.
Say they wanted a layer of only the characters, they would either manually pick or write an expression to collect the desired prims.
Once the list of prims is collected they would then create a new stage and define new prims using these selected prim paths and then reference the shot we had open and sub-root the same paths.
Here is an example of what that might look like:
# Example code
input_stage_path = 'sequences/000994/0010/shot.usda'
output_stage_path = '/RENDER_LAYER/TO/EXPORT.usda'
render_layer_prim_paths = ['/world/chr/chr_A_0001', '/world/chr/chr_B_0001', '/world/chr/chr_C_0001']
shot_stage = Usd.Stage.Open(input_stage_path)
# Create a new, empty stage to export the selected prims
render_layer_stage = Usd.Stage.CreateNew(output_stage_path)
# Copy the selected content to the new stage
for prim_path in render_layer_prim_paths:
prim = shot_stage.GetPrimAtPath(prim_path)
if prim:
render_layer_stage.DefinePrim(prim_path).GetReferences().AddReference(shot_stage.GetRootLayer().identifier, prim_path)
# Export the new stage to the output path
render_layer_stage.GetRootLayer().Export(output_stage_path)
Example output:
#usda 1.0
def "world"
{
def "chr"
{
def "chr_A_0001" (
prepend references = @sequences/000994/0010/shot.usda@</world/chr/chr_A_0001>
)
{
}
def "chr_B_0001" (
prepend references = @sequences/000994/0010/shot.usda@</world/chr/chr_B_0001>
)
{
}
def "chr_C_0001" (
prepend references = @sequences/000994/0010/shot.usda@</world/chr/chr_C_0001>
)
{
}
}
}
Now I’ve tried this in actual shots using a regular expression to get all the rocks assets as an example and the results seemed to be exactly what I was looking for.
A new layer with only the prims I want to render. They are also referencing the shot so the same layer would work even when new opinions are made to the prims in the composed shot.
This allows me to isolate and override the specific prims and render settings and can be done so for each render layer I can come up with.
Is there some downside to this that I am not seeing, or a better way?
Any insight into this would be much appreciated.
Cheers,
Jason Coelho