# Compositions

This guideline focuses on what a "Composition" is and introduces a practical example on how to use it.

# Basic Concept

Composition is a writing process that allows us to combine multiple USD Compounds into a single one.

Note that the actual data is not stored inside the composition, instead the composition "points at" those files. Compositions are typically very small sized files on disk.

A quick way to understand is to simply write your composition to a .usda file and inspect the file into your favorite text editor: you will then see how the USD asset files are pointed at, along with their file paths.

Typically you will see that an Compound is pointed at using a "USD Reference", and any eventual instance of a Compound is pointed at using a "USD Instance".

A couple of notes:

  • You can recursively create compositions containing previously generated compositions.
  • You can "flatten" compositions, in this case the data of the assets will be stored into the composition, making the file "portable". In this case the data will be contained in the composition and therefore the file size might be large.
  • Ideally the consolidation process flows down into the pipeline so that when you are in lighting your scene could contain very few Multiverse Compounds each of them would represent different compositions.

Now, let’s say we have a scene that contains a table and five glasses. Instead of modeling the table and the glass together and then write it as a single asset, we can instead have separate assets for the table and for the glasses.

Afterwards we can use Multiverse to read each USD asset into a new Maya scene, this will generate Compound nodes. We can then instance the glasses and arrange the table with the five glasses into a proper hierarchy simply by moving them and grouping them. Finally we write it out as a USD composition.

Now we can use that composition in other scenes as a single entity.

The benefit of this is that even though now the table and five glasses are in one scene (composition), if there are any changes to the table asset we just need to replace the table asset file and the composition will update automatically on file reopen / refresh, and/or on-demand depending on your asset resolution pipeline. This is a very powerful features especially if you have hundreds of individual assets being used in different scenes.

# Practical Example

Let’s start with a simple asset of a filled bath tub that also contains our Maneki Neko and several teapots, whom he enjoys to play with. Ultimately this is the final result we want to create in this example: a cat in a bath tub with some teapot toys to play with.

Bath tub asset contains Maneki cat and teapots


Bath tub hierarchy

If we inspect the content of bathTubWithNeko, we’ll see that it contains the bath tub, the cat and the teapots properly arranged in a clean hierarchy. Each of these assets has being combined into one single composition. Also notice that in MEOW some locations have specific colors: the locations with an orange label are references, meaning they reference each individual external USD assets.

Note

USD references and not Maya references: remember that when you read USD data with Multiverse there is no data in Maya, and everything is streamed to Maya.

Likewise, the teapot asset has being instanced and it is represented by the light blue color label.

TIP

Click on the "?" icon in MEOW to understand the meaning of icons & colors.

If there is any update on the cat, bathtub or teapot models, the changes will be updated automatically for this bathTubWithNeko composition, so there’s no need to rewrite again the composition for every change.

In order to create the composition shown above first we read each assets with Multiverse into a new Maya scene.

Read bathTub, neko and teapot assets

We can rename the asset compound nodes and arrange them into groups. It is recommended to create a proper hierarchy if we are planning to compose a larger assets from a series of smaller assets as you can see below.

Arrange assets to form a bigger composition

From here we can select the root of our hierarchy and write the the composition using the Write USD Composition shelf menu. After writing the composition we should have the single asset that we’ve seen in the beginning of this section.

We can use the asset in other scenes or even make a bigger composition authoring a new composition in different Maya scene. We can also make further changes for it by using overrides.

# Object Types and Compositions

We can make a composition from any USD asset: mesh, instances, animation, particles, etc... as long as the type is supported then we can use it to create a composition.

The basic workflow is:

  1. Write your assets via Write USD Asset.
  2. Read the USD assets in Maya and arrange them into a composition organizing them into a hierarchy using Maya transform nodes (groups). Feel free to including Maya instances (duplicate as instance), MASH (Maya particle instancing) etc.
  3. Write composition using Write USD Composition.
  4. Use the composition in different scenes or make a new composition based from it.

# Composing layers

The compounds that are part of a composition may very well have multiple layers of data, each represented by a usd file, visible in the Compound Attribute Editor. When we write a composition these layers are preserved as-is, the composition will simply point at them.

# Conclusion

Composition is yet another powerful feature that allows you to compose assets into a bigger and complex scene. This method allows us to divide and conquer, it is easier to handle smaller things which leads to bigger results.

Last Updated: 5/26/2022, 3:36:09 PM