/USD-Cookbook

A collection of simple projects for Pixar's open-source Universal Scene Description

Primary LanguageMathematicaMIT LicenseMIT

This repository is a collection of simple USD projects. Each project shows off a single feature or group of USD features.

Structure summary

This repository is split into six categories

  • Features
  • Concepts
  • Tricks
  • Plugins
  • Tools
  • References

Features highlight a single class or set of functions for working in USD.

Concepts take features explained in Features and extends them to real-world examples.

Tricks are simple, isolated ideas using USD Features.

Plugins show how to customize USD to suit your pipeline.

Tools are miscellaneous scripts that are built to do a specific task, with USD.

References are articles that show where to find more information.

Every project in this repository will show how to work in Python, C++, and USDA wherever possible.

How to view

If a concept folder is trying to show off a USD feature but it takes a lot of code then the top-level README.md file is there to summarize the important bits. It may also refer to other resources for where to read more.

Lastly, source-code files may contain explanations for what is shown. Each of these lines is marked with XXX.

How to build

C++

Unless a C++ project has specific instructions, every project compiles and executes using the following commands:

cd {some_concept_cpp_folder}/build
USD_INSTALL_ROOT=/wherever/you/installed/USD/to cmake ..
make
./run_it

USD_INSTALL_ROOT typically defaults to /usr/local/USD on Linux but your location may vary. See USD's build documentation for details.

Python

Python modules can always run using python name_of_module.py

Sections

Here are links of a recommended viewing order for every project in this repository.

Features

Adding comments to USD files

SetKind onto UsdPrim

specializes composition arc

Using Prim AssetInfo

Defining customizable userProperties

Value resolution caching

Computing bounding boxes, using UsdGeomImageable and UsdGeomBBoxCache

Pixar's specializes example

Using "purposes" on UsdPrim objects

UsdResolveInfo - Finding where opinions come from

Enable debugging messages and write your own

Profiling USD stages

How to use Value Clips

SdfChangeBlock - Efficient USD authoring

SdfBatchNamespaceEdit and SdfNamespaceEdit - Efficient USD authoring

UsdStageCache - caching USD stages

TfNotice - Run functions when a stage changes, using callbacks

TfNotice - Send your own custom callbacks

Concepts

Overriding VariantSets

How to uniquify an instanced UsdPrim

UsdRelationship Forwarding

Using VariantSets in a production scenario

A practical example of the "specializes" composition arc

The "specializes" composition arc as a fallback mechanism

Reference a Prim in the current SdfLayer

How to find "Orphaned" overs

A mesh with a material

Asset composition arcs - how subLayers, references, and payloads work together

Tricks

Printing and modifiying prims using the C++ STL

Custom traversals with boost

Variant auto-selections - Using VariantSets to modify other VariantSets

Copy opinions from a VariantSet onto another Prim

Find a Prim's bound material (includes collections API)

2-pass exporting - Export USD stages 100x faster

Flatten a USD layer stack

Multi-payloads - Yes, you can have more than one

Plugins

usdview_auto_reloader - Update layers in usdview automatically

usdview_root_loader - Recursively load / unload Prim payloads

VariantSet fallback selections

VariantSet selection export polices

Adding custom metadata

Custom USD schemas

Tools

A custom ArResolver plugin

usd_searcher - A command-line tool for searching USD files

Exporting UsdSkel from scratch

References

Understanding usdview

The USD supported plugin mastersheet

Where to find more resources

Studying

There's also Anki deck for this repository, which you can download by clicking here

Roadmap

See This wiki page for a list of planned topics that will be added in the future.

Contributing

This repository is a constant WIP. If there's something that you'd like to see written about, please suggest it as an issue so that I / others can pick it up and work on it. Also, if you have something that you'd like to contribute, please make a PR. Submissions are welcome!

Disclaimer

But note: This repository may not actually show the best way to do things in USD. It's just a collection of (my) personal findings. Also, as Pixar comes out with new USD releases and learning resources, this information may become out-of-date. Always prefer primary guides and documentation over anything that you see here.

Final Note

Tested with:

  • CentOS 7.6
  • USD 19.07
  • cmake version 3.13.4
  • make 3.82
  • g++ 8.3.0