Simple USD Render View Example with Qt C++ / QML

Michael T. Wagner
3 min readJan 3, 2021

Pixar’s open source Universal Scene Description (USD) framework has greatly improved collaboration workflows and pipelines for digital content creation in the animation movie studios all around the world.

“USD is gaining traction, even outside our industry, because it allows us to have a massive scale of complexity and the ability to work within that complexity, in multiple departments at the same time,”. — Steve May, CTO Pixar

Since there are similar challenges with fractured workflows due to data silos in other domains like architecture, engineering and construction or digital factory, USD could indeed become the lingua franca to describe complex 3d digital twin environments, especially with the upcoming nvidia omniverse platform adding live updates, simulation and realtime raytracing on top.

Getting started

It’s not really trivial to build the USD libraries on windows from source out of the box, there are several descriptions how to do it though (see a curated list of resources here). Things get smoother with the prebuilt libraries provided by nvidia here. The actual rendering is done with the Hydra framework which is also part of the USD distribution.

Most examples and tutorials are written in python using the python bindings of the framework, also the standard viewing tool usdview is using the Qt-python (PySide) bindings.

Since I didnt find an example which demonstrates the direct integration of the hydra render output into a native Qt C++ application, I thought it would be a nice idea to create one.

Switch Example

nvidia engineer Victor Yudin has, among other cool stuff, created a minimalistic example which renders USD using Hydra GL on windows using the GLFW library.
So I’ve used his scene and logic and tried to move that to a Qt based window.

GLFW-Implementation (Original)

The original implementation uses a GLFW window.

see https://github.com/mtw75/switch_qt/tree/main/switch_demo ( copied from Victors example and adapted to current nvidia distribution )

QWidget Implementation

The QWidget based implementation uses a QOpenGLWidget as output window but everything else is basically the same as in GLFW implementation.

see https://github.com/mtw75/switch_qt/tree/main/switch_demo_qt

Implementation is straight forward, only thing to do is to use the QT_NO_KEYWORDS definition because there is a conflict with Qt moc handling and the USD python bindings.

QML QuickItem Implementation

The QML implementation uses a QQuickFramebufferObject to display the 3d scene.

https://github.com/mtw75/switch_qt/tree/main/switch_demo_qml

The actual rendering takes place in a QuickFramebufferObject::Renderer, note that it can run in the QML render thread which may not be the main application thread. Therefore the mouse information is duplicated in the renderer and synchronized from the item as required. Anoher thing to remember is to set the mirrorVertical-flag and to activate mouse handling in the item.

So wether you’re going with QWidgets or QuickItems now you should be able to get going with USD standalone visualization — or go the python way creating a plugin for usdview (see description)or omniverse kit (see programming manual).

--

--

Michael T. Wagner

CTO and Co-Founder @ipolog.ai & synctwin.ai, creating clever solutions for smart factory