Flattening assets: Worked Example — Pipeline Development (NVIDIA-Certified Professional: OpenUSD Development)
Flattening Assets: A Step-by-Step Worked Example Flattening assets is a critical process in OpenUSD pipeline development that consolidates complex...
Flattening Assets: A Step-by-Step Worked Example
Flattening assets is a critical process in OpenUSD pipeline development that consolidates complex, layered USD compositions into a single, self-contained asset. This simplifies downstream consumption, improves portability, and ensures consistency across different stages of a 3D content creation pipeline.
Below is a detailed worked example illustrating the flattening process applied to a realistic scenario within an OpenUSD pipeline.
Scenario
Your pipeline ingests multiple USD layers representing a character asset: a base geometry layer, a materials layer, and an animation layer. These layers are composed into a root USD stage for rendering and simulation. The goal is to flatten this composition into a single USD file for efficient distribution to the rendering farm.
Step 1: Load the Root USD Stage
Begin by opening the root USD stage that references all constituent layers.
Code Snippet
stage = Usd.Stage.Open("/path/to/character_root.usd")
This stage represents the fully composed character asset, including geometry, materials, and animation.
Step 2: Prepare the Flattening Target Path
Decide on the output path for the flattened asset. This file will contain all data from the composed layers merged into one.
Example
Output path: /path/to/character_flattened.usd
Step 3: Perform the Flattening Operation
Use the Flatten() method provided by the USD API to merge all referenced layers and sublayers into a single layer.
Code Snippet
flattenedLayer = stage.Flatten()
This creates an in-memory layer containing the complete flattened composition.
Step 4: Save the Flattened Layer to Disk
Write the flattened layer to the target USD file path.
Code Snippet
flattenedLayer.Export("/path/to/character_flattened.usd")
This produces a single USD file encapsulating all geometry, materials, and animation data.
Step 5: Verify the Flattened Asset
Open the flattened USD file independently to ensure it contains all expected data without external references.
Verification
- Check that references and payloads are resolved and embedded.
- Confirm that the asset renders correctly in your USD viewer or renderer.
- Validate that no external dependencies remain.
Step 6: Update Pipeline Documentation and Versioning
Document the flattening step in the pipeline's process documentation, noting the input layers, output file, and any configuration parameters used. Increment the asset version to track changes.
Summary
Flattening assets consolidates multiple USD layers into a single file, enhancing portability and simplifying downstream workflows. This example demonstrated the practical steps using the USD API to flatten a composed character asset, save it, and verify its integrity.
Mastering asset flattening is essential for pipeline developers preparing 3D content for rendering, simulation, or distribution in professional OpenUSD environments.
More in this topic
Ready to test your knowledge?
Put what you've learned into practice with a quick quiz and track your progress.
Test your knowledge →