[Bf-blender-cvs] [5489611e531] master: Compositor: Added denoising node

Brecht Van Lommel noreply at git.blender.org
Wed Aug 14 21:40:37 CEST 2019


Commit: 5489611e53176ad4c1d5ac626db6377b27624cce
Author: Brecht Van Lommel
Date:   Wed Aug 14 15:30:26 2019 +0200
Branches: master
https://developer.blender.org/rB5489611e53176ad4c1d5ac626db6377b27624cce

Compositor: Added denoising node

This node is built on Intel's OpenImageDenoise library.
Other denoisers could be integrated, for example Lukas' Cycles denoiser.

Compositor: Made OpenImageDenoise optional, added CMake and build_env files to find OIDN

Compositor: Fixed some warnings in the denoising operator

build_environment: Updated OpenImageDenoise to 0.8.1

build_environment: Updated OpenImageDenoise in `make deps` for macOS

Reviewers: sergey, jbakker, brecht

Reviewed By: brecht

Subscribers: YAFU, LazyDodo, Zen_YS, slumber, samgreen, tjvoll, yeus, ponomarovmax, getrad, coder.kalyan, vitos1k, Yegor, DeepBlender, kumaran7, Darkfie9825, aliasguru, aafra, ace_dragon, juang3d, pandrodor, cdog, lordodin, jtheninja, mavek, marcog, 5k1n2, Atair, rawalanche, 0o00o0oo, filibis, poor, lukasstockner97

Tags: #compositing

Differential Revision: https://developer.blender.org/D4304

===================================================================

M	CMakeLists.txt
M	build_files/build_environment/CMakeLists.txt
M	build_files/build_environment/cmake/harvest.cmake
A	build_files/build_environment/cmake/openimagedenoise.cmake
M	build_files/build_environment/cmake/tbb.cmake
M	build_files/build_environment/cmake/versions.cmake
A	build_files/build_environment/patches/openimagedenoise.diff
A	build_files/cmake/Modules/FindOpenImageDenoise.cmake
M	build_files/cmake/config/blender_full.cmake
M	build_files/cmake/config/blender_lite.cmake
M	build_files/cmake/config/blender_release.cmake
M	build_files/cmake/macros.cmake
M	build_files/cmake/platform/platform_apple.cmake
M	build_files/cmake/platform/platform_unix.cmake
M	build_files/cmake/platform/platform_win32.cmake
M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/node.c
M	source/blender/compositor/CMakeLists.txt
M	source/blender/compositor/intern/COM_Converter.cpp
A	source/blender/compositor/nodes/COM_DenoiseNode.cpp
A	source/blender/compositor/nodes/COM_DenoiseNode.h
A	source/blender/compositor/operations/COM_DenoiseOperation.cpp
A	source/blender/compositor/operations/COM_DenoiseOperation.h
M	source/blender/editors/space_node/CMakeLists.txt
M	source/blender/editors/space_node/drawnode.c
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_composite.h
M	source/blender/nodes/NOD_static_types.h
A	source/blender/nodes/composite/nodes/node_composite_denoise.c

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6ced6e1d76d..2a7a020c428 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -237,6 +237,7 @@ option(WITH_OPENCOLORIO   "Enable OpenColorIO color management" ${_init_OPENCOLO
 
 # Compositor
 option(WITH_COMPOSITOR         "Enable the tile based nodal compositor" ON)
+option(WITH_OPENIMAGEDENOISE   "Enable the OpenImageDenoise compositing node" OFF)
 
 option(WITH_OPENSUBDIV    "Enable OpenSubdiv for surface subdivision" ${_init_OPENSUBDIV})
 
@@ -1760,6 +1761,7 @@ if(FIRST_RUN)
   info_cfg_option(WITH_CYCLES)
   info_cfg_option(WITH_FREESTYLE)
   info_cfg_option(WITH_OPENCOLORIO)
+  info_cfg_option(WITH_OPENIMAGEDENOISE)
   info_cfg_option(WITH_OPENVDB)
   info_cfg_option(WITH_ALEMBIC)
 
diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt
index 0dbd3b572cf..1b387cb86a2 100644
--- a/build_files/build_environment/CMakeLists.txt
+++ b/build_files/build_environment/CMakeLists.txt
@@ -97,6 +97,7 @@ if(UNIX AND NOT APPLE)
 else()
   include(cmake/pugixml.cmake)
 endif()
+include(cmake/openimagedenoise.cmake)
 
 if(WITH_WEBP)
   include(cmake/webp.cmake)
diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake
index 27bcd184c44..97e4a6b69d4 100644
--- a/build_files/build_environment/cmake/harvest.cmake
+++ b/build_files/build_environment/cmake/harvest.cmake
@@ -166,6 +166,8 @@ harvest(openimageio/bin openimageio/bin "maketx")
 harvest(openimageio/bin openimageio/bin "oiiotool")
 harvest(openimageio/include openimageio/include "*")
 harvest(openimageio/lib openimageio/lib "*.a")
+harvest(openimagedenoise/include openimagedenoise/include "*")
+harvest(openimagedenoise/lib openimagedenoise/lib "*.a")
 harvest(openjpeg/include/openjpeg-2.3 openjpeg/include "*.h")
 harvest(openjpeg/lib openjpeg/lib "*.a")
 harvest(opensubdiv/include opensubdiv/include "*.h")
diff --git a/build_files/build_environment/cmake/openimagedenoise.cmake b/build_files/build_environment/cmake/openimagedenoise.cmake
new file mode 100644
index 00000000000..b20bb838ede
--- /dev/null
+++ b/build_files/build_environment/cmake/openimagedenoise.cmake
@@ -0,0 +1,61 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+
+set(OIDN_EXTRA_ARGS
+  -DWITH_EXAMPLE=OFF
+  -DWITH_TEST=OFF
+  -DTBB_ROOT=${LIBDIR}/tbb
+  -DTBB_STATIC_LIB=ON
+  -DOIDN_STATIC_LIB=ON
+)
+
+ExternalProject_Add(external_openimagedenoise
+  URL ${OIDN_URI}
+  DOWNLOAD_DIR ${DOWNLOAD_DIR}
+  URL_HASH MD5=${OIDN_HASH}
+  PREFIX ${BUILD_DIR}/openimagedenoise
+  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimagedenoise ${DEFAULT_CMAKE_FLAGS} ${OIDN_EXTRA_ARGS}
+  PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/openimagedenoise/src/external_openimagedenoise < ${PATCH_DIR}/openimagedenoise.diff
+  INSTALL_DIR ${LIBDIR}/openimagedenoise
+)
+
+add_dependencies(
+  external_openimagedenoise
+  external_tbb
+)
+
+if(WIN32)
+  if(BUILD_MODE STREQUAL Release)
+    ExternalProject_Add_Step(external_openimagedenoise after_install
+      COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openimagedenoise/include ${HARVEST_TARGET}/openimagedenoise/include
+      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/openimagedenoise.lib ${HARVEST_TARGET}/openimagedenoise/lib/openimagedenoise.lib
+      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/common.lib ${HARVEST_TARGET}/openimagedenoise/lib/common.lib
+      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/mkldnn.lib ${HARVEST_TARGET}/openimagedenoise/lib/mkldnn.lib
+      DEPENDEES install
+    )
+  endif()
+  if(BUILD_MODE STREQUAL Debug)
+    ExternalProject_Add_Step(external_openimagedenoise after_install
+      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/openimagedenoise.lib ${HARVEST_TARGET}/openimagedenoise/lib/openimagedenoise_d.lib
+      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/common.lib ${HARVEST_TARGET}/openimagedenoise/lib/common_d.lib
+      COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimagedenoise/lib/mkldnn.lib ${HARVEST_TARGET}/openimagedenoise/lib/mkldnn_d.lib
+      DEPENDEES install
+    )
+  endif()
+endif()
diff --git a/build_files/build_environment/cmake/tbb.cmake b/build_files/build_environment/cmake/tbb.cmake
index 77f061e30d0..26c52e00c76 100644
--- a/build_files/build_environment/cmake/tbb.cmake
+++ b/build_files/build_environment/cmake/tbb.cmake
@@ -18,7 +18,7 @@
 
 set(TBB_EXTRA_ARGS
   -DTBB_BUILD_SHARED=Off
-  -DTBB_BUILD_TBBMALLOC=Off
+  -DTBB_BUILD_TBBMALLOC=On
   -DTBB_BUILD_TBBMALLOC_PROXY=Off
   -DTBB_BUILD_STATIC=On
 )
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index 3ee6a4920ed..c3b713096d6 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -302,3 +302,7 @@ set(SQLITE_HASH fb558c49ee21a837713c4f1e7e413309aabdd9c7)
 set(EMBREE_VERSION 3.2.4)
 set(EMBREE_URI https://github.com/embree/embree/archive/v${EMBREE_VERSION}.zip)
 set(EMBREE_HASH 3d4a1147002ff43939d45140aa9d6fb8)
+
+set(OIDN_VERSION 1.0.0)
+set(OIDN_URI https://github.com/OpenImageDenoise/oidn/releases/download/v${OIDN_VERSION}/oidn-${OIDN_VERSION}.src.zip)
+set(OIDN_HASH 19fe67b0164e8f020ac8a4f520defe60)
diff --git a/build_files/build_environment/patches/openimagedenoise.diff b/build_files/build_environment/patches/openimagedenoise.diff
new file mode 100644
index 00000000000..08d7a397a6d
--- /dev/null
+++ b/build_files/build_environment/patches/openimagedenoise.diff
@@ -0,0 +1,119 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 70ec895..e616b63 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -178,7 +178,9 @@ set_property(TARGET ${PROJECT_NAME} PROPERTY SOVERSION "0")
+ ## Open Image Denoise examples
+ ## ----------------------------------------------------------------------------
+ 
+-add_subdirectory(examples)
++if(WITH_EXAMPLE)
++  add_subdirectory(examples)
++endif()
+ 
+ ## ----------------------------------------------------------------------------
+ ## Open Image Denoise install and packaging
+Submodule mkl-dnn contains modified content
+diff --git a/mkl-dnn/cmake/TBB.cmake b/mkl-dnn/cmake/TBB.cmake
+index 0711e699..c14210b6 100644
+--- a/mkl-dnn/cmake/TBB.cmake
++++ b/mkl-dnn/cmake/TBB.cmake
+@@ -90,8 +90,8 @@ if(WIN32)
+             NO_DEFAULT_PATH
+         )
+         set(TBB_LIB_DIR ${TBB_ROOT}/lib/${TBB_ARCH}/${TBB_VCVER})
+-        find_library(TBB_LIBRARY tbb PATHS ${TBB_LIB_DIR} ${TBB_ROOT}/lib NO_DEFAULT_PATH)
+-        find_library(TBB_LIBRARY_MALLOC tbbmalloc PATHS ${TBB_LIB_DIR} ${TBB_ROOT}/lib NO_DEFAULT_PATH)
++        find_library(TBB_LIBRARY tbb_static PATHS ${TBB_LIB_DIR} ${TBB_ROOT}/lib NO_DEFAULT_PATH)
++        find_library(TBB_LIBRARY_MALLOC tbbmalloc_static PATHS ${TBB_LIB_DIR} ${TBB_ROOT}/lib NO_DEFAULT_PATH)
+     endif()
+ 
+ else()
+@@ -138,13 +138,13 @@ else()
+         set(TBB_LIBRARY_MALLOC TBB_LIBRARY_MALLOC-NOTFOUND)
+         if(APPLE)
+             find_path(TBB_INCLUDE_DIR tbb/task_scheduler_init.h PATHS ${TBB_ROOT}/include NO_DEFAULT_PATH)
+-            find_library(TBB_LIBRARY tbb PATHS ${TBB_ROOT}/lib NO_DEFAULT_PATH)
+-            find_library(TBB_LIBRARY_MALLOC tbbmalloc PATHS ${TBB_ROOT}/lib NO_DEFAULT_PATH)
++            find_library(TBB_LIBRARY tbb_static PATHS ${TBB_ROOT}/lib NO_DEFAULT_PATH)
++            find_library(TBB_LIBRARY_MALLOC tbbmalloc_static PATHS ${TBB_ROOT}/lib NO_DEFAULT_PATH)
+         else()
+             find_path(TBB_INCLUDE_DIR tbb/task_scheduler_init.h PATHS ${TBB_ROOT}/include NO_DEFAULT_PATH)
+             set(TBB_HINTS HINTS ${TBB_ROOT}/lib/intel64/gcc4.4 ${TBB_ROOT}/lib ${TBB_ROOT}/lib64 PATHS /usr/libx86_64-linux-gnu/)
+-            find_library(TBB_LIBRARY tbb ${TBB_HINTS})
+-            find_library(TBB_LIBRARY_MALLOC tbbmalloc ${TBB_HINTS})
++            find_library(TBB_LIBRARY tbb_static ${TBB_HINTS})
++            find_library(TBB_LIBRARY_MALLOC tbbmalloc_static ${TBB_HINTS})
+         endif()
+     endif()
+ 
+diff '--ignore-matching-lines=:' -ur '--exclude=*.svn*' -u -r
+--- a/cmake/install.cmake	2019-08-12 18:02:20.794402575 +0200
++++ b/cmake/install.cmake	2019-08-12 18:06:07.470045703 +0200
+@@ -18,6 +18,13 @@
+ ## Install library
+ ## ----------------------------------------------------------------------------
+ 
++if(UNIX)
++install(FILES
++  ${CMAKE_BINARY_DIR}/libOpenImageDenoise.a
++  ${CMAKE_BINARY_DIR}/libmkldnn.a
++  ${CMAKE_BINARY_DIR}/libcommon.a
++  DESTINATION ${CMAKE_INSTALL_LIBDIR})
++else()
+ install(TARGETS ${PROJECT_NAME}
+   EXPORT
+     ${PROJECT_NAME}_Export
+@@ -38,6 +45,7 @@
+       DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel
+   )
+ endif()
++endif()
+ 
+ ## ----------------------------------------------------------------------------
+ ## Install headers
+@@ -78,6 +86,7 @@
+ ## Install CMake configuration files
+ ## ----------------------------------------------------------------------------
+ 
++if(NOT UNIX)
+ install(EXPORT ${PROJECT_NAME}_Export
+   DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+   #NAMESPACE ${PROJECT_NAME}::
+@@ -92,3 +101,4 @@
+   DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+   COMPONENT devel
+ )
++endif()
+diff '--ignore-matching-lines=:' -ur '--exclude=*.svn*' -u -r
+--- a/CMakeLists.txt	2019-08-12 14:22:00.974078598 +0200
++++ b/CMakeLists.txt	2019-08-12 18:05

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list