Rendering simple image with Python like usdview

Hi!

I successfully cloned and built OpenUSD 25.5.1 and can run usdview. Now I’m trying to write a “Hello Hydra” application in Python that renders a simple image to buffer or file - very similar in functionality to usdview but without all the GUI elements, user interaction and other bells and whistles. Default hdStorm render delegate or hdEmbree if need be, default camera light, dome light or alternatively the light(s) coming with the scene.

The attached project & script HelloHydra.py HelloHydra.zip (3.4 KB) executes fine with MS VS Code and creates an output file. However, the rendered image is either all black or or completely transparent, depending on whether I use RGB or RGBA buffers. I tried a lot regarding projection matrix, buffer management, materials, lights and the Sphere.usda I was using, unfortunately to no avail.

Can someone more experienced than me explain what’s going on or point me towards some helpful documentation or even a working example? I want to avoid dissecting usdview if possible, as it looks rather complicated.

Thank you very much!

Have you taken a look at the usdrecord command line tool that is part of USD? It’s essentially what you’re describing, and should be easier to customize or use as a reference.

@dhruvgovil : Oh, terrific! As a quick shot, I tried

usdrecord Sphere.usda Sphere.png

which instantly worked like a charm. And there’s even a --renderer command line option to select my render delegate! So let’s hope usdrecord’s source code isn’t too complicated, Python development not really being my forte…

Thanks a lot for the helpful tip!