Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mours <pmours@nvidia.com>2022-03-21 12:58:51 +0300
committerPatrick Mours <pmours@nvidia.com>2022-03-21 15:23:25 +0300
commit08e719910bf2065ef0603cba8cc43ea236b2d090 (patch)
tree59894e7421aaec73691e653d5cc173ce12effbb3 /build_files/cmake/Modules/FindUSD.cmake
parent9ed63ebb458141661bcbfe81c187f843e9dcbacf (diff)
Cycles: Add Hydra render delegate
This patch adds a [Hydra](https://graphics.pixar.com/usd/release/glossary.html#usdglossary-hydra) render delegate to Cycles, allowing Cycles to be used for rendering in applications that provide a Hydra viewport (e.g. USDView or NVIDIA Omniverse Kit). The implementation was written from scratch against Cycles X, for integration into the Blender repository to make it possible to continue developing it in step with the rest of Cycles. For this purpose it follows the style of the rest of the Cycles code and can be built with a CMake option (`WITH_CYCLES_HYDRA_RENDER_DELEGATE=1`) similar to the existing standalone version of Cycles. Supported features: - CPU/CUDA/OptiX/HIP/Metal support - Camera Settings - Render Settings (automatically queried from Cycles via node type system) - Basic AOVs (color, depth, normal, primId, instanceId) - Lights (Disk, Distant, Dome, Rect, Sphere) - Meshes - Geom Subsets - Subdivision Surfaces (using native Cycles support) - Custom Primvars (converted to Cycles attributes) - Cycles Materials (can be exported to USD using the [universal-scene-description branch of Blender](https://developer.blender.org/diffusion/B/history/universal-scene-description/)) - USD Preview Surface Materials - Curves - Point Clouds - OpenVDB Volumes Still missing features: - Motion Blur - Custom AOVs - ... Since Hydra render delegates need to be built against the exact USD version and other dependencies as the target application is using, this is intended to be built separate from Blender (`WITH_BLENDER=0` CMake option) and with support for library versions different from what Blender is using. As such the CMake build scripts for Windows had to be modified slightly, so that the Cycles Hydra render delegate can e.g. be built with MSVC 2017 again even though Blender requires MSVC 2019 now, and it's possible to specify custom paths to the USD SDK etc. The codebase supports building against the latest USD release 22.03 and all the way back to USD 20.08 (with some limitations). This also includes an optimization for Hydra viewports that display the result using OpenGL, in which case the texture can be kept entirely on the GPU (see display_driver.cpp). Unfortunately this is a bit difficult since Hydra doesn't give any control over the OpenGL context created by an application, so the only way to make it available to Cycles (which is rendering on a separate thread) without disturbing the target application is to create a second OpenGL context that is sharing resources with the primary one. The USD SDK doesn't provide an API to do so, and can't use Blenders Ghost since the render delegate is built without Blender, so have to create it manualy. That is only implemented for Windows right now, so on Linux the optimization is disabled (see `HdCyclesDelegate::IsDisplaySupported()`). --- **To build:** 1. [Set up a Blender build environment](https://wiki.blender.org/wiki/Building_Blender) as usual but download and apply this patch to the Git repository (Download Raw Diff on the right via `Save Link As` and then run `git apply patch.diff` with the downloaded file in your local repository after syncing to latest master branch). 2. Set these CMake variables: ``` WITH_BLENDER=0 WITH_CYCLES_HYDRA_RENDER_DELEGATE=1 USD_INCLUDE_DIRS=<path to your USD build>/include USD_LIBRARY_DIR=<path to your USD build>/lib USD_LIBRARY_PREFIX=<optional, if e.g. USD libs are called "usd_hd.lib", set to "usd_"> ``` 3. Continue following the usual Blender build instructions. After building the INSTALL target, the output directory contains the `hdCycles` shared library and associated resource files which can be loaded as a USD plugin. **To execute:** 4. Copy `hdCycles.dll`/`hdCycles.a` and the `hdCycles` directory from the output directory to the USD plugin directory of the target application, or point a `PXR_PLUGINPATH_NAME` environment variable to the output directory. 5. Launch the target application, it should now automatically detect the Cycles Hydra render delegate. Differential Revision: https://developer.blender.org/D14398
Diffstat (limited to 'build_files/cmake/Modules/FindUSD.cmake')
-rw-r--r--build_files/cmake/Modules/FindUSD.cmake82
1 files changed, 46 insertions, 36 deletions
diff --git a/build_files/cmake/Modules/FindUSD.cmake b/build_files/cmake/Modules/FindUSD.cmake
index 840fa2d538f..c8c1f043b63 100644
--- a/build_files/cmake/Modules/FindUSD.cmake
+++ b/build_files/cmake/Modules/FindUSD.cmake
@@ -17,50 +17,60 @@ IF(NOT USD_ROOT_DIR AND NOT $ENV{USD_ROOT_DIR} STREQUAL "")
SET(USD_ROOT_DIR $ENV{USD_ROOT_DIR})
ENDIF()
-SET(_usd_SEARCH_DIRS
- ${USD_ROOT_DIR}
- /opt/lib/usd
-)
+find_package(pxr REQUIRED OFF)
-FIND_PATH(USD_INCLUDE_DIR
- NAMES
- pxr/usd/usd/api.h
- HINTS
- ${_usd_SEARCH_DIRS}
- PATH_SUFFIXES
- include
- DOC "Universal Scene Description (USD) header files"
-)
+if (NOT pxr_FOUND)
-FIND_LIBRARY(USD_LIBRARY
- NAMES
- usd_m usd_ms
- NAMES_PER_DIR
- HINTS
- ${_usd_SEARCH_DIRS}
- PATH_SUFFIXES
- lib64 lib lib/static
- DOC "Universal Scene Description (USD) monolithic library"
-)
+ SET(_usd_SEARCH_DIRS
+ ${USD_ROOT_DIR}
+ /opt/lib/usd
+ )
-IF(${USD_LIBRARY_NOTFOUND})
- set(USD_FOUND FALSE)
-ELSE()
- # handle the QUIETLY and REQUIRED arguments and set USD_FOUND to TRUE if
- # all listed variables are TRUE
- INCLUDE(FindPackageHandleStandardArgs)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(USD DEFAULT_MSG USD_LIBRARY USD_INCLUDE_DIR)
+ FIND_PATH(USD_INCLUDE_DIR
+ NAMES
+ pxr/usd/usd/api.h
+ HINTS
+ ${_usd_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include
+ DOC "Universal Scene Description (USD) header files"
+ )
+
+ FIND_LIBRARY(USD_LIBRARY
+ NAMES
+ usd_m usd_ms
+ NAMES_PER_DIR
+ HINTS
+ ${_usd_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib lib/static
+ DOC "Universal Scene Description (USD) monolithic library"
+ )
- IF(USD_FOUND)
- get_filename_component(USD_LIBRARY_DIR ${USD_LIBRARY} DIRECTORY)
- SET(USD_INCLUDE_DIRS ${USD_INCLUDE_DIR})
- set(USD_LIBRARIES ${USD_LIBRARY})
+ IF(${USD_LIBRARY_NOTFOUND})
+ set(USD_FOUND FALSE)
+ ELSE()
+ # handle the QUIETLY and REQUIRED arguments and set USD_FOUND to TRUE if
+ # all listed variables are TRUE
+ INCLUDE(FindPackageHandleStandardArgs)
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(USD DEFAULT_MSG USD_LIBRARY USD_INCLUDE_DIR)
+
+ IF(USD_FOUND)
+ get_filename_component(USD_LIBRARY_DIR ${USD_LIBRARY} DIRECTORY)
+ SET(USD_INCLUDE_DIRS ${USD_INCLUDE_DIR})
+ set(USD_LIBRARIES ${USD_LIBRARY})
+ ENDIF()
ENDIF()
+
+ UNSET(_usd_SEARCH_DIRS)
+
+ELSE()
+ SET(USD_FOUND ON)
+ SET(USD_INCLUDE_DIR ${PXR_INCLUDE_DIRS})
+ SET(USD_LIBRARIES ${PXR_LIBRARIES})
ENDIF()
MARK_AS_ADVANCED(
USD_INCLUDE_DIR
USD_LIBRARY_DIR
)
-
-UNSET(_usd_SEARCH_DIRS)