Converting Between Layer Formats

This tutorial walks through converting layer files between the different native USD file formats. USD includes three native file formats:

Extension

Content

.usda

Human-readable text

.usdc

Random-access binary

.usd

Either of the above

The usdcat tool is useful for inspecting these files, but it can also convert files between the different formats by using the -o option and supplying a filename with the extension of the desired output format. Here are some examples of how to do this.

Converting between .usda/.usdc and .usd

A .usd file can be either a text or binary format file. When USD opens a .usd file, it detects the underlying format and handles the file appropriately. You can convert any .usda or .usdc file to a .usd file simply by renaming it. For example:

  • Given Sphere.usda, you can simply rename it to Sphere.usd.

    • When USD opens Sphere.usd, it detects that it uses the text file format and opens it appropriately. This works similarly for .usdc files.

  • A Sphere.usd file that uses the text format can be renamed to Sphere.usda

  • A Sphere.usd file that uses the binary format can be renamed to Sphere.usdc.

Converting between .usda and .usdc Files

Consider Sphere.usda in USD/extras/usd/tutorials/convertingLayerFormats. This is a text format file, so it can be examined in any text editor or via usdcat.

$ usdcat Sphere.usda

#usda 1.0
def Sphere "sphere"
{
}

To convert this file to binary, we can specify an output filename with the .usdc extension:

$ usdcat -o NewSphere.usdc Sphere.usda

This produces a binary file named Sphere.usdc in the current directory containing the same content as Sphere.usda. We can verify this using usddiff:

$ usddiff Sphere.usda NewSphere.usdc

Converting binary to text can be done the same way:

$ usdcat -o NewSphere.usda NewSphere.usdc
$ usddiff NewSphere.usdc NewSphere.usda

Converting between .usd Files of Different Formats

Note

If you have a .usda or .usdc file and want to make it a .usd file without changing the underlying format, you do not need to use usdcat; just rename the file. See Converting between .usda/.usdc and .usd above.

If you have a .usd file of a particular format and want to convert it to a .usd file using a different format, pass the --usdFormat option to usdcat. Starting with Sphere.usd in USD/extras/usd/tutorials/convertingLayerFormats, which is a text format file, we can converty to a binary format file:

$ usdcat -o NewSphere_binary.usd --usdFormat usdc Sphere.usd

We can verify the two files match:

$ usddiff Sphere.usd NewSphere_binary.usd

Convert a binary .usd file to a text .usd the same way:

$ usdcat -o NewSphere_text.usd --usdFormat usda NewSphere_binary.usd
$ usddiff NewSphere_binary.usd NewSphere_text.usd