diff options
author | Patrick Mours <pmours@nvidia.com> | 2020-10-02 18:40:28 +0300 |
---|---|---|
committer | Patrick Mours <pmours@nvidia.com> | 2020-10-05 16:03:30 +0300 |
commit | 3df90de6c2268bef91d3754f71c7404cfbeeac90 (patch) | |
tree | d079ef4862e6db7233114554e478e0ef69303fc8 /build_files/cmake | |
parent | 72e741ee62b54cbda9a7ad735cc2c6e4957c3af0 (diff) |
Cycles: Add NanoVDB support for rendering volumes
NanoVDB is a platform-independent sparse volume data structure that makes it possible to
use OpenVDB volumes on the GPU. This patch uses it for volume rendering in Cycles,
replacing the previous usage of dense 3D textures.
Since it has a big impact on memory usage and performance and changes the OpenVDB
branch used for the rest of Blender as well, this is not enabled by default yet, which will
happen only after 2.82 was branched off. To enable it, build both dependencies and Blender
itself with the "WITH_NANOVDB" CMake option.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D8794
Diffstat (limited to 'build_files/cmake')
-rw-r--r-- | build_files/cmake/Modules/FindNanoVDB.cmake | 49 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_apple.cmake | 5 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_unix.cmake | 10 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_win32.cmake | 5 |
4 files changed, 69 insertions, 0 deletions
diff --git a/build_files/cmake/Modules/FindNanoVDB.cmake b/build_files/cmake/Modules/FindNanoVDB.cmake new file mode 100644 index 00000000000..95d76fb39af --- /dev/null +++ b/build_files/cmake/Modules/FindNanoVDB.cmake @@ -0,0 +1,49 @@ +# - Find NanoVDB library +# Find the native NanoVDB includes and library +# This module defines +# NANOVDB_INCLUDE_DIRS, where to find nanovdb.h, Set when +# NANOVDB_INCLUDE_DIR is found. +# NANOVDB_ROOT_DIR, The base directory to search for NanoVDB. +# This can also be an environment variable. +# NANOVDB_FOUND, If false, do not try to use NanoVDB. + +#============================================================================= +# Copyright 2020 Blender Foundation. +# +# Distributed under the OSI-approved BSD 3-Clause License, +# see accompanying file BSD-3-Clause-license.txt for details. +#============================================================================= + +# If NANOVDB_ROOT_DIR was defined in the environment, use it. +IF(NOT NANOVDB_ROOT_DIR AND NOT $ENV{NANOVDB_ROOT_DIR} STREQUAL "") + SET(NANOVDB_ROOT_DIR $ENV{NANOVDB_ROOT_DIR}) +ENDIF() + +SET(_nanovdb_SEARCH_DIRS + ${NANOVDB_ROOT_DIR} +) + +FIND_PATH(NANOVDB_INCLUDE_DIR + NAMES + nanovdb/NanoVDB.h + HINTS + ${_nanovdb_SEARCH_DIRS} + PATH_SUFFIXES + include +) + +# handle the QUIETLY and REQUIRED arguments and set NANOVDB_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(NanoVDB DEFAULT_MSG + NANOVDB_INCLUDE_DIR) + +IF(NANOVDB_FOUND) + SET(NANOVDB_INCLUDE_DIRS ${NANOVDB_INCLUDE_DIR}) +ENDIF(NANOVDB_FOUND) + +MARK_AS_ADVANCED( + NANOVDB_INCLUDE_DIR +) + +UNSET(_nanovdb_SEARCH_DIRS) diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 394eac8d0d8..07b3e53de5c 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -323,6 +323,11 @@ if(WITH_OPENVDB) set(OPENVDB_DEFINITIONS) endif() +if(WITH_NANOVDB) + set(NANOVDB ${LIBDIR}/nanovdb) + set(NANOVDB_INCLUDE_DIR ${NANOVDB}/include) +endif() + if(WITH_LLVM) set(LLVM_ROOT_DIR ${LIBDIR}/llvm) if(EXISTS "${LLVM_ROOT_DIR}/bin/llvm-config") diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 58de3b34961..1aa96c8b842 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -264,6 +264,7 @@ endif() if(WITH_OPENVDB) find_package_wrapper(OpenVDB) find_package_wrapper(Blosc) + if(NOT OPENVDB_FOUND) set(WITH_OPENVDB OFF) set(WITH_OPENVDB_BLOSC OFF) @@ -274,6 +275,15 @@ if(WITH_OPENVDB) endif() endif() +if(WITH_NANOVDB) + find_package_wrapper(NanoVDB) + + if(NOT NANOVDB_FOUND) + set(WITH_NANOVDB OFF) + message(STATUS "NanoVDB not found, disabling it") + endif() +endif() + if(WITH_ALEMBIC) find_package_wrapper(Alembic) diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index 89c55d8b04f..2dd8d5f4600 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -535,6 +535,11 @@ if(WITH_OPENVDB) set(OPENVDB_DEFINITIONS -DNOMINMAX -D_USE_MATH_DEFINES) endif() +if(WITH_NANOVDB) + set(NANOVDB ${LIBDIR}/nanoVDB) + set(NANOVDB_INCLUDE_DIR ${NANOVDB}/include) +endif() + if(WITH_OPENIMAGEDENOISE) set(OPENIMAGEDENOISE ${LIBDIR}/OpenImageDenoise) set(OPENIMAGEDENOISE_LIBPATH ${LIBDIR}/OpenImageDenoise/lib) |