Cycles Hydra Render Delegate and USD feedback

First of all good job on updating the build system for the delegate.

I experimented with the Hydra delegate today and got it running on some test scenes.
Here are some of my observations:

  • hdCycles does not build with Houdini 18.5.* (i.e., USD v20.08)
  • the minimum USD version is 21.03 (this introduces HdMaterialNetwork2)
  • the when building against plain USD the minimal supported version is 21.11 since this adds the --use-cxx11-abi 0 option
  • _stageMetersPerUnit is set to 0.01 by default. This breaks lighting since the scene is rescaled but not the light parameters (which are usually in radiance). Is there a reason why _stageMetersPerUnit is not 1.0 or why the scene scale needs to be adjusted in the first place?
    *the environment map is wrongly oriented (the horizon is rotated by 90 deg)
    *when there is no envmap there seems to be always a white/gray constant background light
    I will post some renderings and comparisons to Karma later.

Is there a plan for some validation tests against publicly available USD scenes like
ALab, Moana, Sponza?

Thanks for the details on the minimum USD and Houdini versions. I added those to the building docs now.

I also noticed various incompatibilities with lighting (and camera DoF.) It seems there is a problem in Blender’s USD exporter at least, see:
https://developer.blender.org/D14630#394344

Getting this validated with various public scenes and Blender exported scenes is certainly something we should do. Not sure when I or someone else will get to it, but it’s probably the most important thing to fix now.

@pmoursnv would know more about the reasons for _stageMetersPerUnit.

@brecht No problem.
I think it would make sense to try adding support for at least USD v20.08.
The main thing which needs to be implemented is the support for the old MaterialNetwork,
which shouldn’t be so hard. This would allow using Houdini 18 and the ALab scene.

From my experiences, Houdini Solaris and the Karma renderer are currently the best way to validate a delegate, since Solaris is able to generate -pure- USD scenes and Karma renders them pretty strict to the USD definition (i.e., since Karma is written around USD).

If I find some time I can help with some of the delegate work.
Especially when it comes to validating and setting up the lighting and material (i.e., USDPreviewShader) part.

@brecht thx for the update


windows build, houdini 19.0.561:
-i get again the empty solaris viewport
this is not fixed for windows, right?
-with usdrender node in “out” i get some rendering in mplay, but as @sherholz mentioned the env rotation matrix is wrong

-the usdpreviewsurface supports only diffuse color at the moment, right? (cant see any reflections yet)


edit: oh missed that #if 0 hack from @pmoursnv. have to try


ok, the #if 0 hack in render_delegate.cpp works now and the solaris viewport is no longer empty. but the material doesnt refresh when changing parameters, only when switching forth and back between karma and cycles

also opacity with refraction seems not to work properly in the usdpreviewsurface material


@brecht The DoF issue is also happening because the Blender USD exporter currently always writes out “focalLength”, “horizontalAperture” and “verticalAperture” in millimeters, but the spec declares those as “tenths of a scene unit”. Since the scene unit is set to meters (“metersPerUnit” is 1), rather than the USD default of centimeters, these should be in decimeters instead. With that changed in the USD file (simply multiplied the values by 0.01 and saved again), DoF starts behaving correctly.
Based on a comment in the relevant exporter code (usd_writer_camera.cc · rB) this was intentionally done though because usdview was misbehaving 
 So not sure how that is best addressed. But I’ll mention these things to Michael who’s been working on the USD importer/exporter.

@sherholz I had it building against a modified USD 20.08 fork that cherry-picked HdMaterialNetwork2, hence the comment about 20.08 working with some limitations in the original patch, but that’s not particularly useful for anybody else of course =P
_stageMetersPerUnit is set to 0.01 by default since that is the USD default (centimeters), whereas Blender/Cycles generally operates in meters. It is expected that the Hydra application overrides that to the USD metersPerUnit metadata value via the provided render setting, like Houdini does. This was necessary since light parameters are not scaled by Hydra, but the Blender USD exporter from the “universal-scene-description” branch (https://developer.blender.org/diffusion/B/history/universal-scene-description) supports exporting USD in either meters (metersPerUnit = 1) or centimeters (metersPerUnit = 0.01) and rendering the latter would thus look different even though they should look the same.
I’m guessing the environment is wrongly oriented because the render delegate is currently assuming a Z up axis (as that is what USD exported from Blender is using), so won’t behave right if the rendered USD is using a Y up axis (which is the default). This could probably be solved with another render setting.

had a look at the 
/hydra/material.cpp and i see that the “opacity” of a usdpreviewsurface is mapped to the “alpha”


karma treats “opacity” as refraction/transmission.
shouldnt it be mapped to something like “transmission”?

Kind of. I am currently investigating this.
The problem here is that opacity does not directly map to transmission, 1-opacity does.

Before:
https://1drv.ms/u/s!At4sZlTrZ-QKiWW4Rg9uCkBQDW7M?e=uP3sWv
After:
https://1drv.ms/u/s!At4sZlTrZ-QKiWaE4TZiqYZBcxxX?e=r4AX9f

The latter one also has some changes to the light parameters to match Karma but is still WIP.
The main problem is that textured opacity requires us to set up some additional node system.

@brecht the black areas are caused by self-intersection the wall and the background plane of the shelf are exactly on top of each other.

Ideally, we will end up in something like this:

Hello,

I am working on the integration of Cycles in our 3D application using the Hydra render delegate and the USD format. It works quite well.

I made some small fixes in the hydra folder that I would like to submit to be added in the official repo.
@brecht, are you a reviewer for the pull requests? Or should I ask to someone else?

Best regards,
Nicolas

7 Likes

Yes, you can add me as reviewer. I can add additional reviewers when needed.

6 Likes

It doesn’t seem like roughness or IOR works with both USD Preview surface or MaterialX surfaces using Houdini 19.5 on macOS with M2 Max

hi,

builded newest cycles (v4.2) for houdini 20.0.590 as described in the build info, set the corresponding env variables for houdini_path and pxr_pluginpath_name, i see the usd plugin folder and the hdCycles.dll in it, but when starting houdini solaris, cycles shows in the renderer list on startup, but as soon as i choose it i get this message and cycles disappears from the list. any hints?

also setting the PATH = "<path/to/cycles_install/>" doesnt help, and getting same error in houdini.
it doesnt load the hdCycles plugin


AND when building cycles with houdini + CUDA binaries ON, i get this errors

with CUDA binaries OFF, i can build it.

(BTW, building against houdini 20.5.332 is even worse
houdini than crashes to desktop)

any hint? Please!!!

window.cpp
libosdCPU_md.lib(level.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__std_find_trivial_4" in Fu
nktion ""int const * __cdecl __std_find_trivial<int const ,int>(int const *,int const *,int)" (??$__std_find_trivial@$$
CBHH@@YAPEBHPEBH0H@Z)". [D:\PLUGIN-PROG\CYCLES\cycles\build\src\app\cycles.vcxproj]
libosdCPU_md.lib(fvarLevel.obj) : error LNK2001: Nicht aufgelöstes externes Symbol "__std_find_trivial_4". [D:\PLUGIN-P
ROG\CYCLES\cycles\build\src\app\cycles.vcxproj]
D:\PLUGIN-PROG\CYCLES\cycles\build\bin\Release\cycles.exe : fatal error LNK1120: 1 nicht aufgelöste Externe [D:\PLUGIN-
PROG\CYCLES\cycles\build\src\app\cycles.vcxproj]
  Building Custom Rule D:/PLUGIN-PROG/CYCLES/cycles/third_party/hipew/CMakeLists.txt
  hipew.c
  extern_hipew.vcxproj -> D:\PLUGIN-PROG\CYCLES\cycles\build\lib\Release\extern_hipew.lib
  Building Custom Rule D:/PLUGIN-PROG/CYCLES/cycles/src/hydra/CMakeLists.txt
  plugin.cpp
libosdCPU_md.lib(level.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__std_find_trivial_4" in Fu
nktion ""int const * __cdecl __std_find_trivial<int const ,int>(int const *,int const *,int)" (??$__std_find_trivial@$$
CBHH@@YAPEBHPEBH0H@Z)". [D:\PLUGIN-PROG\CYCLES\cycles\build\src\hydra\hdCycles.vcxproj]
libosdCPU_md.lib(fvarLevel.obj) : error LNK2001: Nicht aufgelöstes externes Symbol "__std_find_trivial_4". [D:\PLUGIN-P
ROG\CYCLES\cycles\build\src\hydra\hdCycles.vcxproj]
D:\PLUGIN-PROG\CYCLES\cycles\build\src\hydra\Release\hdCycles.dll : fatal error LNK1120: 1 nicht aufgelöste Externe [D:
\PLUGIN-PROG\CYCLES\cycles\build\src\hydra\hdCycles.vcxproj]

Hello,
I just tried to build Cycles as a Hydra delegate for Houdini. I successfully built it, I have Cycles available as a renderer in Houdini’s viewport but as soon as I click on it Houdini crashes, and I have this log:

Crash report from 68fc151a; Houdini FX Version 20.5.445 [windows-x86_64-cl19.35]
Uptime 19 seconds
Wed Jan 22 18:22:50 2025
Caught signal 11

Traceback from 25752 ThreadId=0x00001b98
CURRENT THREAD 7064
+0x15624f50 [JEDI_SceneGraphView::supportsViewCameras] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libJEDI.dll
+0x15e1980e [GUI_DetailLook::updateForRenderInit] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libGUI.dll
+0x160ef35b [DM_VPortAgent::setupGeometry] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libDM.dll
+0x160eb1bf [DM_VPortAgent::renderViewport] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libDM.dll
+0x160d14e3 [DM_VPortAgent::doRender] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libDM.dll
+0x160a3ab2 [DM_Viewport::doRender] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libDM.dll
+0x11f1c921 [UI_Feel::renderMe] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x11f16201 [UI_Feel::doRenderKids] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x11f1611b [UI_Feel::doRender] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x11f1c921 [UI_Feel::renderMe] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x11f16201 [UI_Feel::doRenderKids] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x11f1611b [UI_Feel::doRender] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x1204dec9 [UI_Viewport::reRender] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x120541f7 [UI_Window::renderChildViews] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x12050ed1 [UI_Window::doRedrawSubclass] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x160920b6 [DM_ViewLayout::doMakeTriple] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libDM.dll
+0x12050d3e [UI_Window::doRedraw] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x11fe8b85 [UI_Queue::doWindowRedraws] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x11fe8c73 [UI_Queue::drain] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x11fe94e8 [UI_Queue::eventLoop] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libUI.dll
+0x1097dc6f [AP_Interface::loadWindowGeometry] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libSI.dll
+0x1097e815 [myWinMain] C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\libSI.dll
+0x1400015a2 C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\houdini.exe
+0x140001a32 C:\Program Files\Side Effects Software\Houdini 20.5.445\bin\houdini.exe
+0x7ff82b1ae8d7 [BaseThreadInitThunk] C:\WINDOWS\System32\KERNEL32.DLL
+0x7ff82c05fbcc [RtlUserThreadStart] C:\WINDOWS\SYSTEM32\ntdll.dll

I then tried to run usdview taht comes with Houdini to see if it was different. Usdview opens but I have this error in the terminal:

Traceback (most recent call last):
  File "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.445\python311\Lib\site-packages\pxr\Usdviewq\stageView.py", line 1646, in paintGL
    renderer = self._getRenderer()
               ^^^^^^^^^^^^^^^^^^^
  File "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.445\python311\Lib\site-packages\pxr\Usdviewq\stageView.py", line 959, in _getRenderer
    self._renderer = UsdImagingGL.Engine(params)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
pxr.Tf.ErrorException:
        Error in 'pxrInternal_v0_24__pxrReserved__::PlugPlugin::_Load' at line 261 in file C:\cygwin\home\prisms\builder-new\WeeklyDevTools20.5\dev_tools\src\usd\usd-24.03\USD-py3.11-qt5\pxr\base\plug\plugin.cpp : 'Failed to load plugin 'hdCycles': The specified module could not be found.
 in 'f:/prog/cycles_git/cycles/install/houdini/dso/usd_plugins/hdCycles.dll''

To build it I followed the building process here
Is there anything I could do to fix this issue ?