Skip to content

Commit

Permalink
OpenVDB read support (#2010)
Browse files Browse the repository at this point in the history
  • Loading branch information
marsupial authored and lgritz committed Sep 26, 2018
1 parent 30ebb35 commit 47e9a4c
Show file tree
Hide file tree
Showing 24 changed files with 1,034 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Major new features and improvements:
as parameters for output (the old kind of calls still exist, too, and
have their uses). Also in C++, change all IBA functions that took raw
pointers to per-channel colors into span<> for safety. #1961 (1.9.4)
* Support for OpenVDB volume files (reading only, no write support
currently). #2010

Public API changes:
* **Python binding overhaul**
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ set (PYTHON_VERSION "2.7" CACHE STRING "Target version of python to find")
option (PYLIB_INCLUDE_SONAME "If ON, soname/soversion will be set for Python module library" OFF)
option (PYLIB_LIB_PREFIX "If ON, prefix the Python module with 'lib'" OFF)
option (USE_FIELD3D "Use Field3D if found" ON)
option (USE_OPENVDB "Use OpenVDB if found" ON)
set (OPENVDB_ROOT_DIR "" CACHE STRING "Custom OpenVDB path")
option (USE_TBB "Use Intel TBB if found" ON)
set (TBB_ROOT_DIR "" CACHE STRING "Custom Intel TBB path")
option (USE_FFMPEG "Use FFmpeg if found" ON)
set (JPEG_PATH "" CACHE STRING "Custom JPEG path")
option (USE_JPEGTURBO "Use JPEG-Turbo if found" ON)
Expand Down Expand Up @@ -346,6 +350,9 @@ oiio_add_tests (texture-field3d field3d
FOUNDVAR FIELD3D_FOUND)


oiio_add_tests (openvdb
FOUNDVAR OPENVDB_FOUND)

if (SPI_TESTS)
oiio_add_tests (oiiotool-spi
FOUNDVAR SPI_TESTS
Expand Down
6 changes: 5 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ NEW or CHANGED dependencies since the last major release are **bold**.
icc version 13 or higher
* Boost >= 1.53 (tested up through 1.67)
* CMake >= 3.2.2 (tested up through 3.12)
* OpenEXR >= 2.0 (recommended: 2.2)
* OpenEXR >= 2.0 (recommended: 2.2, tested through 2.3)
* libTIFF >= 3.9 (recommended: 4.0+)

### Optional dependencies -- features may be disabled if not found
Expand All @@ -49,6 +49,10 @@ NEW or CHANGED dependencies since the last major release are **bold**.
* ffmpeg >= 2.6 (tested through 4.0)
* If you want support for jpeg 2000 images:
* OpenJpeg >= 1.5
* If you want support for Field3D files:
* Field3D
* If you want support for OpenVDB files:
* OpenVDB >= 5.0 and Intel TBB >= 2018


Building OpenImageIO on Linux or OS X
Expand Down
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ ifneq (${FIELD3D_HOME},)
MY_CMAKE_FLAGS += -DFIELD3D_HOME:STRING=${FIELD3D_HOME}
endif

ifneq (${USE_TBB},)
MY_CMAKE_FLAGS += -DUSE_TBB:BOOL=${USE_TBB}
endif

ifneq (${TBB_ROOT_DIR},)
MY_CMAKE_FLAGS += -DTBB_ROOT_DIR:STRING=${TBB_ROOT_DIR}
endif

ifneq (${USE_OPENVDB},)
MY_CMAKE_FLAGS += -DUSE_OPENVDB:BOOL=${USE_OPENVDB}
endif

ifneq (${OPENVDB_LOCATION},)
MY_CMAKE_FLAGS += -DOPENVDB_LOCATION:STRING=${OPENVDB_LOCATION}
endif

ifneq (${USE_OPENJPEG},)
MY_CMAKE_FLAGS += -DUSE_OPENJPEG:BOOL=${USE_OPENJPEG}
endif
Expand Down Expand Up @@ -473,6 +489,11 @@ help:
@echo " PYTHON_VERSION=2.6 Specify the Python version"
@echo " USE_FIELD3D=0 Don't build the Field3D plugin"
@echo " FIELD3D_HOME=path Custom Field3D installation"
@echo " USE_OPENVDB=0 Don't build the OpenVDB plugin"
@echo " OPENVDB_LOCATION=path Custom OpenVDB installation"
@echo " USE_TBB=0 Don't use Intel TBB, though known"
@echo " dependencies (USE_OPENVDB=1) will override this"
@echo " TBB_ROOT_DIR=path Custom Intel TBB installation"
@echo " USE_FFMPEG=0 Don't build the FFmpeg plugin"
@echo " USE_JPEGTURBO=0 Don't build the JPEG-Turbo even if found"
@echo " JPEGTURBO_PATH=path Custom path for JPEG-Turbo"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ OpenImageIO consists of:
* Plugins implementing I/O for several popular image file formats,
including TIFF, JPEG/JFIF, OpenEXR, PNG, HDR/RGBE, ICO, BMP, Targa,
JPEG-2000, RMan Zfile, FITS, DDS, Softimage PIC, PNM, DPX, Cineon,
IFF, Field3D, Ptex, Photoshop PSD, Wavefront RLA, SGI, WebP, GIF,
DICOM, many "RAW" digital camera formats, and a variety of movie
IFF, Field3D, OpenVDB, Ptex, Photoshop PSD, Wavefront RLA, SGI, WebP,
GIF, DICOM, many "RAW" digital camera formats, and a variety of movie
formats (readable as individual frames). More are being developed
all the time.

Expand Down
6 changes: 6 additions & 0 deletions site/spi/Makefile-bits-arnold
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ ifeq (${SP_OS}, rhel7)
SPCOMP2_USE_BOOSTVERS ?= 1
OCIO_PATH ?= "${SPCOMP2_SHOTTREE_LOCATION}/OpenColorIO/${SP_OS}-${SPCOMP2_COMPILER}/v${OCIO_SPCOMP_VERSION}"
FIELD3D_HOME ?= "${INSTALL_SPCOMP2_LOCATION}/Field3D/${SP_OS}-${SPCOMP2_COMPILER}-boost155sp/v408"
OPENVDB_ROOT_DIR ?= "${INSTALL_SPCOMP2_LOCATION}/openvdb/${SP_OS}-${SPCOMP2_COMPILER}-boost155sp/v5010000"
TBB_ROOT_DIR ?= /net/apps/rhel7/intel/tbb

## If not overridden, here is our preferred LLVM installation
## (may be changed as new versions are rolled out to the facility)
Expand Down Expand Up @@ -112,6 +114,8 @@ ifeq (${SP_OS}, rhel7)
MY_CMAKE_FLAGS += \
-DOCIO_PATH=${OCIO_PATH} \
-DFIELD3D_HOME=${FIELD3D_HOME} \
-DOPENVDB_ROOT_DIR=${OPENVDB_ROOT_DIR} \
-DTBB_ROOT_DIR=${TBB_ROOT_DIR} \
-DHDF5_CUSTOM=1 \
-DHDF5_LIBRARIES=/usr/lib64/libhdf5.so \
-DNuke_ROOT=/net/apps/rhel7/foundry/nuke${NUKE_VERSION} \
Expand Down Expand Up @@ -155,6 +159,7 @@ else ifeq (${SP_OS}, lion)
MACPORTS_PREFIX=/opt/local-10.7-2012-08
OCIO_PATH ?= "${SPCOMP2_SHOTTREE_LOCATION}/OpenColorIO/${SP_OS}-${SPCOMP2_COMPILER}/v${OCIO_SPCOMP_VERSION}"
FIELD3D_HOME ?= "${INSTALL_SPCOMP2_LOCATION}/Field3D/${SP_OS}-${SPCOMP2_COMPILER}-boost151/v306"
OPENVDB_ROOT_DIR ?= "${INSTALL_SPCOMP2_LOCATION}/openvdb/${SP_OS}-${SPCOMP2_COMPILER}-boost151/v3010000"
# CMAKE_CXX_COMPILER:
# otherwise g++ is used and SPI standardized on clang.
# OVERRIDE_SHARED_LIBRARY_SUFFIX:
Expand All @@ -169,6 +174,7 @@ else ifeq (${SP_OS}, lion)
MY_CMAKE_FLAGS += \
-DOCIO_PATH="${OCIO_PATH}" \
-DFIELD3D_HOME=${FIELD3D_HOME} \
-DOPENVDB_ROOT_DIR=${OPENVDB_ROOT_DIR} \
-DOPENJPEG_HOME=${MACPORTS_PREFIX} \
-DOVERRIDE_SHARED_LIBRARY_SUFFIX=.so \
-DPYTHON_EXECUTABLE=${MACPORTS_PREFIX}/bin/python${PYVER} \
Expand Down
9 changes: 8 additions & 1 deletion site/spi/Makefile-bits-spcomp2
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ ifeq (${SP_OS}, rhel7)
# $(info SPCOMP2_BOOSTVERS_SUFFIX ${SPCOMP2_BOOSTVERS_SUFFIX})
OCIO_PATH ?= ${SPCOMP2_SHOTTREE_LOCATION}/OpenColorIO/${SP_OS}-${SPCOMP2_COMPILER}/v${OCIO_SPCOMP_VERSION}
# FIELD3D_HOME ?= ${SPCOMP2_SHOTTREE_LOCATION}/Field3D/${SP_OS}-${SPCOMP2_COMPILER}-boost155${BOOSTSPSUFFIX}/v408
OPENVDB_ROOT_DIR ?= ${SPCOMP2_SHOTTREE_LOCATION}/openvdb/${SP_OS}-${SPCOMP2_COMPILER}-boost155${BOOSTSPSUFFIX}/v5010000
TBB_ROOT_DIR ?= /net/apps/rhel7/intel/tbb
OIIO_SPCOMP2_PATH := ${SPCOMP2_SHOTTREE_LOCATION}/OpenImageIO/${SP_OS}-${SPCOMP2_COMPILER}$(CPPSTDSUFFIX)-boost${SPCOMP2_BOOSTVERS_SUFFIX}/v${OPENIMAGEIO_SPCOMP2_VERSION}
$(info New rhel7 OIIO_SPCOMP2_PATH is ${OIIO_SPCOMP2_PATH})

Expand Down Expand Up @@ -145,11 +147,14 @@ ifeq (${SP_OS}, rhel7)
MY_CMAKE_FLAGS += \
-DOCIO_PATH=${OCIO_PATH} \
-DFIELD3D_HOME=${FIELD3D_HOME} \
-DOPENVDB_ROOT_DIR=${OPENVDB_ROOT_DIR} \
-DTBB_ROOT_DIR=${TBB_ROOT_DIR} \
-DHDF5_CUSTOM=1 \
-DHDF5_LIBRARIES=/usr/lib64/libhdf5.so \
-DNuke_ROOT=/net/apps/rhel7/foundry/nuke${NUKE_VERSION} \
-DLIBRAW_INCLUDEDIR_HINT=/usr/include/libraw-0.18.11 \
-DLIBRAW_LIBDIR_HINT=/usr/lib64/libraw-0.18.11

MY_CMAKE_FLAGS += \
-DBOOST_CUSTOM=1 \
-DBoost_VERSION=${CONSTRUCTED_BOOSTVERS} \
Expand Down Expand Up @@ -193,6 +198,7 @@ else ifeq (${SP_OS}, lion)
MACPORTS_PREFIX=/opt/local-10.7-2012-08
OCIO_PATH ?= "${SPCOMP2_SHOTTREE_LOCATION}/OpenColorIO/${SP_OS}-${SPCOMP2_COMPILER}/v${OCIO_SPCOMP_VERSION}"
FIELD3D_HOME ?= "${INSTALL_SPCOMP2_LOCATION}/Field3D/${SP_OS}-${SPCOMP2_COMPILER}-boost151/v306"
OPENVDB_ROOT_DIR ?= "${INSTALL_SPCOMP2_LOCATION}/openvdb/${SP_OS}-${SPCOMP2_COMPILER}-boost151/v3010000"
# CMAKE_CXX_COMPILER:
# otherwise g++ is used and SPI standardized on clang.
# CMAKE_INSTALL_NAME_DIR:
Expand All @@ -211,6 +217,7 @@ else ifeq (${SP_OS}, lion)
MY_CMAKE_FLAGS += \
-DOCIO_PATH="${OCIO_PATH}" \
-DFIELD3D_HOME=${FIELD3D_HOME} \
-DOPENVDB_ROOT_DIR=${OPENVDB_ROOT_DIR} \
-DOPENJPEG_HOME=${MACPORTS_PREFIX} \
-DOVERRIDE_SHARED_LIBRARY_SUFFIX=.so \
-DPYTHON_EXECUTABLE=${MACPORTS_PREFIX}/bin/python${PYVER} \
Expand Down Expand Up @@ -305,7 +312,7 @@ INSTALL_BIN_LOCATION = /shots/spi/home/bin/${SP_OS}
INSTALL_SPCOMP2_CURRENT = $(INSTALL_SPCOMP2_LOCATION)/OpenImageIO/$(SPARCH)/v$(OPENIMAGEIO_SPCOMP2_VERSION)

SPCOMP2_RPATH_OPT ?= ${OCIO_PATH}/lib:${FIELD3D_HOME}/lib:/usr/lib64/libraw-0.18.11
SPCOMP2_RPATH_DEBUG ?= ${OCIO_PATH}/lib/debug:${FIELD3D_HOME}/lib/debug:/usr/lib64/libraw-0.18.11
SPCOMP2_RPATH_DEBUG ?= ${OCIO_PATH}/lib/debug:${FIELD3D_HOME}/lib/debug:/usr/lib64/libraw-0.18.11:${OPENVDB_ROOT_DIR}/lib/debug
PYSPCOMP2_RPATH_OPT ?= ${SPCOMP2_RPATH_OPT}:${OIIO_SPCOMP2_PATH}/lib
PYSPCOMP2_RPATH_DEBUG ?= ${SPCOMP2_RPATH_DEBUG}:${OIIO_SPCOMP2_PATH}/lib/debug

Expand Down
2 changes: 2 additions & 0 deletions src/build-scripts/install_homebrew_deps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ brew install qt
brew install field3d
brew install ffmpeg
brew install opencv
brew install tbb
brew install openvdb
brew upgrade python
brew install pybind11 numpy
brew link --overwrite numpy
Expand Down
46 changes: 46 additions & 0 deletions src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ if (NOT VERBOSE)
set (OpenEXR_FIND_QUIETLY true)
set (OpenGL_FIND_QUIETLY true)
set (OpenJpeg_FIND_QUIETLY true)
set (OpenVDB_FIND_QUIETLY true)
set (PkgConfig_FIND_QUIETLY true)
set (PNG_FIND_QUIETLY TRUE)
set (PTex_FIND_QUIETLY TRUE)
set (PugiXML_FIND_QUIETLY TRUE)
set (PythonInterp_FIND_QUIETLY true)
set (PythonLibs_FIND_QUIETLY true)
set (Qt5_FIND_QUIETLY true)
set (TBB_FIND_QUIETLY true)
set (Threads_FIND_QUIETLY true)
set (TIFF_FIND_QUIETLY true)
set (WEBP_FIND_QUIETLY true)
Expand Down Expand Up @@ -300,6 +302,50 @@ endif ()
###########################################################################


###########################################################################
# Intel TBB
if (USE_TBB)
find_package (TBB 2017) # 2017 min for VFX Platform 2018
if (TBB_FOUND)
if (NOT TBB_FIND_QUIETLY)
message (STATUS "Intel TBB includes = ${TBB_INCLUDE_DIRS}")
message (STATUS "Intel TBB library = ${TBB_LIBRARIES}")
endif ()
add_definitions ("-DUSE_TBB=1")
else ()
message (STATUS "Intel TBB not found, TBB_ROOT_DIR='${TBB_ROOT_DIR}'")
endif ()
endif ()

# end Intel TBB setup
###########################################################################


###########################################################################
# OpenVDB
if (USE_OPENVDB AND TBB_FOUND)
find_package (OpenVDB 5.0) # 5.0 min for VFX Platform 2017
if (OPENVDB_FOUND)
if (NOT OpenVDB_FIND_QUIETLY)
message (STATUS "OpenVDB includes = ${OPENVDB_INCLUDE_DIR}")
message (STATUS "OpenVDB libraries = ${OPENVDB_LIBRARY}")
endif ()
add_definitions ("-DUSE_OPENVDB=1")
else ()
message (STATUS "OpenVDB not found, OPENVDB_ROOT_DIR='${OPENVDB_ROOT_DIR}'")
endif ()
else ()
if (USE_OPENVDB AND NOT TBB_FOUND)
set (oiio_vdb_why ", could not find Intel TBB")
endif ()
message (STATUS "OpenVDB will not be used${oiio_vdb_why}")
endif ()

# end OpenVDB setup
###########################################################################



###########################################################################
# JPEG

Expand Down
73 changes: 73 additions & 0 deletions src/cmake/modules/FindOpenVDB.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# - Find OPENVDB library
# Find the native OPENVDB includes and library
# This module defines
# OPENVDB_INCLUDE_DIRS, where to find openvdb.h, Set when
# OPENVDB_INCLUDE_DIR is found.
# OPENVDB_LIBRARIES, libraries to link against to use OPENVDB.
# OPENVDB_ROOT_DIR, The base directory to search for OPENVDB.
# This can also be an environment variable.
# OPENVDB_FOUND, If false, do not try to use OPENVDB.
#
# also defined, but not for general use are
# OPENVDB_LIBRARY, where to find the OPENVDB library.

#=============================================================================
# Copyright 2015 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================

# If OPENVDB_ROOT_DIR was defined in the environment, use it.
IF(NOT OPENVDB_ROOT_DIR AND NOT $ENV{OPENVDB_ROOT_DIR} STREQUAL "")
SET(OPENVDB_ROOT_DIR $ENV{OPENVDB_ROOT_DIR})
ENDIF()

SET(_openvdb_SEARCH_DIRS
${OPENVDB_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
/opt/openvdb
/opt/lib/openvdb
)

FIND_PATH(OPENVDB_INCLUDE_DIR
NAMES
openvdb/openvdb.h
HINTS
${_openvdb_SEARCH_DIRS}
PATH_SUFFIXES
include
)

FIND_LIBRARY(OPENVDB_LIBRARY
NAMES
openvdb
HINTS
${_openvdb_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)

# handle the QUIETLY and REQUIRED arguments and set OPENVDB_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENVDB DEFAULT_MSG
OPENVDB_LIBRARY OPENVDB_INCLUDE_DIR)

IF(OPENVDB_FOUND)
SET(OPENVDB_LIBRARIES ${OPENVDB_LIBRARY})
SET(OPENVDB_INCLUDE_DIRS ${OPENVDB_INCLUDE_DIR})
ENDIF(OPENVDB_FOUND)

MARK_AS_ADVANCED(
OPENVDB_INCLUDE_DIR
OPENVDB_LIBRARY
)

UNSET(_openvdb_SEARCH_DIRS)

0 comments on commit 47e9a4c

Please sign in to comment.