build_usd.py
script is a crucial tool for source builds, streamlining the process of downloading dependencies and compiling OpenUSD libraries and tools.OpenUSD, or Universal Scene Description, is a powerful, extensible software platform developed by Pixar Animation Studios for the collaborative construction and interchange of 3D scene data. While primarily developed on Linux, it is robustly supported on Windows and macOS, making it a versatile tool for industries ranging from film and animation to manufacturing and energy. This guide provides a comprehensive overview of how to build and run OpenUSD samples on a Windows environment, ensuring a smooth and efficient setup for developers and enthusiasts alike.
Successfully engaging with OpenUSD on Windows requires careful attention to prerequisites, environment configuration, and the correct execution of build and sample scripts. Whether you opt for the convenience of pre-built binaries or the flexibility of compiling from source, understanding the underlying steps is crucial for a productive development experience.
Before embarking on the OpenUSD installation and build process, it's vital to ensure your Windows system is adequately prepared. Meeting these prerequisites will prevent common installation issues and ensure a smooth development workflow.
cl.exe
) and CMake support.It's a good practice to verify that your essential tools are correctly installed and accessible from the command line:
python --version
.pip --version
.git --version
.cmake --version
.Ensuring these foundational tools are in place will streamline the subsequent steps for downloading and building OpenUSD.
Developers have two primary avenues for obtaining OpenUSD: leveraging pre-built binaries for a quick start or compiling from source for maximum control and customization. The choice depends on your specific needs and comfort level with build processes.
For immediate access to OpenUSD tools like usdview
and its Python API, NVIDIA provides fully bootstrapped pre-built binaries. This is the simplest and fastest way to get started without delving into complex compilation.
C:\USD
.usd-core
directly via PyPI:
pip install usd-core
You can verify this installation by running the following Python code:
from pxr import Usd
print(Usd.GetVersion())
This approach allows you to skip much of the manual compilation and directly proceed to exploring samples and using usdview
.
An illustrative banner highlighting OpenUSD's branding and 3D capabilities.
Building OpenUSD from source is essential for developers who need to integrate custom schemas, develop plugins, or require specific build configurations (e.g., enabling Vulkan support). While more involved, it offers unparalleled flexibility.
git clone https://github.com/PixarAnimationStudios/OpenUSD.git
cd OpenUSD
This will download the entire OpenUSD source code to your local machine.
The recommended method for building OpenUSD from source on Windows leverages the build_usd.py
Python script provided within the OpenUSD repository. This script automates dependency management and the compilation process.
cd C:\path\to\OpenUSD
build_usd.py
script, specifying your desired installation directory. For example, to install to C:\USD
:
python build_scripts\build_usd.py "C:\USD"
This script will download necessary external dependencies (like Boost, TBB), configure the build using CMake, compile the OpenUSD libraries and tools, and install them into the specified directory. This process can take a significant amount of time depending on your system's performance.
C:\Program Files
), you might need to run the command prompt as an administrator to avoid permission issues.build_usd.py
script generally handles this, but be aware of potential issues if you are manually configuring environments.After OpenUSD is built or extracted, you must configure your system's environment variables to enable the operating system and Python to locate the OpenUSD executables and Python modules.
OpenUSD typically installs its binaries (like usdview.exe
) in a bin
subdirectory and Python modules in a lib\python
subdirectory within your chosen installation path (e.g., C:\USD
).
You need to add these directories to your system's environment variables. This can be done temporarily in a command prompt session or permanently for all sessions.
Open a new Command Prompt (or the Visual Studio Native Tools Command Prompt if you're continuing from a build) and execute the following commands, replacing C:\USD
with your actual installation path:
set PATH=C:\USD\bin;%PATH%
set PYTHONPATH=C:\USD\lib\python;%PYTHONPATH%
For convenience, some OpenUSD distributions or build scripts might provide a batch file (e.g., setenvwindows.bat
) in the installation directory to automate this step.
For persistent access to OpenUSD tools, add these paths to your system's environment variables:
bin
directory (e.g., C:\USD\bin
).PYTHONPATH
: If it doesn't exist, click "New..." under "System variables", enter PYTHONPATH
as the variable name, and C:\USD\lib\python
as the variable value. If it exists, edit it to append your OpenUSD Python path, separated by a semicolon.After setting permanent environment variables, open a *new* command prompt for the changes to take effect.
Once environment variables are set, confirm your OpenUSD installation is functional:
usdview
: In a new command prompt, type:
usdview --version
This should display the version of usdview
, confirming it's recognized.
from pxr import Usd
print(Usd.GetVersion())
This should print the OpenUSD version, indicating the Python bindings are correctly configured.
OpenUSD provides a rich set of samples and tutorials to help users understand its core concepts and API usage. These samples are invaluable for learning how to author, compose, and manipulate 3D scenes using USD.
The OpenUSD ecosystem offers several categories of samples, each serving a distinct learning purpose:
extras/usd/tutorials
directory of the main OpenUSD GitHub repository. These cover fundamental concepts like "Hello World," inspecting properties, referencing layers, and transformations.These samples are typically Python scripts that generate .usd
files or C++ executables that perform specific USD operations. To run them:
cd C:\path\to\OpenUSD\extras\usd\tutorials
helloworld.py
):
python helloworld.py
usdview helloworld.usd
The first command runs the Python script to generate the USD file, and the second opens it in usdview
.
These samples demonstrate more advanced concepts and often come with their own build system, typically using CMake and Visual Studio.
git clone https://github.com/NVIDIA-Omniverse/usd-exchange-samples.git
cd usd-exchange-samples
usd-exchange-samples
repository often includes scripts to manage its dependencies (including OpenUSD itself if not already installed) and build the samples. Look for repo.bat
or similar batch files. For instance:
repo.bat install_usdex
repo.bat build
These commands will fetch necessary components and then build the sample projects, often generating Visual Studio solution files (e.g., in a _compiler
directory) that you can open to compile the executables.
A central tool for viewing and inspecting USD files generated by samples is usdview
. This lightweight viewer allows you to visualize 3D scenes, inspect properties, and understand scene composition. You can launch it from the command line:
usdview your_sample_scene.usd
Developing with OpenUSD on Windows involves navigating various complexities, from initial setup to long-term maintenance. The following radar chart illustrates key aspects of OpenUSD development on Windows, highlighting perceived difficulty and stability based on common developer experiences.
This radar chart provides a comparative view of user experiences when using pre-built binaries versus building OpenUSD from source on Windows. It highlights that while pre-built binaries offer a quicker and more stable initial setup and dependency management, building from source provides a superior debugging experience and greater control over performance optimization and tooling integration, albeit with higher initial complexity and potential build instability.
Understanding the different paths and their implications for OpenUSD development is key. The following mindmap visually represents the core concepts and workflows involved in getting started with OpenUSD on Windows, emphasizing the choices and processes available to a developer.
This mindmap provides a structured overview of the journey to build and run OpenUSD samples on Windows. It delineates the initial prerequisites, the two main paths for acquiring OpenUSD (pre-built vs. source), the crucial environment setup, and the various types of samples available. It also highlights key tools and essential learning resources, offering a clear roadmap for anyone starting their OpenUSD development on Windows.
While the comprehensive steps detailed above provide a solid foundation, sometimes a visual walkthrough can greatly enhance understanding. The following video offers insights into creating Python code samples for OpenUSD, a common way to interact with USD after your environment is set up.
How to Create Python Code Samples for OpenUSD. This video focuses on practical application of OpenUSD by demonstrating how to write and improve Python code samples, which is highly relevant once you have successfully set up your OpenUSD environment on Windows. It illustrates how developers can interact with USD stages and layers programmatically, a core aspect of OpenUSD development.
To consolidate the various aspects of building and running OpenUSD samples on Windows, the following table summarizes the key components, their purpose, and their relevance in the development workflow.
Component/Process | Description | Relevance to OpenUSD on Windows |
---|---|---|
Prerequisites (VS, Python, CMake, Git) | Essential software and tools required on your Windows system before installing or building OpenUSD. | Foundational for successful compilation from source and for running Python-based samples; ensures compatibility and necessary build environments. |
Pre-Built Binaries (NVIDIA) | Pre-compiled OpenUSD libraries and tools provided by NVIDIA. | Ideal for quick setup and immediate access to usdview and Python APIs without complex compilation. |
Source Code (GitHub) | The official OpenUSD repository containing the complete source code. | Required for developers needing to build custom plugins, schemas, or specific configurations; offers maximum control. |
build_usd.py Script |
A Python script automating the OpenUSD source build process, including dependency fetching and compilation. | Crucial for streamlining the complex process of building OpenUSD from source on Windows, managing external dependencies. |
Environment Variables (PATH, PYTHONPATH) | System variables that direct the OS and Python interpreter to OpenUSD executables and modules. | Necessary for the system to locate and execute OpenUSD tools (e.g., usdview ) and for Python scripts to import pxr modules. |
usdview |
The official OpenUSD scene viewer. | An indispensable tool for visualizing, inspecting, and debugging .usd files generated by samples or authored scenes. |
OpenUSD Repository Tutorials | Code examples found in extras/usd/tutorials of the OpenUSD GitHub repo. |
Basic samples illustrating core OpenUSD concepts (e.g., "Hello World," layering, transformations) using Python and C++. |
NVIDIA Omniverse USD Exchange Samples | Samples demonstrating advanced OpenUSD Exchange SDK usage and converters. | Provides practical examples for interoperability and more complex USD workflows, often with their own build instructions. |
Python API (pxr module) |
The Python bindings for OpenUSD, allowing programmatic interaction with USD stages. | Enables scripting, automation, and integration of OpenUSD functionalities into Python-based pipelines and applications. |
build_usd.py
script and ensuring all prerequisites are met significantly mitigates these issues.usdview
and why is it important?usdview
is the official graphical viewer for Universal Scene Description (USD) files. It is an invaluable tool because it allows developers to visually inspect USD stages, explore their hierarchy, examine properties, and debug scene composition. It helps confirm that your authored or generated USD files are correct and helps in understanding how different layers and assets are resolved in a scene.usdview
and its Python API without going through the potentially time-consuming and complex process of compiling everything from source and resolving dependencies. This is ideal for quickly getting started, learning, and running samples.PATH
for DLL dependencies; the OpenUSD build scripts usually handle this automatically, but it's a detail to keep in mind for manual setups.Building and running OpenUSD samples on Windows is a foundational step for engaging with this powerful 3D scene description platform. While the process can involve several prerequisites and environment configurations, the availability of both convenient pre-built binaries and comprehensive source build scripts (like build_usd.py
) offers flexibility for different developer needs. By meticulously following the steps for installing necessary tools, setting up environment variables, and leveraging the diverse sample repositories, you can effectively begin your journey into OpenUSD development. Whether for learning core concepts with tutorials or exploring advanced interoperability with Exchange SDK samples, a well-configured Windows environment provides a robust foundation for creating and manipulating complex 3D scenes.