├── CMake ├── FindOpenEXR.cmake ├── FindOptiX.cmake └── configure_optix.cmake ├── CMakeFiles ├── 3.20.1 │ ├── CMakeCCompiler.cmake │ ├── CMakeCXXCompiler.cmake │ ├── CMakeDetermineCompilerABI_C.bin │ ├── CMakeDetermineCompilerABI_CXX.bin │ ├── CMakeSystem.cmake │ ├── CompilerIdC │ │ ├── CMakeCCompilerId.c │ │ └── a.out │ └── CompilerIdCXX │ │ ├── CMakeCXXCompilerId.cpp │ │ └── a.out ├── CMakeError.log ├── CMakeOutput.log ├── CMakeRuleHashes.txt ├── Makefile2 ├── Progress │ ├── 1 │ ├── 2 │ ├── 3 │ ├── 4 │ ├── 5 │ ├── 6 │ ├── 7 │ ├── 8 │ ├── 9 │ ├── 10 │ ├── 11 │ ├── 12 │ ├── 13 │ ├── 14 │ ├── 15 │ ├── 16 │ ├── 17 │ ├── 18 │ ├── 19 │ ├── 20 │ ├── 21 │ ├── 22 │ ├── 23 │ ├── 24 │ ├── 25 │ ├── 26 │ └── count.txt ├── TargetDirectories.txt ├── cmake.check_cache ├── progress.marks ├── psdr_cuda.dir │ ├── DependInfo.cmake │ ├── build.make │ ├── cmake_clean.cmake │ ├── compiler_depend.make │ ├── compiler_depend.ts │ ├── depend.make │ ├── flags.make │ ├── link.txt │ ├── progress.make │ └── src │ │ ├── bsdf │ │ ├── diffuse.cpp.o.d │ │ ├── ggx.cpp.o.d │ │ ├── roughconductor.cpp.o.d │ │ └── subsurface.cpp.o.d │ │ ├── core │ │ ├── bitmap.cpp.o.d │ │ ├── bitmap_loader.cpp.o.d │ │ ├── cube_distrb.cpp.o.d │ │ ├── pmf.cpp.o.d │ │ └── sampler.cpp.o.d │ │ ├── emitter │ │ ├── area.cpp.o.d │ │ └── envmap.cpp.o.d │ │ ├── integrator │ │ ├── direct.cpp.o.d │ │ ├── direct_origin.cpp.o.d │ │ ├── field.cpp.o.d │ │ ├── integrator.cpp.o.d │ │ └── laser.cpp.o.d │ │ ├── optix │ │ └── ptx.cpp.o.d │ │ ├── psdr.cpp.o.d │ │ ├── scene │ │ ├── scene.cpp.o.d │ │ ├── scene_loader.cpp.o.d │ │ └── scene_optix.cpp.o.d │ │ ├── sensor │ │ ├── perspective.cpp.o.d │ │ └── sensor.cpp.o.d │ │ └── shape │ │ └── mesh.cpp.o.d └── ptx.dir │ ├── DependInfo.cmake │ ├── build.make │ ├── cmake_clean.cmake │ ├── compiler_depend.make │ ├── compiler_depend.ts │ ├── cuda │ ├── ptx_generated_psdr_cuda.cu.ptx.Debug.cmake │ ├── ptx_generated_psdr_cuda.cu.ptx.cmake │ ├── ptx_generated_psdr_cuda.cu.ptx.cmake.pre-gen │ └── ptx_generated_psdr_cuda.cu.ptx.depend │ ├── depend.make │ ├── flags.make │ ├── link.txt │ └── progress.make ├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── cmake_install.cmake ├── cuda ├── psdr_cuda.cpp ├── psdr_cuda.cu └── psdr_cuda.h ├── data ├── hdrdragon │ ├── mask │ │ └── .DS_Store │ └── rawimages │ │ └── GantryStateLog.txt ├── hdrkiwi │ ├── alpha_mask.zip │ ├── colmap_unposed │ │ ├── mvs │ │ │ ├── fused.ply │ │ │ ├── fused.ply.vis │ │ │ ├── meshed_trim_3.ply │ │ │ ├── run-colmap-geometric.sh │ │ │ ├── run-colmap-photometric.sh │ │ │ ├── sparse │ │ │ │ ├── cameras.bin │ │ │ │ ├── images.bin │ │ │ │ └── points3D.bin │ │ │ └── stereo │ │ │ │ ├── fusion.cfg │ │ │ │ └── patch-match.cfg │ │ └── sfm │ │ │ ├── database.db │ │ │ ├── images │ │ │ └── sparse │ │ │ └── 0 │ │ │ ├── cameras.bin │ │ │ ├── images.bin │ │ │ ├── points3D.bin │ │ │ └── project.ini │ ├── database.db │ ├── exr_ref.zip │ ├── images_big │ │ └── GantryStateLog.txt │ ├── mask │ │ └── .DS_Store │ ├── rawimages │ │ └── GantryStateLog.txt │ └── sparse │ │ └── 0 │ │ ├── cameras.bin │ │ ├── images.bin │ │ ├── points3D.bin │ │ └── project.ini └── hdrsoap │ ├── colmap_unposed │ └── sfm │ │ ├── database.db │ │ └── images │ └── exr_images │ └── GantryStateLog.txt ├── docs ├── _static │ └── theme_overrides.css ├── _templates │ └── page.html ├── conf.py ├── core_compile.rst ├── core_intro.rst ├── index.rst ├── inverse_diff_render.rst ├── inverse_intro.rst ├── plugin_refs.rst ├── python_intro.rst ├── python_render.rst └── requirements.txt ├── examples ├── python │ ├── AdamUniform.py │ ├── Untitled.py │ ├── constants.py │ ├── learn_real_data.py │ ├── loss.py │ ├── scripts │ │ ├── learn_kiwi.sh │ │ └── learn_soap.sh │ └── tool_functions.py ├── scenes │ ├── kiwi_real.xml │ ├── light │ │ ├── lights-gantry.npy │ │ ├── lights-sy-bunny.npy │ │ ├── lights-sy-cube.npy │ │ ├── lights-sy-layer.npy │ │ ├── lights-sy-platigon.npy │ │ ├── lights-sy-seal.npy │ │ └── lights-sy.npy │ └── soap_real.xml └── smoothshape │ ├── cube_3_init_uv.obj │ └── soap_init.obj ├── include ├── misc │ └── Exception.h ├── psdr │ ├── bsdf │ │ ├── bsdf.h │ │ ├── bssdf.h │ │ ├── diffuse.h │ │ ├── ggx.h │ │ ├── hetersub.h │ │ ├── layersub.h │ │ ├── microfacet.h │ │ ├── roughconductor.h │ │ └── subsurface.h │ ├── constants.h │ ├── core │ │ ├── bitmap.h │ │ ├── bitmap_loader.h │ │ ├── cube_distrb.h │ │ ├── frame.h │ │ ├── intersection.h │ │ ├── pmf.h │ │ ├── ray.h │ │ ├── records.h │ │ ├── sampler.h │ │ ├── transform.h │ │ └── warp.h │ ├── edge │ │ └── edge.h │ ├── emitter │ │ ├── area.h │ │ ├── emitter.h │ │ ├── envmap.h │ │ └── point.h │ ├── fwd.h │ ├── integrator │ │ ├── bdlaser.h │ │ ├── colocate.h │ │ ├── direct.h │ │ ├── direct_origin.h │ │ ├── field.h │ │ ├── integrator.h │ │ └── laser.h │ ├── macros.h │ ├── object.h │ ├── optix │ │ └── ptx.h │ ├── psdr.h │ ├── scene │ │ ├── optix.h │ │ ├── scene.h │ │ ├── scene_loader.h │ │ └── scene_optix.h │ ├── sensor │ │ ├── perspective.h │ │ └── sensor.h │ ├── shape │ │ └── mesh.h │ ├── types.h │ └── utils.h ├── pugixml │ ├── pugiconfig.hpp │ ├── pugixml.cpp │ └── pugixml.hpp └── tiny_obj_loader │ └── tiny_obj_loader.h ├── setpath.sh └── src ├── bsdf ├── bssdf.cpp ├── diffuse.cpp ├── ggx.cpp ├── hetersub.cpp ├── microfacet.cpp └── roughconductor.cpp ├── core ├── bitmap.cpp ├── bitmap_loader.cpp ├── cube_distrb.cpp ├── pmf.cpp └── sampler.cpp ├── emitter ├── area.cpp ├── envmap.cpp └── point.cpp ├── integrator ├── bdlaser.cpp ├── colocate.cpp ├── direct.cpp ├── direct_origin.cpp ├── field.cpp ├── integrator.cpp └── laser.cpp ├── intersect ├── AllIntersectRenderer.cpp ├── AllIntersectRenderer.h ├── CUDABuffer.h ├── LaunchParams.h ├── intersect.cpp ├── intersect.cu └── intersect.h ├── optix └── ptx.cpp ├── psdr.cpp ├── scene ├── scene.cpp ├── scene_loader.cpp └── scene_optix.cpp ├── sensor ├── perspective.cpp └── sensor.cpp └── shape └── mesh.cpp /CMake/FindOpenEXR.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018 NVIDIA Corporation. All rights reserved. 3 | # 4 | # NVIDIA Corporation and its licensors retain all intellectual property and proprietary 5 | # rights in and to this software, related documentation and any modifications thereto. 6 | # Any use, reproduction, disclosure or distribution of this software and related 7 | # documentation without an express license agreement from NVIDIA Corporation is strictly 8 | # prohibited. 9 | # 10 | # TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* 11 | # AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, 12 | # INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 13 | # PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY 14 | # SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT 15 | # LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF 16 | # BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR 17 | # INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF 18 | # SUCH DAMAGES 19 | # 20 | 21 | # Find OpenEXR package. 22 | 23 | # Optional input variable: OpenEXR_ROOT 24 | # Output variables: 25 | # OpenEXR_FOUND 26 | # OpenEXR_INCLUDE_DIR 27 | # OpenEXR_LIBRARIES 28 | # OpenEXR_VERSION 29 | 30 | set( OpenEXR_LIB_NAMES IlmImf Half Iex Imath IlmThread ) 31 | 32 | # If OpenEXR_ROOT has changed, unset variables that depend upon it. 33 | set( OpenEXR_ROOT "" CACHE PATH "Path to OpenEXR installation directory" ) 34 | if( NOT "${OpenEXR_ROOT}" STREQUAL "${OpenEXR_ROOT_PREVIOUS}" ) 35 | message( "New value detected for OpenEXR_ROOT: ${OpenEXR_ROOT}" ) 36 | unset( OpenEXR_INCLUDE_DIR ) 37 | unset( OpenEXR_LIBRARIES ) 38 | unset( OpenEXR_LIB_DIR ) 39 | foreach( LIB ${OpenEXR_LIB_NAMES} ) 40 | unset( OpenEXR_${LIB}_RELEASE ) 41 | unset( OpenEXR_${LIB}_DEBUG ) 42 | endforeach( LIB ) 43 | unset( OpenEXR_VERSION ) 44 | endif() 45 | set( OpenEXR_ROOT_PREVIOUS "${OpenEXR_ROOT}" CACHE PATH "Previous path to OpenEXR" FORCE ) 46 | 47 | # Find OpenEXR includes. 48 | find_path( OpenEXR_INCLUDE_DIR ImfOutputFile.h 49 | HINTS "${OpenEXR_ROOT}/include/OpenEXR" ) 50 | mark_as_advanced( OpenEXR_INCLUDE_DIR ) 51 | 52 | # Get version number from header, which we need for the library names. 53 | set( OpenEXR_VERSION "" CACHE STRING "OpenEXR version string" ) 54 | set( CONFIG_H "${OpenEXR_INCLUDE_DIR}/OpenEXRConfig.h" ) 55 | if( NOT OpenEXR_VERSION AND EXISTS "${CONFIG_H}" ) 56 | message( "Reading OpenEXR version from ${CONFIG_H}" ) 57 | file( STRINGS "${CONFIG_H}" VERSION_STRING 58 | REGEX "#define OPENEXR_VERSION_STRING" ) 59 | string( REGEX REPLACE ".*\"([0-9.]+)\".*" "\\1" VERSION_STRING "${VERSION_STRING}" ) 60 | set( OpenEXR_VERSION "${VERSION_STRING}" CACHE STRING "OpenEXR version string" FORCE ) 61 | endif() 62 | string( REGEX REPLACE "^([0-9]+).*" "\\1" VERSION_MAJOR "${OpenEXR_VERSION}" ) 63 | string( REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${OpenEXR_VERSION}" ) 64 | set( VERSION_SUFFIX "${VERSION_MAJOR}_${VERSION_MINOR}" ) 65 | 66 | # Allow location of library directory to be overridden. 67 | set( OpenEXR_LIB_DIR "${OpenEXR_ROOT}/lib" CACHE PATH "Path to OpenEXR libraries" ) 68 | mark_as_advanced( OpenEXR_LIB_DIR ) 69 | 70 | # Find OpenEXR libraries. 71 | set( OpenEXR_LIBRARIES "" ) 72 | foreach( LIB ${OpenEXR_LIB_NAMES} ) 73 | find_library( OpenEXR_${LIB}_RELEASE 74 | NAMES "${LIB}_s" "${LIB}-${VERSION_SUFFIX}_s" "${LIB}" 75 | HINTS "${OpenEXR_LIB_DIR}" ) 76 | mark_as_advanced( OpenEXR_${LIB}_RELEASE ) 77 | if( OpenEXR_${LIB}_RELEASE ) 78 | list( APPEND OpenEXR_LIBRARIES optimized "${OpenEXR_${LIB}_RELEASE}" ) 79 | endif() 80 | 81 | find_library( OpenEXR_${LIB}_DEBUG 82 | NAMES "${LIB}_s_d" "${LIB}-${VERSION_SUFFIX}_s_d" 83 | HINTS "${OpenEXR_LIB_DIR}" ) 84 | mark_as_advanced( OpenEXR_${LIB}_DEBUG ) 85 | if( OpenEXR_${LIB}_DEBUG ) 86 | list( APPEND OpenEXR_LIBRARIES debug "${OpenEXR_${LIB}_DEBUG}" ) 87 | elseif( OpenEXR_${LIB}_RELEASE ) 88 | # Fallback: use release libraries if no debug libraries were found. 89 | list( APPEND OpenEXR_LIBRARIES debug "${OpenEXR_${LIB}_RELEASE}" ) 90 | endif() 91 | endforeach( LIB ) 92 | 93 | include( FindPackageHandleStandardArgs ) 94 | 95 | # find_package_handle_standard_args reports the value of the first variable 96 | # on success, so make sure this is the actual OpenEXR library 97 | find_package_handle_standard_args( OpenEXR 98 | REQUIRED_VARS 99 | OpenEXR_IlmImf_RELEASE OpenEXR_Half_RELEASE OpenEXR_Iex_RELEASE OpenEXR_Imath_RELEASE OpenEXR_IlmThread_RELEASE 100 | OpenEXR_INCLUDE_DIR 101 | VERSION_VAR OpenEXR_VERSION ) 102 | -------------------------------------------------------------------------------- /CMake/FindOptiX.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions 6 | # are met: 7 | # * Redistributions of source code must retain the above copyright 8 | # notice, this list of conditions and the following disclaimer. 9 | # * Redistributions in binary form must reproduce the above copyright 10 | # notice, this list of conditions and the following disclaimer in the 11 | # documentation and/or other materials provided with the distribution. 12 | # * Neither the name of NVIDIA CORPORATION nor the names of its 13 | # contributors may be used to endorse or promote products derived 14 | # from this software without specific prior written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 17 | # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | # 28 | 29 | # Locate the OptiX distribution. Search relative to the SDK first, then look in the system. 30 | 31 | # Our initial guess will be within the SDK. 32 | 33 | set(OptiX_INSTALL_DIR "${CMAKE_SOURCE_DIR}/optix/" CACHE PATH "Path to OptiX installed location.") 34 | # The distribution contains only 64 bit libraries. Error when we have been mis-configured. 35 | if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) 36 | if(WIN32) 37 | message(SEND_ERROR "Make sure when selecting the generator, you select one with Win64 or x64.") 38 | endif() 39 | message(FATAL_ERROR "OptiX only supports builds configured for 64 bits.") 40 | endif() 41 | 42 | # search path based on the bit-ness of the build. (i.e. 64: bin64, lib64; 32: 43 | # bin, lib). Note that on Mac, the OptiX library is a universal binary, so we 44 | # only need to look in lib and not lib64 for 64 bit builds. 45 | if(NOT APPLE) 46 | set(bit_dest "64") 47 | else() 48 | set(bit_dest "") 49 | endif() 50 | 51 | # Include 52 | find_path(OptiX_INCLUDE 53 | NAMES optix.h 54 | PATHS "${OptiX_INSTALL_DIR}/include" 55 | NO_DEFAULT_PATH 56 | ) 57 | find_path(OptiX_INCLUDE 58 | NAMES optix.h 59 | ) 60 | 61 | # Check to make sure we found what we were looking for 62 | function(OptiX_report_error error_message required component ) 63 | if(DEFINED OptiX_FIND_REQUIRED_${component} AND NOT OptiX_FIND_REQUIRED_${component}) 64 | set(required FALSE) 65 | endif() 66 | if(OptiX_FIND_REQUIRED AND required) 67 | message(FATAL_ERROR "${error_message} Please locate before proceeding.") 68 | else() 69 | if(NOT OptiX_FIND_QUIETLY) 70 | message(STATUS "${error_message}") 71 | endif(NOT OptiX_FIND_QUIETLY) 72 | endif() 73 | endfunction() 74 | 75 | if(NOT OptiX_INCLUDE) 76 | OptiX_report_error("OptiX headers (optix.h and friends) not found." TRUE headers ) 77 | endif() 78 | 79 | -------------------------------------------------------------------------------- /CMake/configure_optix.cmake: -------------------------------------------------------------------------------- 1 | # ======================================================================== # 2 | # Copyright 2018 Ingo Wald # 3 | # # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); # 5 | # you may not use this file except in compliance with the License. # 6 | # You may obtain a copy of the License at # 7 | # # 8 | # http://www.apache.org/licenses/LICENSE-2.0 # 9 | # # 10 | # Unless required by applicable law or agreed to in writing, software # 11 | # distributed under the License is distributed on an "AS IS" BASIS, # 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 13 | # See the License for the specific language governing permissions and # 14 | # limitations under the License. # 15 | # ======================================================================== # 16 | 17 | set(CMAKE_MODULE_PATH 18 | "${PROJECT_SOURCE_DIR}/cmake" 19 | # "${CMAKE_CURRENT_SOURCE_DIR}/../cmake" 20 | ${CMAKE_MODULE_PATH} 21 | ) 22 | 23 | find_package(CUDA REQUIRED) 24 | find_package(OptiX REQUIRED) 25 | 26 | #include_directories(${CUDA_TOOLKIT_INCLUDE}) 27 | if (CUDA_TOOLKIT_ROOT_DIR) 28 | include_directories(${CUDA_TOOLKIT_ROOT_DIR}/include) 29 | endif() 30 | include_directories(${OptiX_INCLUDE}) 31 | 32 | if (WIN32) 33 | add_definitions(-DNOMINMAX) 34 | endif() 35 | 36 | find_program(BIN2C bin2c 37 | DOC "Path to the cuda-sdk bin2c executable.") 38 | 39 | # this macro defines cmake rules that execute the following four steps: 40 | # 1) compile the given cuda file ${cuda_file} to an intermediary PTX file 41 | # 2) use the 'bin2c' tool (that comes with CUDA) to 42 | # create a second intermediary (.c-)file which defines a const string variable 43 | # (named '${c_var_name}') whose (constant) value is the PTX output 44 | # from the previous step. 45 | # 3) compile the given .c file to an intermediary object file (why thus has 46 | # that PTX string 'embedded' as a global constant. 47 | # 4) assign the name of the intermediary .o file to the cmake variable 48 | # 'output_var', which can then be added to cmake targets. 49 | macro(cuda_compile_and_embed output_var cuda_file) 50 | set(c_var_name ${output_var}) 51 | cuda_compile_ptx(ptx_files ${cuda_file} OPTIONS --generate-line-info -use_fast_math --keep) 52 | list(GET ptx_files 0 ptx_file) 53 | set(embedded_file ${ptx_file}_embedded.c) 54 | # message("adding rule to compile and embed ${cuda_file} to \"const char ${var_name}[];\"") 55 | add_custom_command( 56 | OUTPUT ${embedded_file} 57 | COMMAND ${BIN2C} -c --padd 0 --type char --name ${c_var_name} ${ptx_file} > ${embedded_file} 58 | DEPENDS ${ptx_file} 59 | COMMENT "compiling (and embedding ptx from) ${cuda_file}" 60 | ) 61 | set(${output_var} ${embedded_file}) 62 | endmacro() 63 | 64 | include_directories(${OptiX_INCLUDE}) 65 | 66 | add_definitions(-D__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__=1) 67 | 68 | 69 | -------------------------------------------------------------------------------- /CMakeFiles/3.20.1/CMakeCCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_COMPILER "/usr/bin/gcc-9") 2 | set(CMAKE_C_COMPILER_ARG1 "") 3 | set(CMAKE_C_COMPILER_ID "GNU") 4 | set(CMAKE_C_COMPILER_VERSION "9.3.0") 5 | set(CMAKE_C_COMPILER_VERSION_INTERNAL "") 6 | set(CMAKE_C_COMPILER_WRAPPER "") 7 | set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11") 8 | set(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert") 9 | set(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes") 10 | set(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros") 11 | set(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert") 12 | 13 | set(CMAKE_C_PLATFORM_ID "Linux") 14 | set(CMAKE_C_SIMULATE_ID "") 15 | set(CMAKE_C_COMPILER_FRONTEND_VARIANT "") 16 | set(CMAKE_C_SIMULATE_VERSION "") 17 | 18 | 19 | 20 | 21 | set(CMAKE_AR "/usr/bin/ar") 22 | set(CMAKE_C_COMPILER_AR "/usr/bin/gcc-ar-9") 23 | set(CMAKE_RANLIB "/usr/bin/ranlib") 24 | set(CMAKE_C_COMPILER_RANLIB "/usr/bin/gcc-ranlib-9") 25 | set(CMAKE_LINKER "/usr/bin/ld") 26 | set(CMAKE_MT "") 27 | set(CMAKE_COMPILER_IS_GNUCC 1) 28 | set(CMAKE_C_COMPILER_LOADED 1) 29 | set(CMAKE_C_COMPILER_WORKS TRUE) 30 | set(CMAKE_C_ABI_COMPILED TRUE) 31 | set(CMAKE_COMPILER_IS_MINGW ) 32 | set(CMAKE_COMPILER_IS_CYGWIN ) 33 | if(CMAKE_COMPILER_IS_CYGWIN) 34 | set(CYGWIN 1) 35 | set(UNIX 1) 36 | endif() 37 | 38 | set(CMAKE_C_COMPILER_ENV_VAR "CC") 39 | 40 | if(CMAKE_COMPILER_IS_MINGW) 41 | set(MINGW 1) 42 | endif() 43 | set(CMAKE_C_COMPILER_ID_RUN 1) 44 | set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) 45 | set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) 46 | set(CMAKE_C_LINKER_PREFERENCE 10) 47 | 48 | # Save compiler ABI information. 49 | set(CMAKE_C_SIZEOF_DATA_PTR "8") 50 | set(CMAKE_C_COMPILER_ABI "ELF") 51 | set(CMAKE_C_BYTE_ORDER "LITTLE_ENDIAN") 52 | set(CMAKE_C_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 53 | 54 | if(CMAKE_C_SIZEOF_DATA_PTR) 55 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") 56 | endif() 57 | 58 | if(CMAKE_C_COMPILER_ABI) 59 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") 60 | endif() 61 | 62 | if(CMAKE_C_LIBRARY_ARCHITECTURE) 63 | set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu") 64 | endif() 65 | 66 | set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "") 67 | if(CMAKE_C_CL_SHOWINCLUDES_PREFIX) 68 | set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}") 69 | endif() 70 | 71 | 72 | 73 | 74 | 75 | set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/9/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include") 76 | set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "gcc;gcc_s;c;gcc;gcc_s") 77 | set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/lib/gcc/x86_64-linux-gnu/9;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib") 78 | set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") 79 | -------------------------------------------------------------------------------- /CMakeFiles/3.20.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/CMakeFiles/3.20.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /CMakeFiles/3.20.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/CMakeFiles/3.20.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /CMakeFiles/3.20.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Linux-5.3.0-62-generic") 2 | set(CMAKE_HOST_SYSTEM_NAME "Linux") 3 | set(CMAKE_HOST_SYSTEM_VERSION "5.3.0-62-generic") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Linux-5.3.0-62-generic") 9 | set(CMAKE_SYSTEM_NAME "Linux") 10 | set(CMAKE_SYSTEM_VERSION "5.3.0-62-generic") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /CMakeFiles/3.20.1/CompilerIdC/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/CMakeFiles/3.20.1/CompilerIdC/a.out -------------------------------------------------------------------------------- /CMakeFiles/3.20.1/CompilerIdCXX/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/CMakeFiles/3.20.1/CompilerIdCXX/a.out -------------------------------------------------------------------------------- /CMakeFiles/CMakeError.log: -------------------------------------------------------------------------------- 1 | Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output: 2 | Change Dir: /home/xd/Research/psdr-cuda/CMakeFiles/CMakeTmp 3 | 4 | Run Build Command(s):/usr/bin/make -f Makefile cmTC_ff2a3/fast && /usr/bin/make -f CMakeFiles/cmTC_ff2a3.dir/build.make CMakeFiles/cmTC_ff2a3.dir/build 5 | make[1]: Entering directory '/home/xd/Research/psdr-cuda/CMakeFiles/CMakeTmp' 6 | Building C object CMakeFiles/cmTC_ff2a3.dir/src.c.o 7 | /usr/bin/gcc-9 -DCMAKE_HAVE_LIBC_PTHREAD -fPIC -o CMakeFiles/cmTC_ff2a3.dir/src.c.o -c /home/xd/Research/psdr-cuda/CMakeFiles/CMakeTmp/src.c 8 | Linking C executable cmTC_ff2a3 9 | /opt/cmake-3.20.1-linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ff2a3.dir/link.txt --verbose=1 10 | /usr/bin/gcc-9 -fPIC -rdynamic CMakeFiles/cmTC_ff2a3.dir/src.c.o -o cmTC_ff2a3 11 | /usr/bin/ld: CMakeFiles/cmTC_ff2a3.dir/src.c.o: in function `main': 12 | src.c:(.text+0x3e): undefined reference to `pthread_create' 13 | /usr/bin/ld: src.c:(.text+0x4a): undefined reference to `pthread_detach' 14 | /usr/bin/ld: src.c:(.text+0x56): undefined reference to `pthread_cancel' 15 | /usr/bin/ld: src.c:(.text+0x67): undefined reference to `pthread_join' 16 | collect2: error: ld returned 1 exit status 17 | make[1]: *** [CMakeFiles/cmTC_ff2a3.dir/build.make:99: cmTC_ff2a3] Error 1 18 | make[1]: Leaving directory '/home/xd/Research/psdr-cuda/CMakeFiles/CMakeTmp' 19 | make: *** [Makefile:127: cmTC_ff2a3/fast] Error 2 20 | 21 | 22 | Source file was: 23 | #include 24 | 25 | static void* test_func(void* data) 26 | { 27 | return data; 28 | } 29 | 30 | int main(void) 31 | { 32 | pthread_t thread; 33 | pthread_create(&thread, NULL, test_func, NULL); 34 | pthread_detach(thread); 35 | pthread_cancel(thread); 36 | pthread_join(thread, NULL); 37 | pthread_atfork(NULL, NULL, NULL); 38 | pthread_exit(NULL); 39 | 40 | return 0; 41 | } 42 | 43 | Determining if the function pthread_create exists in the pthreads failed with the following output: 44 | Change Dir: /home/xd/Research/psdr-cuda/CMakeFiles/CMakeTmp 45 | 46 | Run Build Command(s):/usr/bin/make -f Makefile cmTC_5d365/fast && /usr/bin/make -f CMakeFiles/cmTC_5d365.dir/build.make CMakeFiles/cmTC_5d365.dir/build 47 | make[1]: Entering directory '/home/xd/Research/psdr-cuda/CMakeFiles/CMakeTmp' 48 | Building C object CMakeFiles/cmTC_5d365.dir/CheckFunctionExists.c.o 49 | /usr/bin/gcc-9 -fPIC -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_5d365.dir/CheckFunctionExists.c.o -c /opt/cmake-3.20.1-linux-x86_64/share/cmake-3.20/Modules/CheckFunctionExists.c 50 | Linking C executable cmTC_5d365 51 | /opt/cmake-3.20.1-linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5d365.dir/link.txt --verbose=1 52 | /usr/bin/gcc-9 -fPIC -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_5d365.dir/CheckFunctionExists.c.o -o cmTC_5d365 -lpthreads 53 | /usr/bin/ld: cannot find -lpthreads 54 | collect2: error: ld returned 1 exit status 55 | make[1]: *** [CMakeFiles/cmTC_5d365.dir/build.make:99: cmTC_5d365] Error 1 56 | make[1]: Leaving directory '/home/xd/Research/psdr-cuda/CMakeFiles/CMakeTmp' 57 | make: *** [Makefile:127: cmTC_5d365/fast] Error 2 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /CMakeFiles/CMakeRuleHashes.txt: -------------------------------------------------------------------------------- 1 | # Hashes of file build rules. 2 | 654c1c07424efd4dce251e91f5cb7ea5 lib/ptx/ptx_generated_psdr_cuda.cu.ptx 3 | -------------------------------------------------------------------------------- /CMakeFiles/Progress/1: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/10: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/11: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/12: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/13: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/14: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/15: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/16: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/17: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/18: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/19: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/2: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/20: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/21: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/22: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/23: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/24: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/25: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/26: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/3: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/4: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/5: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/6: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/7: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/8: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/9: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /CMakeFiles/Progress/count.txt: -------------------------------------------------------------------------------- 1 | 28 2 | -------------------------------------------------------------------------------- /CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /home/xd/Research/psdr-cuda/CMakeFiles/rebuild_cache.dir 2 | /home/xd/Research/psdr-cuda/CMakeFiles/edit_cache.dir 3 | /home/xd/Research/psdr-cuda/CMakeFiles/psdr_cuda.dir 4 | /home/xd/Research/psdr-cuda/CMakeFiles/ptx.dir 5 | -------------------------------------------------------------------------------- /CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 28 2 | -------------------------------------------------------------------------------- /CMakeFiles/psdr_cuda.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Consider dependencies only in project. 3 | set(CMAKE_DEPENDS_IN_PROJECT_ONLY OFF) 4 | 5 | # The set of languages for which implicit dependencies are needed: 6 | set(CMAKE_DEPENDS_LANGUAGES 7 | ) 8 | 9 | # The set of dependency files which are needed: 10 | set(CMAKE_DEPENDS_DEPENDENCY_FILES 11 | "/home/xd/Research/psdr-cuda/src/bsdf/diffuse.cpp" "CMakeFiles/psdr_cuda.dir/src/bsdf/diffuse.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/bsdf/diffuse.cpp.o.d" 12 | "/home/xd/Research/psdr-cuda/src/bsdf/ggx.cpp" "CMakeFiles/psdr_cuda.dir/src/bsdf/ggx.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/bsdf/ggx.cpp.o.d" 13 | "/home/xd/Research/psdr-cuda/src/bsdf/roughconductor.cpp" "CMakeFiles/psdr_cuda.dir/src/bsdf/roughconductor.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/bsdf/roughconductor.cpp.o.d" 14 | "/home/xd/Research/psdr-cuda/src/bsdf/subsurface.cpp" "CMakeFiles/psdr_cuda.dir/src/bsdf/subsurface.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/bsdf/subsurface.cpp.o.d" 15 | "/home/xd/Research/psdr-cuda/src/core/bitmap.cpp" "CMakeFiles/psdr_cuda.dir/src/core/bitmap.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/core/bitmap.cpp.o.d" 16 | "/home/xd/Research/psdr-cuda/src/core/bitmap_loader.cpp" "CMakeFiles/psdr_cuda.dir/src/core/bitmap_loader.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/core/bitmap_loader.cpp.o.d" 17 | "/home/xd/Research/psdr-cuda/src/core/cube_distrb.cpp" "CMakeFiles/psdr_cuda.dir/src/core/cube_distrb.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/core/cube_distrb.cpp.o.d" 18 | "/home/xd/Research/psdr-cuda/src/core/pmf.cpp" "CMakeFiles/psdr_cuda.dir/src/core/pmf.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/core/pmf.cpp.o.d" 19 | "/home/xd/Research/psdr-cuda/src/core/sampler.cpp" "CMakeFiles/psdr_cuda.dir/src/core/sampler.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/core/sampler.cpp.o.d" 20 | "/home/xd/Research/psdr-cuda/src/emitter/area.cpp" "CMakeFiles/psdr_cuda.dir/src/emitter/area.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/emitter/area.cpp.o.d" 21 | "/home/xd/Research/psdr-cuda/src/emitter/envmap.cpp" "CMakeFiles/psdr_cuda.dir/src/emitter/envmap.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/emitter/envmap.cpp.o.d" 22 | "/home/xd/Research/psdr-cuda/src/integrator/direct.cpp" "CMakeFiles/psdr_cuda.dir/src/integrator/direct.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/integrator/direct.cpp.o.d" 23 | "/home/xd/Research/psdr-cuda/src/integrator/direct_origin.cpp" "CMakeFiles/psdr_cuda.dir/src/integrator/direct_origin.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/integrator/direct_origin.cpp.o.d" 24 | "/home/xd/Research/psdr-cuda/src/integrator/field.cpp" "CMakeFiles/psdr_cuda.dir/src/integrator/field.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/integrator/field.cpp.o.d" 25 | "/home/xd/Research/psdr-cuda/src/integrator/integrator.cpp" "CMakeFiles/psdr_cuda.dir/src/integrator/integrator.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/integrator/integrator.cpp.o.d" 26 | "/home/xd/Research/psdr-cuda/src/integrator/laser.cpp" "CMakeFiles/psdr_cuda.dir/src/integrator/laser.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/integrator/laser.cpp.o.d" 27 | "/home/xd/Research/psdr-cuda/src/optix/ptx.cpp" "CMakeFiles/psdr_cuda.dir/src/optix/ptx.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/optix/ptx.cpp.o.d" 28 | "/home/xd/Research/psdr-cuda/src/psdr.cpp" "CMakeFiles/psdr_cuda.dir/src/psdr.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/psdr.cpp.o.d" 29 | "/home/xd/Research/psdr-cuda/src/scene/scene.cpp" "CMakeFiles/psdr_cuda.dir/src/scene/scene.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/scene/scene.cpp.o.d" 30 | "/home/xd/Research/psdr-cuda/src/scene/scene_loader.cpp" "CMakeFiles/psdr_cuda.dir/src/scene/scene_loader.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/scene/scene_loader.cpp.o.d" 31 | "/home/xd/Research/psdr-cuda/src/scene/scene_optix.cpp" "CMakeFiles/psdr_cuda.dir/src/scene/scene_optix.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/scene/scene_optix.cpp.o.d" 32 | "/home/xd/Research/psdr-cuda/src/sensor/perspective.cpp" "CMakeFiles/psdr_cuda.dir/src/sensor/perspective.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/sensor/perspective.cpp.o.d" 33 | "/home/xd/Research/psdr-cuda/src/sensor/sensor.cpp" "CMakeFiles/psdr_cuda.dir/src/sensor/sensor.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/sensor/sensor.cpp.o.d" 34 | "/home/xd/Research/psdr-cuda/src/shape/mesh.cpp" "CMakeFiles/psdr_cuda.dir/src/shape/mesh.cpp.o" "gcc" "CMakeFiles/psdr_cuda.dir/src/shape/mesh.cpp.o.d" 35 | ) 36 | 37 | # Targets to which this target links. 38 | set(CMAKE_TARGET_LINKED_INFO_FILES 39 | ) 40 | 41 | # Fortran module output directory. 42 | set(CMAKE_Fortran_TARGET_MODULE_DIR "") 43 | -------------------------------------------------------------------------------- /CMakeFiles/psdr_cuda.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "CMakeFiles/psdr_cuda.dir/src/bsdf/diffuse.cpp.o" 3 | "CMakeFiles/psdr_cuda.dir/src/bsdf/diffuse.cpp.o.d" 4 | "CMakeFiles/psdr_cuda.dir/src/bsdf/ggx.cpp.o" 5 | "CMakeFiles/psdr_cuda.dir/src/bsdf/ggx.cpp.o.d" 6 | "CMakeFiles/psdr_cuda.dir/src/bsdf/roughconductor.cpp.o" 7 | "CMakeFiles/psdr_cuda.dir/src/bsdf/roughconductor.cpp.o.d" 8 | "CMakeFiles/psdr_cuda.dir/src/bsdf/subsurface.cpp.o" 9 | "CMakeFiles/psdr_cuda.dir/src/bsdf/subsurface.cpp.o.d" 10 | "CMakeFiles/psdr_cuda.dir/src/core/bitmap.cpp.o" 11 | "CMakeFiles/psdr_cuda.dir/src/core/bitmap.cpp.o.d" 12 | "CMakeFiles/psdr_cuda.dir/src/core/bitmap_loader.cpp.o" 13 | "CMakeFiles/psdr_cuda.dir/src/core/bitmap_loader.cpp.o.d" 14 | "CMakeFiles/psdr_cuda.dir/src/core/cube_distrb.cpp.o" 15 | "CMakeFiles/psdr_cuda.dir/src/core/cube_distrb.cpp.o.d" 16 | "CMakeFiles/psdr_cuda.dir/src/core/pmf.cpp.o" 17 | "CMakeFiles/psdr_cuda.dir/src/core/pmf.cpp.o.d" 18 | "CMakeFiles/psdr_cuda.dir/src/core/sampler.cpp.o" 19 | "CMakeFiles/psdr_cuda.dir/src/core/sampler.cpp.o.d" 20 | "CMakeFiles/psdr_cuda.dir/src/emitter/area.cpp.o" 21 | "CMakeFiles/psdr_cuda.dir/src/emitter/area.cpp.o.d" 22 | "CMakeFiles/psdr_cuda.dir/src/emitter/envmap.cpp.o" 23 | "CMakeFiles/psdr_cuda.dir/src/emitter/envmap.cpp.o.d" 24 | "CMakeFiles/psdr_cuda.dir/src/integrator/direct.cpp.o" 25 | "CMakeFiles/psdr_cuda.dir/src/integrator/direct.cpp.o.d" 26 | "CMakeFiles/psdr_cuda.dir/src/integrator/direct_origin.cpp.o" 27 | "CMakeFiles/psdr_cuda.dir/src/integrator/direct_origin.cpp.o.d" 28 | "CMakeFiles/psdr_cuda.dir/src/integrator/field.cpp.o" 29 | "CMakeFiles/psdr_cuda.dir/src/integrator/field.cpp.o.d" 30 | "CMakeFiles/psdr_cuda.dir/src/integrator/integrator.cpp.o" 31 | "CMakeFiles/psdr_cuda.dir/src/integrator/integrator.cpp.o.d" 32 | "CMakeFiles/psdr_cuda.dir/src/integrator/laser.cpp.o" 33 | "CMakeFiles/psdr_cuda.dir/src/integrator/laser.cpp.o.d" 34 | "CMakeFiles/psdr_cuda.dir/src/optix/ptx.cpp.o" 35 | "CMakeFiles/psdr_cuda.dir/src/optix/ptx.cpp.o.d" 36 | "CMakeFiles/psdr_cuda.dir/src/psdr.cpp.o" 37 | "CMakeFiles/psdr_cuda.dir/src/psdr.cpp.o.d" 38 | "CMakeFiles/psdr_cuda.dir/src/scene/scene.cpp.o" 39 | "CMakeFiles/psdr_cuda.dir/src/scene/scene.cpp.o.d" 40 | "CMakeFiles/psdr_cuda.dir/src/scene/scene_loader.cpp.o" 41 | "CMakeFiles/psdr_cuda.dir/src/scene/scene_loader.cpp.o.d" 42 | "CMakeFiles/psdr_cuda.dir/src/scene/scene_optix.cpp.o" 43 | "CMakeFiles/psdr_cuda.dir/src/scene/scene_optix.cpp.o.d" 44 | "CMakeFiles/psdr_cuda.dir/src/sensor/perspective.cpp.o" 45 | "CMakeFiles/psdr_cuda.dir/src/sensor/perspective.cpp.o.d" 46 | "CMakeFiles/psdr_cuda.dir/src/sensor/sensor.cpp.o" 47 | "CMakeFiles/psdr_cuda.dir/src/sensor/sensor.cpp.o.d" 48 | "CMakeFiles/psdr_cuda.dir/src/shape/mesh.cpp.o" 49 | "CMakeFiles/psdr_cuda.dir/src/shape/mesh.cpp.o.d" 50 | "lib/psdr_cuda.pdb" 51 | "lib/psdr_cuda.so" 52 | ) 53 | 54 | # Per-language clean rules from dependency scanning. 55 | foreach(lang CXX) 56 | include(CMakeFiles/psdr_cuda.dir/cmake_clean_${lang}.cmake OPTIONAL) 57 | endforeach() 58 | -------------------------------------------------------------------------------- /CMakeFiles/psdr_cuda.dir/compiler_depend.make: -------------------------------------------------------------------------------- 1 | # Empty compiler generated dependencies file for psdr_cuda. 2 | # This may be replaced when dependencies are built. 3 | -------------------------------------------------------------------------------- /CMakeFiles/psdr_cuda.dir/compiler_depend.ts: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Timestamp file for compiler generated dependencies management for psdr_cuda. 3 | -------------------------------------------------------------------------------- /CMakeFiles/psdr_cuda.dir/depend.make: -------------------------------------------------------------------------------- 1 | # Empty dependencies file for psdr_cuda. 2 | # This may be replaced when dependencies are built. 3 | -------------------------------------------------------------------------------- /CMakeFiles/psdr_cuda.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.20 3 | 4 | # compile CXX with /usr/bin/g++-9 5 | CXX_DEFINES = -DPSDR_CUDA_FILE=\"psdr_cuda\" -DPTX_OUTPUT_DIR=\"/home/xd/Research/psdr-cuda/lib/ptx\" -Dpsdr_cuda_EXPORTS 6 | 7 | CXX_INCLUDES = -I/home/xd/Research/psdr-cuda/include -I/home/xd/Research/psdr-cuda/ext/optix/include -I/home/xd/Research/psdr-cuda/cuda -I/home/xd/Research/psdr-cuda -I/usr/local/cuda-10.2/include -I/usr/include/OpenEXR -I/usr/include/python3.7m -I/home/xd/Research/psdr-cuda/ext/enoki/include 8 | 9 | CXX_FLAGS = -O0 -g -Wall -g -fPIC -std=gnu++17 10 | 11 | -------------------------------------------------------------------------------- /CMakeFiles/psdr_cuda.dir/link.txt: -------------------------------------------------------------------------------- 1 | /usr/bin/g++-9 -fPIC -O0 -g -Wall -g -shared -o lib/psdr_cuda.so CMakeFiles/psdr_cuda.dir/src/core/bitmap.cpp.o CMakeFiles/psdr_cuda.dir/src/core/bitmap_loader.cpp.o CMakeFiles/psdr_cuda.dir/src/core/sampler.cpp.o CMakeFiles/psdr_cuda.dir/src/core/pmf.cpp.o CMakeFiles/psdr_cuda.dir/src/core/cube_distrb.cpp.o CMakeFiles/psdr_cuda.dir/src/bsdf/subsurface.cpp.o CMakeFiles/psdr_cuda.dir/src/bsdf/diffuse.cpp.o CMakeFiles/psdr_cuda.dir/src/bsdf/ggx.cpp.o CMakeFiles/psdr_cuda.dir/src/bsdf/roughconductor.cpp.o CMakeFiles/psdr_cuda.dir/src/emitter/area.cpp.o CMakeFiles/psdr_cuda.dir/src/emitter/envmap.cpp.o CMakeFiles/psdr_cuda.dir/src/sensor/sensor.cpp.o CMakeFiles/psdr_cuda.dir/src/sensor/perspective.cpp.o CMakeFiles/psdr_cuda.dir/src/shape/mesh.cpp.o CMakeFiles/psdr_cuda.dir/src/optix/ptx.cpp.o CMakeFiles/psdr_cuda.dir/src/scene/scene_optix.cpp.o CMakeFiles/psdr_cuda.dir/src/scene/scene.cpp.o CMakeFiles/psdr_cuda.dir/src/scene/scene_loader.cpp.o CMakeFiles/psdr_cuda.dir/src/integrator/integrator.cpp.o CMakeFiles/psdr_cuda.dir/src/integrator/field.cpp.o CMakeFiles/psdr_cuda.dir/src/integrator/direct.cpp.o CMakeFiles/psdr_cuda.dir/src/integrator/laser.cpp.o CMakeFiles/psdr_cuda.dir/src/integrator/direct_origin.cpp.o CMakeFiles/psdr_cuda.dir/src/psdr.cpp.o -L/home/xd/Research/psdr-cuda/ext/enoki/build /usr/local/cuda-10.2/lib64/libcudart_static.a -ldl -lrt -lenoki-cuda -lenoki-autodiff -lcuda /usr/local/cuda-10.2/lib64/libcudart_static.a -ldl -lrt -lIlmImf -lHalf -lIex -lImath -lIlmThread -lenoki-cuda -lenoki-autodiff -lcuda -lIlmImf -lHalf -lIex -lImath -lIlmThread -lpthread 2 | -------------------------------------------------------------------------------- /CMakeFiles/psdr_cuda.dir/progress.make: -------------------------------------------------------------------------------- 1 | CMAKE_PROGRESS_1 = 1 2 | CMAKE_PROGRESS_2 = 2 3 | CMAKE_PROGRESS_3 = 3 4 | CMAKE_PROGRESS_4 = 4 5 | CMAKE_PROGRESS_5 = 5 6 | CMAKE_PROGRESS_6 = 6 7 | CMAKE_PROGRESS_7 = 7 8 | CMAKE_PROGRESS_8 = 8 9 | CMAKE_PROGRESS_9 = 9 10 | CMAKE_PROGRESS_10 = 10 11 | CMAKE_PROGRESS_11 = 11 12 | CMAKE_PROGRESS_12 = 12 13 | CMAKE_PROGRESS_13 = 13 14 | CMAKE_PROGRESS_14 = 14 15 | CMAKE_PROGRESS_15 = 15 16 | CMAKE_PROGRESS_16 = 16 17 | CMAKE_PROGRESS_17 = 17 18 | CMAKE_PROGRESS_18 = 18 19 | CMAKE_PROGRESS_19 = 19 20 | CMAKE_PROGRESS_20 = 20 21 | CMAKE_PROGRESS_21 = 21 22 | CMAKE_PROGRESS_22 = 22 23 | CMAKE_PROGRESS_23 = 23 24 | CMAKE_PROGRESS_24 = 24 25 | CMAKE_PROGRESS_25 = 25 26 | 27 | -------------------------------------------------------------------------------- /CMakeFiles/ptx.dir/DependInfo.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Consider dependencies only in project. 3 | set(CMAKE_DEPENDS_IN_PROJECT_ONLY OFF) 4 | 5 | # The set of languages for which implicit dependencies are needed: 6 | set(CMAKE_DEPENDS_LANGUAGES 7 | ) 8 | 9 | # The set of dependency files which are needed: 10 | set(CMAKE_DEPENDS_DEPENDENCY_FILES 11 | "/home/xd/Research/psdr-cuda/cuda/psdr_cuda.cpp" "CMakeFiles/ptx.dir/cuda/psdr_cuda.cpp.o" "gcc" "CMakeFiles/ptx.dir/cuda/psdr_cuda.cpp.o.d" 12 | ) 13 | 14 | # Targets to which this target links. 15 | set(CMAKE_TARGET_LINKED_INFO_FILES 16 | ) 17 | 18 | # Fortran module output directory. 19 | set(CMAKE_Fortran_TARGET_MODULE_DIR "") 20 | -------------------------------------------------------------------------------- /CMakeFiles/ptx.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "CMakeFiles/ptx.dir/cuda/psdr_cuda.cpp.o" 3 | "CMakeFiles/ptx.dir/cuda/psdr_cuda.cpp.o.d" 4 | "bin/ptx" 5 | "bin/ptx.pdb" 6 | "lib/ptx/ptx_generated_psdr_cuda.cu.ptx" 7 | ) 8 | 9 | # Per-language clean rules from dependency scanning. 10 | foreach(lang CXX) 11 | include(CMakeFiles/ptx.dir/cmake_clean_${lang}.cmake OPTIONAL) 12 | endforeach() 13 | -------------------------------------------------------------------------------- /CMakeFiles/ptx.dir/compiler_depend.make: -------------------------------------------------------------------------------- 1 | # Empty compiler generated dependencies file for ptx. 2 | # This may be replaced when dependencies are built. 3 | -------------------------------------------------------------------------------- /CMakeFiles/ptx.dir/compiler_depend.ts: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Timestamp file for compiler generated dependencies management for ptx. 3 | -------------------------------------------------------------------------------- /CMakeFiles/ptx.dir/cuda/ptx_generated_psdr_cuda.cu.ptx.depend: -------------------------------------------------------------------------------- 1 | #FindCUDA.cmake generated file. Do not edit. 2 | -------------------------------------------------------------------------------- /CMakeFiles/ptx.dir/depend.make: -------------------------------------------------------------------------------- 1 | # Empty dependencies file for ptx. 2 | # This may be replaced when dependencies are built. 3 | -------------------------------------------------------------------------------- /CMakeFiles/ptx.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.20 3 | 4 | # compile CXX with /usr/bin/g++-9 5 | CXX_DEFINES = -DOPTIX_SAMPLE_NAME_DEFINE=ptx -DPSDR_CUDA_FILE=\"psdr_cuda\" 6 | 7 | CXX_INCLUDES = -I/home/xd/Research/psdr-cuda/include -I/home/xd/Research/psdr-cuda/ext/optix/include -I/home/xd/Research/psdr-cuda/cuda -I/home/xd/Research/psdr-cuda -I/usr/local/cuda-10.2/include -I/usr/include/OpenEXR -I/usr/include/python3.7m -I/home/xd/Research/psdr-cuda/ext/enoki/include 8 | 9 | CXX_FLAGS = -O0 -g -Wall -g -std=gnu++17 10 | 11 | -------------------------------------------------------------------------------- /CMakeFiles/ptx.dir/link.txt: -------------------------------------------------------------------------------- 1 | /usr/bin/g++-9 -O0 -g -Wall -g -rdynamic CMakeFiles/ptx.dir/cuda/psdr_cuda.cpp.o -o bin/ptx -L/home/xd/Research/psdr-cuda/ext/enoki/build 2 | -------------------------------------------------------------------------------- /CMakeFiles/ptx.dir/progress.make: -------------------------------------------------------------------------------- 1 | CMAKE_PROGRESS_1 = 26 2 | CMAKE_PROGRESS_2 = 27 3 | CMAKE_PROGRESS_3 = 28 4 | 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Shuang Zhao, All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # psdr-cuda 2 | This is a path space differentiable renderer (psdr-cuda) with bssrdf support which forked from [psdr-cuda](https://psdr-cuda.readthedocs.io/en/latest/). The derivation and experimental detail can be found in [paper](https://www.cs.cornell.edu/~xideng/pub/deng22dsss.pdf). 3 | 4 | 5 | ## Compile 6 | To build the code, please follow this process of [compiling psdr-cuda](https://psdr-cuda.readthedocs.io/en/latest/core_compile.html) 7 | 8 | ## Materials 9 | The material we use in reconstructing is `HeterSub`, the definition and implementation can be found in `hetersub.h` and `hetersub.cpp`, currently, it is using dipole model, one can switch to better diphole in the future. The expression of diphole model and better diphole model can be found in [this report](http://www.eugenedeon.com/wp-content/uploads/2014/04/betterdipole.pdf). 10 | 11 | ## Integrators 12 | 13 | Here are several integrators implemented in this framework, the one we used for reconstruction is the `DirectIntegrator`, it is a direct light integrator with point light assumption, support gradient estimation of geometry with bssrdf material (both primary and secondary discontintuity). The `OldDirectIntegrator` correspond to the `DirectIntegrator` in the original psdr-cuda codebase; and the `ColocateIntegrator` is integrator with the "point light locates at the same place as camera" assumpition. To validate the implementation of BSSRDF we used the `LaserIntegrator`, where a directional coherent light is pointing down to a plane, it is deprecated now. 14 | 15 | 16 | ## Optimizing 17 | #### Synthetic data 18 | To do: adding sythetic examples ... 19 | 20 | #### Real data 21 | 1. The latest optimizing code is in `"examples/python/learn_real_data.py"`. 22 | 23 | 2. To set the `ROOT_DIR`, `SCENE_DIR`, etc... go to `"examples/python/constants.py"`. 24 | 25 | 3. To optimize homogeneous value of `alebdo` and `sigma_t`, set `args.sigma_texture = 0`. 26 | 27 | 4. To optimize `albedo` and `sigma_t` as texture, set `args.sigma_texture = 512` and `args.albedo_texture = 512`. 28 | 29 | 30 | ## Data Folder 31 | Find real data here [Soap and Kiwi](https://drive.google.com/drive/folders/1JrTtno7c-FnYuNJ044FKbjlZYujJiczN?usp=sharing). 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /cmake_install.cmake: -------------------------------------------------------------------------------- 1 | # Install script for directory: /home/xd/Research/psdr-cuda 2 | 3 | # Set the install prefix 4 | if(NOT DEFINED CMAKE_INSTALL_PREFIX) 5 | set(CMAKE_INSTALL_PREFIX "/usr/local") 6 | endif() 7 | string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 8 | 9 | # Set the install configuration name. 10 | if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) 11 | if(BUILD_TYPE) 12 | string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" 13 | CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") 14 | else() 15 | set(CMAKE_INSTALL_CONFIG_NAME "Debug") 16 | endif() 17 | message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") 18 | endif() 19 | 20 | # Set the component getting installed. 21 | if(NOT CMAKE_INSTALL_COMPONENT) 22 | if(COMPONENT) 23 | message(STATUS "Install component: \"${COMPONENT}\"") 24 | set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") 25 | else() 26 | set(CMAKE_INSTALL_COMPONENT) 27 | endif() 28 | endif() 29 | 30 | # Install shared libraries without execute permission? 31 | if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) 32 | set(CMAKE_INSTALL_SO_NO_EXE "1") 33 | endif() 34 | 35 | # Is this installation the result of a crosscompile? 36 | if(NOT DEFINED CMAKE_CROSSCOMPILING) 37 | set(CMAKE_CROSSCOMPILING "FALSE") 38 | endif() 39 | 40 | # Set default install directory permissions. 41 | if(NOT DEFINED CMAKE_OBJDUMP) 42 | set(CMAKE_OBJDUMP "/usr/bin/objdump") 43 | endif() 44 | 45 | if(CMAKE_INSTALL_COMPONENT) 46 | set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") 47 | else() 48 | set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") 49 | endif() 50 | 51 | string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT 52 | "${CMAKE_INSTALL_MANIFEST_FILES}") 53 | file(WRITE "/home/xd/Research/psdr-cuda/${CMAKE_INSTALL_MANIFEST}" 54 | "${CMAKE_INSTALL_MANIFEST_CONTENT}") 55 | -------------------------------------------------------------------------------- /cuda/psdr_cuda.cpp: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | return 0; 4 | } -------------------------------------------------------------------------------- /cuda/psdr_cuda.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct Params 4 | { 5 | const float *ray_o_x, *ray_o_y, *ray_o_z; 6 | const float *ray_d_x, *ray_d_y, *ray_d_z; 7 | const float *ray_tmax; 8 | 9 | int *tri_index; 10 | int *shape_index; 11 | float *barycentric_u, *barycentric_v; 12 | 13 | /* xi deng added for bssrdf intersections */ 14 | int *mul_tri_index; 15 | int *mul_shape_index; 16 | float *mul_barycentric_u, *mul_barycentric_v; 17 | 18 | //float *mul_layer_index; 19 | int *num_its; 20 | 21 | /* xi deng added for bssrdf intersections */ 22 | /* render mode 0, return closest intersection */ 23 | /* render mode 1, bssrdf point sample, return all intersections */ 24 | /* TODO: render mode 2, multilayer bssrdf, return intersections with all layers */ 25 | int rendermode; 26 | 27 | int renderdepth; 28 | const float *rnd; 29 | uint32_t maxRange; 30 | 31 | 32 | OptixTraversableHandle handle; 33 | }; 34 | 35 | struct RayGenData 36 | { 37 | 38 | }; 39 | 40 | struct MissData 41 | { 42 | 43 | }; 44 | 45 | struct HitGroupData 46 | { 47 | int shape_offset; 48 | int shape_id; 49 | float *vertex; 50 | int *index; 51 | int layer_id; 52 | }; 53 | 54 | typedef struct SurfacePos 55 | { 56 | float p_x, p_y, p_z; 57 | float t_max; 58 | int depth; 59 | int layer_id; 60 | } SurfacePos; 61 | -------------------------------------------------------------------------------- /data/hdrdragon/mask/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrdragon/mask/.DS_Store -------------------------------------------------------------------------------- /data/hdrdragon/rawimages/GantryStateLog.txt: -------------------------------------------------------------------------------- 1 | ml=0 mc=45 mb=0 mo=0 basename=dragon_00000 2 | ml=45 mc=45 mb=0 mo=0 basename=dragon_00001 3 | ml=90 mc=45 mb=0 mo=0 basename=dragon_00002 4 | ml=90 mc=45 mb=0 mo=45 basename=dragon_00003 5 | ml=90 mc=45 mb=0 mo=90 basename=dragon_00004 6 | ml=90 mc=-45 mb=0 mo=0 basename=dragon_00005 7 | ml=90 mc=-45 mb=0 mo=90 basename=dragon_00006 8 | ml=90 mc=-45 mb=0 mo=135 basename=dragon_00007 9 | ml=90 mc=-45 mb=0 mo=180 basename=dragon_00008 10 | ml=90 mc=-45 mb=0 mo=225 basename=dragon_00009 11 | ml=90 mc=-45 mb=0 mo=270 basename=dragon_00010 12 | ml=90 mc=-45 mb=0 mo=315 basename=dragon_00011 13 | ml=55 mc=-45 mb=0 mo=315 basename=dragon_00012 14 | ml=55 mc=-45 mb=0 mo=270 basename=dragon_00013 15 | ml=55 mc=-45 mb=0 mo=225 basename=dragon_00014 16 | ml=55 mc=-45 mb=0 mo=180 basename=dragon_00015 17 | ml=55 mc=-45 mb=0 mo=135 basename=dragon_00016 18 | ml=55 mc=-45 mb=0 mo=90 basename=dragon_00017 19 | ml=55 mc=-45 mb=0 mo=0 basename=dragon_00018 20 | ml=90 mc=-45 mb=90 mo=0 basename=dragon_00019 21 | ml=90 mc=-45 mb=90 mo=90 basename=dragon_00020 22 | ml=90 mc=-45 mb=90 mo=135 basename=dragon_00021 23 | ml=90 mc=-45 mb=90 mo=180 basename=dragon_00022 24 | ml=90 mc=-45 mb=90 mo=225 basename=dragon_00023 25 | ml=90 mc=-45 mb=90 mo=270 basename=dragon_00024 26 | ml=90 mc=-45 mb=90 mo=315 basename=dragon_00025 27 | ml=55 mc=-45 mb=90 mo=315 basename=dragon_00026 28 | ml=55 mc=-45 mb=90 mo=270 basename=dragon_00027 29 | ml=55 mc=-45 mb=90 mo=225 basename=dragon_00028 30 | ml=55 mc=-45 mb=90 mo=180 basename=dragon_00029 31 | ml=55 mc=-45 mb=90 mo=135 basename=dragon_00030 32 | ml=55 mc=-45 mb=90 mo=90 basename=dragon_00031 33 | ml=55 mc=-45 mb=90 mo=0 basename=dragon_00032 34 | ml=90 mc=-95 mb=60 mo=0 basename=dragon_00033 35 | ml=90 mc=-95 mb=60 mo=90 basename=dragon_00034 36 | ml=90 mc=-95 mb=60 mo=135 basename=dragon_00035 37 | ml=90 mc=-95 mb=60 mo=180 basename=dragon_00036 38 | ml=90 mc=-95 mb=60 mo=225 basename=dragon_00037 39 | ml=90 mc=-95 mb=60 mo=270 basename=dragon_00038 40 | ml=90 mc=-95 mb=60 mo=315 basename=dragon_00039 41 | ml=55 mc=-95 mb=60 mo=315 basename=dragon_00040 42 | ml=55 mc=-95 mb=60 mo=270 basename=dragon_00041 43 | ml=55 mc=-95 mb=60 mo=225 basename=dragon_00042 44 | ml=55 mc=-95 mb=60 mo=180 basename=dragon_00043 45 | ml=55 mc=-95 mb=60 mo=135 basename=dragon_00044 46 | ml=55 mc=-95 mb=60 mo=90 basename=dragon_00045 47 | ml=55 mc=-95 mb=60 mo=0 basename=dragon_00046 48 | ml=20 mc=-90 mb=60 mo=0 basename=dragon_00047 49 | ml=20 mc=-45 mb=60 mo=0 basename=dragon_00048 50 | ml=20 mc=0 mb=60 mo=0 basename=dragon_00049 51 | ml=20 mc=45 mb=60 mo=0 basename=dragon_00050 52 | ml=20 mc=90 mb=60 mo=0 basename=dragon_00051 53 | -------------------------------------------------------------------------------- /data/hdrkiwi/alpha_mask.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/alpha_mask.zip -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/mvs/fused.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format binary_little_endian 1.0 3 | element vertex 0 4 | property float x 5 | property float y 6 | property float z 7 | property float nx 8 | property float ny 9 | property float nz 10 | property uchar red 11 | property uchar green 12 | property uchar blue 13 | end_header 14 | -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/mvs/fused.ply.vis: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/mvs/meshed_trim_3.ply: -------------------------------------------------------------------------------- 1 | ply 2 | format binary_little_endian 1.0 3 | comment Running Screened Poisson Reconstruction (Version 8.0) 4 | comment --in /home/dx/Research/psdr-cuda/realdata/hdrKiwi/colmap_unposed/mvs/fused.ply 5 | comment --depth 13 6 | comment --out /home/dx/Research/psdr-cuda/realdata/hdrKiwi/colmap_unposed/mvs/meshed_trim_3.ply 7 | comment --pointWeight 1.000000 8 | comment --density 9 | comment --color 32.000000 10 | comment # Tree set in: 0.1 (s), 131.2 (MB) 11 | comment # Constraints set in: 0.0 (s), 388.1 (MB) 12 | comment # Linear system solved in: 1.5 (s), 839.1 (MB) 13 | comment # Got triangles in: 0.2 (s), 840.9 (MB) 14 | comment # Total Solve: 1.8 (s), 840.9 (MB) 15 | element vertex 0 16 | property float x 17 | property float y 18 | property float z 19 | property float value 20 | property uchar red 21 | property uchar green 22 | property uchar blue 23 | element face 0 24 | property list uchar int vertex_indices 25 | end_header 26 | -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/mvs/run-colmap-geometric.sh: -------------------------------------------------------------------------------- 1 | # You must set $COLMAP_EXE_PATH to 2 | # the directory containing the COLMAP executables. 3 | $COLMAP_EXE_PATH/patch_match_stereo \ 4 | --workspace_path . \ 5 | --workspace_format COLMAP \ 6 | --PatchMatchStereo.max_image_size 2000 \ 7 | --PatchMatchStereo.geom_consistency true 8 | $COLMAP_EXE_PATH/stereo_fusion \ 9 | --workspace_path . \ 10 | --workspace_format COLMAP \ 11 | --input_type geometric \ 12 | --output_path ./fused.ply 13 | $COLMAP_EXE_PATH/poisson_mesher \ 14 | --input_path ./fused.ply \ 15 | --output_path ./meshed-poisson.ply 16 | $COLMAP_EXE_PATH/delaunay_mesher \ 17 | --input_path . \ 18 | --input_type dense 19 | --output_path ./meshed-delaunay.ply 20 | -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/mvs/run-colmap-photometric.sh: -------------------------------------------------------------------------------- 1 | # You must set $COLMAP_EXE_PATH to 2 | # the directory containing the COLMAP executables. 3 | $COLMAP_EXE_PATH/patch_match_stereo \ 4 | --workspace_path . \ 5 | --workspace_format COLMAP \ 6 | --PatchMatchStereo.max_image_size 2000 \ 7 | --PatchMatchStereo.geom_consistency false 8 | $COLMAP_EXE_PATH/stereo_fusion \ 9 | --workspace_path . \ 10 | --workspace_format COLMAP \ 11 | --input_type photometric \ 12 | --output_path ./fused.ply 13 | $COLMAP_EXE_PATH/poisson_mesher \ 14 | --input_path ./fused.ply \ 15 | --output_path ./meshed-poisson.ply 16 | $COLMAP_EXE_PATH/delaunay_mesher \ 17 | --input_path . \ 18 | --input_type dense 19 | --output_path ./meshed-delaunay.ply 20 | -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/mvs/sparse/cameras.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/colmap_unposed/mvs/sparse/cameras.bin -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/mvs/sparse/images.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/colmap_unposed/mvs/sparse/images.bin -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/mvs/sparse/points3D.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/colmap_unposed/mvs/sparse/points3D.bin -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/mvs/stereo/fusion.cfg: -------------------------------------------------------------------------------- 1 | kiwi_0.png 2 | kiwi_15.png 3 | kiwi_18.png 4 | kiwi_12.png 5 | kiwi_26.png 6 | kiwi_32.png 7 | kiwi_47.png 8 | kiwi_50.png 9 | kiwi_48.png 10 | kiwi_49.png 11 | -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/mvs/stereo/patch-match.cfg: -------------------------------------------------------------------------------- 1 | kiwi_0.png 2 | __auto__, 20 3 | kiwi_15.png 4 | __auto__, 20 5 | kiwi_18.png 6 | __auto__, 20 7 | kiwi_12.png 8 | __auto__, 20 9 | kiwi_26.png 10 | __auto__, 20 11 | kiwi_32.png 12 | __auto__, 20 13 | kiwi_47.png 14 | __auto__, 20 15 | kiwi_50.png 16 | __auto__, 20 17 | kiwi_48.png 18 | __auto__, 20 19 | kiwi_49.png 20 | __auto__, 20 21 | -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/sfm/database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/colmap_unposed/sfm/database.db -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/sfm/images: -------------------------------------------------------------------------------- 1 | /home/dx/Research/psdr-cuda/realdata/hdrKiwi/images -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/sfm/sparse/0/cameras.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/colmap_unposed/sfm/sparse/0/cameras.bin -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/sfm/sparse/0/images.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/colmap_unposed/sfm/sparse/0/images.bin -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/sfm/sparse/0/points3D.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/colmap_unposed/sfm/sparse/0/points3D.bin -------------------------------------------------------------------------------- /data/hdrkiwi/colmap_unposed/sfm/sparse/0/project.ini: -------------------------------------------------------------------------------- 1 | database_path=/home/dx/Research/psdr-cuda/realdata/hdrKiwi/colmap_unposed/sfm/database.db 2 | image_path=/home/dx/Research/psdr-cuda/realdata/hdrKiwi/images 3 | [Mapper] 4 | ignore_watermarks=false 5 | multiple_models=true 6 | extract_colors=true 7 | ba_refine_focal_length=true 8 | ba_refine_principal_point=false 9 | ba_refine_extra_params=true 10 | ba_global_use_pba=true 11 | fix_existing_images=false 12 | tri_ignore_two_view_tracks=true 13 | min_num_matches=15 14 | max_num_models=50 15 | max_model_overlap=20 16 | min_model_size=10 17 | init_image_id1=-1 18 | init_image_id2=-1 19 | init_num_trials=200 20 | num_threads=-1 21 | ba_local_num_images=6 22 | ba_local_max_num_iterations=25 23 | ba_global_pba_gpu_index=-1 24 | ba_global_images_freq=500 25 | ba_global_points_freq=250000 26 | ba_global_max_num_iterations=50 27 | ba_global_max_refinements=5 28 | ba_local_max_refinements=2 29 | snapshot_images_freq=0 30 | init_min_num_inliers=100 31 | init_max_reg_trials=2 32 | abs_pose_min_num_inliers=30 33 | max_reg_trials=3 34 | tri_max_transitivity=1 35 | tri_complete_max_transitivity=5 36 | tri_re_max_trials=1 37 | min_focal_length_ratio=0.10000000000000001 38 | max_focal_length_ratio=10 39 | max_extra_param=1 40 | ba_global_images_ratio=1.1000000000000001 41 | ba_global_points_ratio=1.1000000000000001 42 | ba_global_max_refinement_change=0.00050000000000000001 43 | ba_local_max_refinement_change=0.001 44 | init_max_error=4 45 | init_max_forward_motion=0.94999999999999996 46 | init_min_tri_angle=16 47 | abs_pose_max_error=12 48 | abs_pose_min_inlier_ratio=0.25 49 | filter_max_reproj_error=4 50 | filter_min_tri_angle=1.5 51 | tri_create_max_angle_error=2 52 | tri_continue_max_angle_error=2 53 | tri_merge_max_reproj_error=4 54 | tri_complete_max_reproj_error=4 55 | tri_re_max_angle_error=5 56 | tri_re_min_ratio=0.20000000000000001 57 | tri_min_angle=1.5 58 | snapshot_path= 59 | -------------------------------------------------------------------------------- /data/hdrkiwi/database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/database.db -------------------------------------------------------------------------------- /data/hdrkiwi/exr_ref.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/exr_ref.zip -------------------------------------------------------------------------------- /data/hdrkiwi/images_big/GantryStateLog.txt: -------------------------------------------------------------------------------- 1 | ml=0 mc=45 mb=0 mo=0 basename=kiwi_00000 2 | ml=45 mc=45 mb=0 mo=0 basename=kiwi_00001 3 | ml=90 mc=45 mb=0 mo=0 basename=kiwi_00002 4 | ml=90 mc=45 mb=0 mo=45 basename=kiwi_00003 5 | ml=90 mc=45 mb=0 mo=90 basename=kiwi_00004 6 | ml=90 mc=-45 mb=0 mo=0 basename=kiwi_00005 7 | ml=90 mc=-45 mb=0 mo=90 basename=kiwi_00006 8 | ml=90 mc=-45 mb=0 mo=135 basename=kiwi_00007 9 | ml=90 mc=-45 mb=0 mo=180 basename=kiwi_00008 10 | ml=90 mc=-45 mb=0 mo=225 basename=kiwi_00009 11 | ml=90 mc=-45 mb=0 mo=270 basename=kiwi_00010 12 | ml=90 mc=-45 mb=0 mo=315 basename=kiwi_00011 13 | ml=55 mc=-45 mb=0 mo=315 basename=kiwi_00012 14 | ml=55 mc=-45 mb=0 mo=270 basename=kiwi_00013 15 | ml=55 mc=-45 mb=0 mo=225 basename=kiwi_00014 16 | ml=55 mc=-45 mb=0 mo=180 basename=kiwi_00015 17 | ml=55 mc=-45 mb=0 mo=135 basename=kiwi_00016 18 | ml=55 mc=-45 mb=0 mo=90 basename=kiwi_00017 19 | ml=55 mc=-45 mb=0 mo=0 basename=kiwi_00018 20 | ml=90 mc=-45 mb=90 mo=0 basename=kiwi_00019 21 | ml=90 mc=-45 mb=90 mo=90 basename=kiwi_00020 22 | ml=90 mc=-45 mb=90 mo=135 basename=kiwi_00021 23 | ml=90 mc=-45 mb=90 mo=180 basename=kiwi_00022 24 | ml=90 mc=-45 mb=90 mo=225 basename=kiwi_00023 25 | ml=90 mc=-45 mb=90 mo=270 basename=kiwi_00024 26 | ml=90 mc=-45 mb=90 mo=315 basename=kiwi_00025 27 | ml=55 mc=-45 mb=90 mo=315 basename=kiwi_00026 28 | ml=55 mc=-45 mb=90 mo=270 basename=kiwi_00027 29 | ml=55 mc=-45 mb=90 mo=225 basename=kiwi_00028 30 | ml=55 mc=-45 mb=90 mo=180 basename=kiwi_00029 31 | ml=55 mc=-45 mb=90 mo=135 basename=kiwi_00030 32 | ml=55 mc=-45 mb=90 mo=90 basename=kiwi_00031 33 | ml=55 mc=-45 mb=90 mo=0 basename=kiwi_00032 34 | ml=90 mc=-95 mb=60 mo=0 basename=kiwi_00033 35 | ml=90 mc=-95 mb=60 mo=90 basename=kiwi_00034 36 | ml=90 mc=-95 mb=60 mo=135 basename=kiwi_00035 37 | ml=90 mc=-95 mb=60 mo=180 basename=kiwi_00036 38 | ml=90 mc=-95 mb=60 mo=225 basename=kiwi_00037 39 | ml=90 mc=-95 mb=60 mo=270 basename=kiwi_00038 40 | ml=90 mc=-95 mb=60 mo=315 basename=kiwi_00039 41 | ml=55 mc=-95 mb=60 mo=315 basename=kiwi_00040 42 | ml=55 mc=-95 mb=60 mo=270 basename=kiwi_00041 43 | ml=55 mc=-95 mb=60 mo=225 basename=kiwi_00042 44 | ml=55 mc=-95 mb=60 mo=180 basename=kiwi_00043 45 | ml=55 mc=-95 mb=60 mo=135 basename=kiwi_00044 46 | ml=55 mc=-95 mb=60 mo=90 basename=kiwi_00045 47 | ml=55 mc=-95 mb=60 mo=0 basename=kiwi_00046 48 | ml=20 mc=-90 mb=60 mo=0 basename=kiwi_00047 49 | ml=20 mc=-45 mb=60 mo=0 basename=kiwi_00048 50 | ml=20 mc=0 mb=60 mo=0 basename=kiwi_00049 51 | ml=20 mc=45 mb=60 mo=0 basename=kiwi_00050 52 | ml=20 mc=90 mb=60 mo=0 basename=kiwi_00051 53 | -------------------------------------------------------------------------------- /data/hdrkiwi/mask/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/mask/.DS_Store -------------------------------------------------------------------------------- /data/hdrkiwi/rawimages/GantryStateLog.txt: -------------------------------------------------------------------------------- 1 | ml=0 mc=45 mb=0 mo=0 basename=kiwi_00000 2 | ml=45 mc=45 mb=0 mo=0 basename=kiwi_00001 3 | ml=90 mc=45 mb=0 mo=0 basename=kiwi_00002 4 | ml=90 mc=45 mb=0 mo=45 basename=kiwi_00003 5 | ml=90 mc=45 mb=0 mo=90 basename=kiwi_00004 6 | ml=90 mc=-45 mb=0 mo=0 basename=kiwi_00005 7 | ml=90 mc=-45 mb=0 mo=90 basename=kiwi_00006 8 | ml=90 mc=-45 mb=0 mo=135 basename=kiwi_00007 9 | ml=90 mc=-45 mb=0 mo=180 basename=kiwi_00008 10 | ml=90 mc=-45 mb=0 mo=225 basename=kiwi_00009 11 | ml=90 mc=-45 mb=0 mo=270 basename=kiwi_00010 12 | ml=90 mc=-45 mb=0 mo=315 basename=kiwi_00011 13 | ml=55 mc=-45 mb=0 mo=315 basename=kiwi_00012 14 | ml=55 mc=-45 mb=0 mo=270 basename=kiwi_00013 15 | ml=55 mc=-45 mb=0 mo=225 basename=kiwi_00014 16 | ml=55 mc=-45 mb=0 mo=180 basename=kiwi_00015 17 | ml=55 mc=-45 mb=0 mo=135 basename=kiwi_00016 18 | ml=55 mc=-45 mb=0 mo=90 basename=kiwi_00017 19 | ml=55 mc=-45 mb=0 mo=0 basename=kiwi_00018 20 | ml=90 mc=-45 mb=90 mo=0 basename=kiwi_00019 21 | ml=90 mc=-45 mb=90 mo=90 basename=kiwi_00020 22 | ml=90 mc=-45 mb=90 mo=135 basename=kiwi_00021 23 | ml=90 mc=-45 mb=90 mo=180 basename=kiwi_00022 24 | ml=90 mc=-45 mb=90 mo=225 basename=kiwi_00023 25 | ml=90 mc=-45 mb=90 mo=270 basename=kiwi_00024 26 | ml=90 mc=-45 mb=90 mo=315 basename=kiwi_00025 27 | ml=55 mc=-45 mb=90 mo=315 basename=kiwi_00026 28 | ml=55 mc=-45 mb=90 mo=270 basename=kiwi_00027 29 | ml=55 mc=-45 mb=90 mo=225 basename=kiwi_00028 30 | ml=55 mc=-45 mb=90 mo=180 basename=kiwi_00029 31 | ml=55 mc=-45 mb=90 mo=135 basename=kiwi_00030 32 | ml=55 mc=-45 mb=90 mo=90 basename=kiwi_00031 33 | ml=55 mc=-45 mb=90 mo=0 basename=kiwi_00032 34 | ml=90 mc=-95 mb=60 mo=0 basename=kiwi_00033 35 | ml=90 mc=-95 mb=60 mo=90 basename=kiwi_00034 36 | ml=90 mc=-95 mb=60 mo=135 basename=kiwi_00035 37 | ml=90 mc=-95 mb=60 mo=180 basename=kiwi_00036 38 | ml=90 mc=-95 mb=60 mo=225 basename=kiwi_00037 39 | ml=90 mc=-95 mb=60 mo=270 basename=kiwi_00038 40 | ml=90 mc=-95 mb=60 mo=315 basename=kiwi_00039 41 | ml=55 mc=-95 mb=60 mo=315 basename=kiwi_00040 42 | ml=55 mc=-95 mb=60 mo=270 basename=kiwi_00041 43 | ml=55 mc=-95 mb=60 mo=225 basename=kiwi_00042 44 | ml=55 mc=-95 mb=60 mo=180 basename=kiwi_00043 45 | ml=55 mc=-95 mb=60 mo=135 basename=kiwi_00044 46 | ml=55 mc=-95 mb=60 mo=90 basename=kiwi_00045 47 | ml=55 mc=-95 mb=60 mo=0 basename=kiwi_00046 48 | ml=20 mc=-90 mb=60 mo=0 basename=kiwi_00047 49 | ml=20 mc=-45 mb=60 mo=0 basename=kiwi_00048 50 | ml=20 mc=0 mb=60 mo=0 basename=kiwi_00049 51 | ml=20 mc=45 mb=60 mo=0 basename=kiwi_00050 52 | ml=20 mc=90 mb=60 mo=0 basename=kiwi_00051 53 | -------------------------------------------------------------------------------- /data/hdrkiwi/sparse/0/cameras.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/sparse/0/cameras.bin -------------------------------------------------------------------------------- /data/hdrkiwi/sparse/0/images.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/sparse/0/images.bin -------------------------------------------------------------------------------- /data/hdrkiwi/sparse/0/points3D.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrkiwi/sparse/0/points3D.bin -------------------------------------------------------------------------------- /data/hdrsoap/colmap_unposed/sfm/database.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/data/hdrsoap/colmap_unposed/sfm/database.db -------------------------------------------------------------------------------- /data/hdrsoap/colmap_unposed/sfm/images: -------------------------------------------------------------------------------- 1 | /home/dx/Research/psdr-cuda/realdata/hdrSoap/images -------------------------------------------------------------------------------- /data/hdrsoap/exr_images/GantryStateLog.txt: -------------------------------------------------------------------------------- 1 | ml=0 mc=45 mb=0 mo=0 basename=soap_00000 2 | ml=45 mc=45 mb=0 mo=0 basename=soap_00001 3 | ml=90 mc=45 mb=0 mo=0 basename=soap_00002 4 | ml=90 mc=45 mb=0 mo=45 basename=soap_00003 5 | ml=90 mc=45 mb=0 mo=90 basename=soap_00004 6 | ml=90 mc=-45 mb=0 mo=0 basename=soap_00005 7 | ml=90 mc=-45 mb=0 mo=90 basename=soap_00006 8 | ml=90 mc=-45 mb=0 mo=135 basename=soap_00007 9 | ml=90 mc=-45 mb=0 mo=180 basename=soap_00008 10 | ml=90 mc=-45 mb=0 mo=225 basename=soap_00009 11 | ml=90 mc=-45 mb=0 mo=270 basename=soap_00010 12 | ml=90 mc=-45 mb=0 mo=315 basename=soap_00011 13 | ml=55 mc=-45 mb=0 mo=315 basename=soap_00012 14 | ml=55 mc=-45 mb=0 mo=270 basename=soap_00013 15 | ml=55 mc=-45 mb=0 mo=225 basename=soap_00014 16 | ml=55 mc=-45 mb=0 mo=180 basename=soap_00015 17 | ml=55 mc=-45 mb=0 mo=135 basename=soap_00016 18 | ml=55 mc=-45 mb=0 mo=90 basename=soap_00017 19 | ml=55 mc=-45 mb=0 mo=0 basename=soap_00018 20 | ml=90 mc=-45 mb=90 mo=0 basename=soap_00019 21 | ml=90 mc=-45 mb=90 mo=90 basename=soap_00020 22 | ml=90 mc=-45 mb=90 mo=135 basename=soap_00021 23 | ml=90 mc=-45 mb=90 mo=180 basename=soap_00022 24 | ml=90 mc=-45 mb=90 mo=225 basename=soap_00023 25 | ml=90 mc=-45 mb=90 mo=270 basename=soap_00024 26 | ml=90 mc=-45 mb=90 mo=315 basename=soap_00025 27 | ml=55 mc=-45 mb=90 mo=315 basename=soap_00026 28 | ml=55 mc=-45 mb=90 mo=270 basename=soap_00027 29 | ml=55 mc=-45 mb=90 mo=225 basename=soap_00028 30 | ml=55 mc=-45 mb=90 mo=180 basename=soap_00029 31 | ml=55 mc=-45 mb=90 mo=135 basename=soap_00030 32 | ml=55 mc=-45 mb=90 mo=90 basename=soap_00031 33 | ml=55 mc=-45 mb=90 mo=0 basename=soap_00032 34 | ml=90 mc=-95 mb=60 mo=0 basename=soap_00033 35 | ml=90 mc=-95 mb=60 mo=90 basename=soap_00034 36 | ml=90 mc=-95 mb=60 mo=135 basename=soap_00035 37 | ml=90 mc=-95 mb=60 mo=180 basename=soap_00036 38 | ml=90 mc=-95 mb=60 mo=225 basename=soap_00037 39 | ml=90 mc=-95 mb=60 mo=270 basename=soap_00038 40 | ml=90 mc=-95 mb=60 mo=315 basename=soap_00039 41 | ml=55 mc=-95 mb=60 mo=315 basename=soap_00040 42 | ml=55 mc=-95 mb=60 mo=270 basename=soap_00041 43 | ml=55 mc=-95 mb=60 mo=225 basename=soap_00042 44 | ml=55 mc=-95 mb=60 mo=180 basename=soap_00043 45 | ml=55 mc=-95 mb=60 mo=135 basename=soap_00044 46 | ml=55 mc=-95 mb=60 mo=90 basename=soap_00045 47 | ml=55 mc=-95 mb=60 mo=0 basename=soap_00046 48 | ml=20 mc=-90 mb=60 mo=0 basename=soap_00047 49 | ml=20 mc=-45 mb=60 mo=0 basename=soap_00048 50 | ml=20 mc=0 mb=60 mo=0 basename=soap_00049 51 | ml=20 mc=45 mb=60 mo=0 basename=soap_00050 52 | ml=20 mc=90 mb=60 mo=0 basename=soap_00051 53 | -------------------------------------------------------------------------------- /docs/_static/theme_overrides.css: -------------------------------------------------------------------------------- 1 | table.docutils td, table.docutils th { 2 | padding:.5em; 3 | } 4 | 5 | table.docutils th { 6 | vertical-align:middle; 7 | } 8 | 9 | .toggle .header { 10 | display: block; 11 | clear: both; 12 | padding-bottom: 1em; 13 | } 14 | 15 | .toggle .header:after { 16 | content: " ▼"; 17 | } 18 | 19 | .toggle .header.open:after { 20 | content: " ▲"; 21 | } 22 | 23 | .MathJax .mo { color: inherit } 24 | .MathJax .mi { color: inherit } 25 | 26 | div.sphinxsidebar h4 { 27 | font-family: "Open Sans", Helvetica, Arial, sans-serif; 28 | font-size: 14px; 29 | font-weight: bold; 30 | text-transform: uppercase; 31 | color: #606060; 32 | } 33 | 34 | div.sphinxsidebar { 35 | margin: 1em; 36 | } 37 | 38 | div.sidebar-wrapper { 39 | padding:0px; 40 | } 41 | -------------------------------------------------------------------------------- /docs/_templates/page.html: -------------------------------------------------------------------------------- 1 | 2 | {% extends "!page.html" %} 3 | 4 | {% block footer %} 5 | 15 | {% endblock %} 16 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import shlex 4 | import subprocess 5 | 6 | templates_path = ['_templates'] 7 | 8 | source_suffix = '.rst' 9 | 10 | master_doc = 'index' 11 | 12 | project = 'psdr-cuda' 13 | author = 'Kai Yan' 14 | 15 | version = '0.1.0' 16 | release = '0.1.0' 17 | 18 | language = None 19 | 20 | exclude_patterns = ['.build', 'release.rst'] 21 | 22 | default_role = 'any' 23 | 24 | todo_include_todos = False 25 | 26 | import guzzle_sphinx_theme 27 | 28 | html_theme_path = guzzle_sphinx_theme.html_theme_path() 29 | html_theme = 'guzzle_sphinx_theme' 30 | html_static_path = ['_static'] 31 | 32 | extensions = [] 33 | extensions.append("guzzle_sphinx_theme") 34 | extensions.append("sphinx.ext.mathjax") 35 | 36 | html_theme_options = { 37 | "project_nav_name": "PSDR-CUDA" 38 | } 39 | 40 | html_sidebars = { 41 | '**': ['logo-text.html', 'globaltoc.html', 'searchbox.html'] 42 | } 43 | 44 | def setup(app): 45 | app.add_css_file('theme_overrides.css') 46 | 47 | html_logo = None 48 | 49 | html_static_path = ['_static'] 50 | 51 | html_show_sourcelink = False 52 | 53 | htmlhelp_basename = 'enokidoc' 54 | 55 | latex_elements = { 56 | 'preamble': '\\DeclareUnicodeCharacter{00A0}{}', 57 | } 58 | 59 | latex_documents = [ 60 | (master_doc, 'psdr.tex', 'psdr Documentation', 61 | 'Kai Yan', 'manual'), 62 | ] 63 | 64 | man_pages = [ 65 | (master_doc, 'psdr', 'psdr Documentation', 66 | [author], 1) 67 | ] 68 | 69 | texinfo_documents = [ 70 | (master_doc, 'psdr', 'psdr Documentation', 71 | author, 'psdr', 'One line description of project.', 72 | 'Miscellaneous'), 73 | ] 74 | 75 | primary_domain = 'cpp' 76 | highlight_language = 'cpp' 77 | -------------------------------------------------------------------------------- /docs/core_compile.rst: -------------------------------------------------------------------------------- 1 | Compiling the system 2 | ========================= 3 | 4 | Compiling PSDR-CUDA from scratch requires recent versions of CMake (at least 3.8.8), Python (at least 3.6), CUDA (at least 10.1), OptiX (at least 7.0), as well as a C++ compiler that supports the C++17 standard. 5 | 6 | 7 | Linux 8 | -------------------- 9 | 10 | The build process under Linux requires several external dependencies that are easily installed using the system-provided package manager (e.g., ``apt-get`` under Ubuntu). 11 | 12 | To fetch all dependencies, enter the following commands on Ubuntu: 13 | 14 | .. code-block:: bash 15 | 16 | # Install OpenEXR for image I/O 17 | sudo apt install libopenexr-dev 18 | 19 | # Install required Python packages 20 | sudo apt install python3-dev python3-distutils python3-setuptools 21 | 22 | Additionally, the Enoki and pybind11 libraries are needed. To make pybind11 globally accessible, we recommend running ``sudo make install`` to copy all its header files to ``/usr/local/include/pybind11/``. 23 | 24 | Lastly, a softlink to Nvidia OptiX needs to be created at ``ext/optix``. For example, if OptiX is installed under ``/home/user/NVIDIA-OptiX-SDK-7.1.0-linux64``, this can be done by running the following commands from inside PSDR-CUDA's root directory: 25 | 26 | .. code-block:: bash 27 | 28 | mkdir -p ext 29 | ln -s /home/user/NVIDIA-OptiX-SDK-7.1.0-linux64 ext/optix 30 | 31 | With all dependencies installed/compiled, building PSDR-CUDA requires defining a few Cmake variables including ``PYTHON_INCLUDE_PATH``, ``OpenEXR_ROOT``, and ``ENOKI_DIR``. Assuming the Enoki library is cloned to ``/home/user/enoki`` and built under ``/home/user/enoki/build``, this can be done by running the following commands from inside PSDR-CUDA's root directory: 32 | 33 | .. code-block:: bash 34 | 35 | # Create a directory where build products are stored 36 | mkdir build 37 | cd build 38 | cmake -D CMAKE_C_COMPILER=gcc-9 \ 39 | -D CMAKE_CXX_COMPILER=g++-9 \ 40 | -D PYTHON_INCLUDE_PATH=/usr/include/python3.8/ \ 41 | -D OpenEXR_ROOT=/usr/include/OpenEXR/ \ 42 | -D ENOKI_DIR=/home/user/enoki/ \ 43 | .. 44 | make -j 45 | 46 | Tested version 47 | ^^^^^^^^^^^^^^ 48 | * Ubuntu 20.04 49 | * gcc 9.3.0 50 | 51 | 52 | Windows 53 | -------------------- 54 | 55 | To make the compilation under Windows more streamlined, we created a `package `_ containing precompiled binaries of most of the dependencies. Utilizing this package requires having Visual Studio 2019, CUDA 11, and Python 3.8. 56 | 57 | After decompressing this package to ``ext_win64`` under PSDR-CUDA's root directory, assuming Python to be installed under ``C:/Users/User/Anaconda3``, PSDR-CUDA can be built by running the following commands under the command prompt: 58 | 59 | .. code-block:: batch 60 | 61 | rem Create a directory where build products are stored 62 | mkdir build 63 | cd build 64 | cmake -D PYTHON_ROOT="C:/Users/User/Anaconda3" -G "Visual Studio 16 2019" -A x64 .. 65 | cmake --build . --config Release 66 | copy /y lib\Release\*.pyd lib\ 67 | 68 | Tested version 69 | ^^^^^^^^^^^^^^ 70 | * Windows 10 71 | * Visual Studio 2019 (Community Edition) 72 | * Python 3.8.3 (Anaconda) 73 | * CUDA 11 74 | * OptiX 7.1 75 | 76 | 77 | Mac OS 78 | -------------------- 79 | 80 | Unfortunately, PSDR-CUDA does not work under the Mac OS due to the lack of CUDA support. 81 | -------------------------------------------------------------------------------- /docs/core_intro.rst: -------------------------------------------------------------------------------- 1 | Getting started 2 | ==================== 3 | 4 | PSDR-CUDA is a physics-based differenetiable renderer written in C++17/CUDA and based on the theoretical framework introduced in the paper titled "`Path-Space Differentiable Rendering `_". 5 | 6 | PSDR-CUDA is light-weight (compared to other modern renderers like `Mitsuba 2 `_) yet powerful, offering the following features: 7 | 8 | \1. **Fast GPU-based ray tracing:** PSDR-CUDA uses `OptiX 7.1 `_ that leverages RTX ray tracing on modern Nvidia graphics hardware. 9 | 10 | \2. **Vectorized computation:** PSDR-CUDA uses `Enoki `_, the numerical foundation of `Mitsuba 2 `_, to perform vectorized computations (including reverse-mode automatic differentiation) on the GPU using `CUDA 11 `_. 11 | 12 | \3. **Fast and unbiased gradients:** PSDR-CUDA implements state-of-the-art algorithms that produce unbiased gradient estimates with respect to *arbitrary* scene parameters (e.g., spatially varying reflectance and object geometry). 13 | 14 | \4. **Python bindings:** PSDR-CUDA provides fine-grained Python bindings using `pybind11 `_ and can be easily integrated into Python-based interference and learning pipelines. 15 | 16 | 17 | About 18 | -------------------- 19 | 20 | This project was created by `Shuang Zhao `_. 21 | Significant features and/or improvements to the code were contributed by Kai Yan. 22 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | Path-Space Differentiable Renderer 2 | ============================================= 3 | 4 | .. only:: not latex 5 | 6 | .. image:: teaser.png 7 | :width: 800px 8 | :align: center 9 | 10 | .. toctree:: 11 | :maxdepth: 1 12 | :caption: Core features 13 | 14 | core_intro 15 | core_compile 16 | → GitHub 17 | 18 | .. toctree:: 19 | :maxdepth: 1 20 | :caption: Python interface 21 | 22 | python_intro 23 | python_render 24 | 25 | .. toctree:: 26 | :maxdepth: 1 27 | :caption: Inverse rendering 28 | 29 | inverse_intro 30 | inverse_diff_render 31 | 32 | .. toctree:: 33 | :maxdepth: 1 34 | :caption: Plugin references 35 | 36 | plugin_refs 37 | -------------------------------------------------------------------------------- /docs/inverse_diff_render.rst: -------------------------------------------------------------------------------- 1 | .. _Inverse diff render: 2 | 3 | Differentiable rendering 4 | ========================= 5 | 6 | How to use PSDR-CUDA for forward rendering has been shown in the :ref:`previous section `. 7 | In what follows, we focus on performing *differentiable rendering*. 8 | 9 | Similar to the forward-rendering case, after being loaded and configured, a scene can be rendered in a differentiable fashion by calling an integrator's ``renderD()`` method. The return value of this method is an Enoki CUDA array of the type ``enoki.cuda_autodiff.Vector3f``. 10 | 11 | 12 | Generating derivative image 13 | --------------------------------------- 14 | 15 | The following example generates a derivative image ``image_deriv`` with respect to the rotation angle ``P`` of the first mesh about the Z-axis. 16 | 17 | .. code-block:: python3 18 | 19 | import enoki as ek 20 | from enoki.cuda_autodiff import Float32 as FloatD, Vector3f as Vector3fD, Matrix4f as Matrix4fD 21 | import psdr_cuda 22 | 23 | # Load the scene without configuring it 24 | scene = psdr_cuda.Scene() 25 | scene.load_file('scene.xml', auto_configure=False) 26 | 27 | # Initialize a parameter P for differentiation 28 | P = FloatD(0.) 29 | ek.set_requires_gradient(P) 30 | 31 | # Construct a rotation matrix 32 | mat = Matrix4fD.rotate(Vector3fD(0., 0., 1.), P) 33 | 34 | # Left-multiply this matrix to the to-world transformation of the first mesh of the scene 35 | scene.param_map["Mesh[0]"].append_transform(mat) 36 | 37 | # Configure the scene 38 | scene.configure() 39 | 40 | # Start rendering! 41 | image = psdr_cuda.DirectIntegrator().renderD(scene, sensor_id=0) 42 | 43 | # Compute derivative image with respect to P using forward-mode autodiff 44 | ek.forward(P) 45 | image_deriv = ek.gradient(image) 46 | 47 | 48 | Differentiating image loss 49 | --------------------------------------- 50 | 51 | What follows is another example that computes the gradient of the image RMSE ``loss``, given a target image ``target_image``, with respect to all vertex positions of ``Mesh[0]``. The resulting ``grad`` can then be used in gradient-based optimization pipelines to minimize ``loss``. 52 | 53 | .. code-block:: python3 54 | 55 | import enoki as ek 56 | from enoki.cuda_autodiff import Float32 as FloatD, Vector3f as Vector3fD, Matrix4f as Matrix4fD 57 | import psdr_cuda 58 | 59 | # Load the scene without configuring it 60 | scene = psdr_cuda.Scene() 61 | scene.load_file('scene.xml', auto_configure=False) 62 | 63 | # Compute gradient with respect to mesh vertex positions 64 | ek.set_requires_gradient(scene.param_map["Mesh[0]"].vertex_positions) 65 | 66 | # Configure the scene 67 | scene.configure() 68 | 69 | # Start rendering! 70 | image = psdr_cuda.DirectIntegrator().renderD(scene, sensor_id=0) 71 | 72 | # Compute the RMSE image loss 73 | loss = ek.sqrt(ek.hmean(ek.squared_norm(target_image - image))) 74 | 75 | # Reverse-mode autodiff 76 | ek.backward(loss) 77 | 78 | # Obtain the gradient of the loss 79 | grad = ek.gradient(scene.param_map["Mesh[0]"].vertex_positions) 80 | -------------------------------------------------------------------------------- /docs/inverse_intro.rst: -------------------------------------------------------------------------------- 1 | .. _Inverse intro: 2 | 3 | Introduction 4 | ==================== 5 | 6 | We have showed how to perform forward rendering using PSDR-CUDA in the :ref:`previous section `. 7 | This section focuses on the use of PSDR-CUDA's Python bindings for *differentiable* and *inverse* rendering applications. 8 | 9 | 10 | Automatic-differentiation types 11 | ----------------------------------- 12 | 13 | A key ingredient to differentiable rendering is automatic differentiation. PSDR-CUDA relies on Enoki's to perform transparent reverse-mode automatic differentiation. To this end, commonly used data types include ``Float32``, ``Vector3f``, and ``Matrix4f`` from ``enoki.cuda_autodiff``, which can be imported as follows: 14 | 15 | .. code-block:: python3 16 | 17 | from enoki.cuda_autodiff import Float32 as FloatD, Vector3f as Vector3fD, Matrix4f as Matrix4fD 18 | 19 | For more details on how Enoki's automatic differentiation works, please refer to its `official documentation `_. 20 | -------------------------------------------------------------------------------- /docs/plugin_refs.rst: -------------------------------------------------------------------------------- 1 | Plugin references 2 | ========================= 3 | 4 | TBD. 5 | -------------------------------------------------------------------------------- /docs/python_intro.rst: -------------------------------------------------------------------------------- 1 | .. _Python intro: 2 | 3 | Introduction 4 | ==================== 5 | 6 | Although the core functionalities of PSDR-CUDA are written in C++17 and CUDA, to enable easy integration into Python-based inference and learning pipelines, running PSDR-CUDA requires using its Python bindings. 7 | 8 | This section focuses on the use of the bindings for *forward* rendering. 9 | We will show how to perform differentiable and inverse rendering in the :ref:`next section `. 10 | 11 | 12 | Importing the renderer 13 | ------------------------------ 14 | 15 | To import PSDR-CUDA into Python, you only need to import its central module named ``psdr_cuda``: 16 | 17 | .. code-block:: python3 18 | 19 | import psdr_cuda 20 | 21 | 22 | Basic arithmetic types 23 | ------------------------------ 24 | 25 | PSDR-CUDA relies heavily on the `Enoki `_ library for elementary arithmetic types and mathematical operations. Commonly used data types include ``Float32``, ``Vector3f``, and ``Matrix4f`` from both ``enoki.cuda``, which can be imported as follows: 26 | 27 | .. code-block:: python3 28 | 29 | from enoki.cuda import Float32 as FloatC, Vector3f as Vector3fC, Matrix4f as Matrix4fC 30 | 31 | For more details on Enoki's data types and their Python bindings, please refer to its `official documentation `_. 32 | -------------------------------------------------------------------------------- /docs/python_render.rst: -------------------------------------------------------------------------------- 1 | .. _Python render: 2 | 3 | Rendering a scene 4 | ==================== 5 | 6 | PSDR-CUDA renders virtual scenes described using a simplified version of Mitsuba's XML `description language `_. 7 | 8 | 9 | Loading a scene 10 | -------------------- 11 | 12 | PSDR-CUDA provides two functions for loading scenes in Python: 13 | 14 | - ``psdr_cuda.Scene.load_file()``: load the scene from an XML file on disk; 15 | 16 | - ``psdr_cuda.Scene.load_string()``: load the scene from a string in memory. 17 | 18 | Here is a complete Python example on how to load a PSDR-CUDA scene from an XML file: 19 | 20 | .. code-block:: python3 21 | 22 | import psdr_cuda 23 | 24 | scene = psdr_cuda.Scene() 25 | scene.load_file('scene.xml') 26 | 27 | 28 | Forward rendering of a scene 29 | ------------------------------ 30 | 31 | Once a scene has been loaded, it can be rendered as follows: 32 | 33 | .. code-block:: python3 34 | 35 | # Initialize an integrator 36 | integrator = psdr_cuda.DirectIntegrator() 37 | 38 | # Start rendering! 39 | sensor_id = 0 40 | image = integrator.renderC(scene, sensor_id) 41 | 42 | The ``sensor_id`` variable is an integer specifying which sensor to use (as PSDR-CUDA allows a scene to contain multiple sensors with identical resolutions). 43 | 44 | The ``image`` variable returned by the integrator's ``renderC()`` function is a RGB image stored as an Enoki CUDA array of the type ``enoki.cuda.Vector3f``. This variable can be converted to a Numpy array and saved as an OpenEXR image named ``image.exr`` using OpenCV: 45 | 46 | .. code-block:: python3 47 | 48 | # Cast to a Numpy array and reshape 49 | out = image.numpy().reshape((scene.opts.cropheight, scene.opts.cropwidth, 3)) 50 | 51 | # Save to OpenEXR image using OpenCV 52 | import cv2 53 | out = cv2.cvtColor(out, cv2.COLOR_RGB2BGR) # OpenCV uses BGR 54 | cv2.imwrite("image.exr", out) 55 | 56 | In the code above, ``scene.opts`` is an instance of ``psdr_cuda.RenderOption`` whose C++ definition is 57 | 58 | .. code-block:: c++ 59 | 60 | struct RenderOption { 61 | int width, height; // Image resolution 62 | int spp; // Spp for the main image/interior integral 63 | int sppe; // Spp for primary edge integral 64 | int sppse; // Spp for secondary edge integral 65 | int log_level; 66 | }; 67 | 68 | This variable is automatically set when loading the scene but can also be overwritten as follows. 69 | 70 | .. code-block:: python3 71 | 72 | # Delay the configuration of the scene 73 | scene.load_file('scene.xml', auto_configure=False) 74 | 75 | # Overwriting the render options 76 | scene.opts.cropwidth = 256 77 | scene.opts.cropheight = 256 78 | scene.opts.spp = 32 79 | 80 | # Configure the scene 81 | scene.configure() 82 | 83 | Note that a scene must be configured before being rendered. If the scene is loaded with ``auto_configure=False`` without being manually configured via ``scene.configure()``, attempting to render it will cause an assertion failure. 84 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | guzzle_sphinx_theme 2 | pygments-mathematica 3 | -------------------------------------------------------------------------------- /examples/python/Untitled.py: -------------------------------------------------------------------------------- 1 | def tv_loss(img, tv_weight): 2 | """ 3 | Compute total variation loss. 4 | Inputs: 5 | - img: PyTorch Variable of shape (1, 3, H, W) holding an input image. 6 | - tv_weight: Scalar giving the weight w_t to use for the TV loss. 7 | Returns: 8 | - loss: PyTorch Variable holding a scalar giving the total variation loss 9 | for img weighted by tv_weight. 10 | """ 11 | w_variance = torch.sum(torch.pow(img[:,:,:,:-1] - img[:,:,:,1:], 2)) 12 | h_variance = torch.sum(torch.pow(img[:,:,:-1,:] - img[:,:,1:,:], 2)) 13 | loss = tv_weight * (h_variance + w_variance) 14 | return loss -------------------------------------------------------------------------------- /examples/python/constants.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | # replace this as home directory 4 | HOME_DIR = "/home/dx/Research/" 5 | 6 | ROOT_DIR = os.path.join(HOME_DIR, "psdr-bssrdf") 7 | DATA_DIR = os.path.join(HOME_DIR, "data") 8 | SCENES_DIR = os.path.join(ROOT_DIR, "examples/scenes/") 9 | 10 | RAW_TEXTURE_DIR = os.path.join(ROOT_DIR, "examples/data/textures_raw/") 11 | TEXTURE_DIR = os.path.join(DATA_DIR, "textures") 12 | REMESH_DIR = os.path.join(HOME_DIR, "botsch-kobbelt-remesher-libigl/build") 13 | RESULT_DIR = os.path.join(DATA_DIR, "results") 14 | BLEND_SCENE = os.path.join(SCENES_DIR, "render.blend") 15 | BLENDER_EXEC = "blender2.8" # Change this if you have a different blender installation 16 | REAL_DIR = os.path.join(DATA_DIR, "realdata/") 17 | # data folders 18 | ESSEN_DIR = os.path.join(DATA_DIR, "essen/") 19 | LIGHT_DIR = os.path.join(SCENES_DIR, "light/") 20 | SHAPE_DIR = os.path.join(DATA_DIR, "smoothshape/") 21 | -------------------------------------------------------------------------------- /examples/python/scripts/learn_kiwi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | python3 ../learn_real_data.py \ 4 | --stats_folder "joint_kiwi" \ 5 | --light_file "gantry" \ 6 | --seed 2 \ 7 | --scene "kiwi" \ 8 | --n_dump 50 \ 9 | --ref_folder "exr_ref" \ 10 | --mesh_lr 0.05 \ 11 | --sigma_lr 0.05 \ 12 | --albedo_lr 0.05 \ 13 | --rough_lr 0.05 \ 14 | --eta_lr 0.005 \ 15 | --n_reduce_step 1000 \ 16 | --n_iters 10000 \ 17 | --laplacian 30 \ 18 | --spp 32 \ 19 | --sppe 32 \ 20 | --sppse 2500 \ 21 | --sigma_laplacian 0 \ 22 | --albedo_laplacian 0 \ 23 | --rough_laplacian 0 \ 24 | --albedo_texture 512 \ 25 | --sigma_texture 0 \ 26 | --rough_texture 512 \ 27 | --no_init "no" \ 28 | --d_type "real" -------------------------------------------------------------------------------- /examples/python/scripts/learn_soap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | python3 ../learn_real_data.py \ 4 | --stats_folder "joint_sss" \ 5 | --light_file "gantry" \ 6 | --seed 0 \ 7 | --scene "soap" \ 8 | --n_dump 50 \ 9 | --ref_folder "exr_ref" \ 10 | --mesh_lr 0.05 \ 11 | --sigma_lr 0.5 \ 12 | --albedo_lr 0.05 \ 13 | --rough_lr 0.05 \ 14 | --eta_lr 0.05 \ 15 | --n_reduce_step 500 \ 16 | --n_iters 10000 \ 17 | --laplacian 30 \ 18 | --spp 32 \ 19 | --sppe 32 \ 20 | --sppse 2500 \ 21 | --sigma_laplacian 0 \ 22 | --albedo_laplacian 0 \ 23 | --rough_laplacian 0 \ 24 | --albedo_texture 512 \ 25 | --sigma_texture 0 \ 26 | --rough_texture 512 \ 27 | --no_init "no" \ 28 | --d_type "real" 29 | -------------------------------------------------------------------------------- /examples/scenes/light/lights-gantry.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/examples/scenes/light/lights-gantry.npy -------------------------------------------------------------------------------- /examples/scenes/light/lights-sy-bunny.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/examples/scenes/light/lights-sy-bunny.npy -------------------------------------------------------------------------------- /examples/scenes/light/lights-sy-cube.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/examples/scenes/light/lights-sy-cube.npy -------------------------------------------------------------------------------- /examples/scenes/light/lights-sy-layer.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/examples/scenes/light/lights-sy-layer.npy -------------------------------------------------------------------------------- /examples/scenes/light/lights-sy-platigon.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/examples/scenes/light/lights-sy-platigon.npy -------------------------------------------------------------------------------- /examples/scenes/light/lights-sy-seal.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/examples/scenes/light/lights-sy-seal.npy -------------------------------------------------------------------------------- /examples/scenes/light/lights-sy.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyDeng/InverseTranslucent/c1bade64e8d3e9adde4cd3ce4d55b33af5a51f15/examples/scenes/light/lights-sy.npy -------------------------------------------------------------------------------- /include/psdr/bsdf/bsdf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace psdr 9 | { 10 | 11 | template 12 | struct BSDFSample_ : public SampleRecord_ { 13 | PSDR_IMPORT_BASE(SampleRecord_, ad, pdf, is_valid) 14 | 15 | Vector3f wo; 16 | // Xi Deng added to support bssrdf 17 | Intersection po; 18 | Mask is_sub; 19 | 20 | ENOKI_DERIVED_STRUCT(BSDFSample_, Base, 21 | ENOKI_BASE_FIELDS(pdf, is_valid), 22 | ENOKI_DERIVED_FIELDS(wo, po, is_sub) 23 | ) 24 | }; 25 | 26 | 27 | PSDR_CLASS_DECL_BEGIN(BSDF,, Object) 28 | public: 29 | virtual ~BSDF() override {} 30 | 31 | virtual SpectrumC eval(const IntersectionC &its, const Vector3fC &wo, MaskC active = true) const = 0; 32 | virtual SpectrumD eval(const IntersectionD &its, const Vector3fD &wo, MaskD active = true) const = 0; 33 | 34 | // virtual BSDFSampleC sample(const IntersectionC &its, const Vector3fC &sample, MaskC active = true) const = 0; 35 | // virtual BSDFSampleD sample(const IntersectionD &its, const Vector3fD &sample, MaskD active = true) const = 0; 36 | 37 | virtual FloatC pdf(const IntersectionC &its, const Vector3fC &wo, MaskC active) const = 0; 38 | virtual FloatD pdf(const IntersectionD &its, const Vector3fD &wo, MaskD active) const = 0; 39 | virtual bool anisotropic() const = 0; 40 | 41 | // Xi Deng added to support bssrdf 42 | virtual SpectrumC eval(const IntersectionC &its, const BSDFSampleC &bs, MaskC active = true) const = 0; 43 | virtual SpectrumD eval(const IntersectionD &its, const BSDFSampleD &bs, MaskD active = true) const = 0; 44 | // virtual SpectrumC eval(const IntersectionC &its, const BSDFSampleC &bs, MaskC active = true) const = 0; 45 | // virtual SpectrumD eval(const IntersectionD &its, const BSDFSampleD &bs, MaskD active = true) const = 0; 46 | 47 | virtual BSDFSampleC sample(const Scene *scene, const IntersectionC &its, const Vector8fC &sample, MaskC active = true) const = 0; 48 | virtual BSDFSampleD sample(const Scene *scene, const IntersectionD &its, const Vector8fD &sample, MaskD active = true) const = 0; 49 | 50 | virtual FloatC pdf(const IntersectionC &its, const BSDFSampleC &wo, MaskC active) const = 0; 51 | virtual FloatD pdf(const IntersectionD &its, const BSDFSampleD &wo, MaskD active) const = 0; 52 | 53 | virtual FloatC pdfpoint(const IntersectionC &its, const BSDFSampleC &bs, MaskC active) const = 0; 54 | virtual FloatD pdfpoint(const IntersectionD &its, const BSDFSampleD &bs, MaskD active) const = 0; 55 | 56 | virtual bool hasbssdf() const = 0; 57 | PSDR_CLASS_DECL_END(BSDF) 58 | 59 | } // namespace psdr 60 | 61 | ENOKI_STRUCT_SUPPORT(psdr::BSDFSample_, pdf, is_valid, wo, po, is_sub) 62 | 63 | ENOKI_CALL_SUPPORT_BEGIN(psdr::BSDF) 64 | ENOKI_CALL_SUPPORT_METHOD(eval) 65 | ENOKI_CALL_SUPPORT_METHOD(sample) 66 | ENOKI_CALL_SUPPORT_METHOD(pdf) 67 | ENOKI_CALL_SUPPORT_METHOD(pdfpoint) 68 | ENOKI_CALL_SUPPORT_METHOD(anisotropic) 69 | ENOKI_CALL_SUPPORT_METHOD(hasbssdf) 70 | ENOKI_CALL_SUPPORT_END(psdr::BSDF) 71 | -------------------------------------------------------------------------------- /include/psdr/bsdf/diffuse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "bsdf.h" 5 | 6 | namespace psdr 7 | { 8 | 9 | PSDR_CLASS_DECL_BEGIN(Diffuse, final, BSDF) 10 | public: 11 | Diffuse() : m_reflectance(0.5f) {} 12 | Diffuse(const ScalarVector3f &ref) : m_reflectance(ref) {} 13 | Diffuse(const char *refl_file); 14 | Diffuse(const Bitmap3fD &reflectance); 15 | 16 | void setDiffuseReflectance(std::string filename){ 17 | m_reflectance.load_openexr(filename.c_str()); 18 | } 19 | 20 | SpectrumC eval(const IntersectionC &its, const Vector3fC &wo, MaskC active = true) const override; 21 | SpectrumD eval(const IntersectionD &its, const Vector3fD &wo, MaskD active = true) const override; 22 | 23 | // BSDFSampleC sample(const IntersectionC &its, const Vector3fC &sample, MaskC active = true) const override; 24 | // BSDFSampleD sample(const IntersectionD &its, const Vector3fD &sample, MaskD active = true) const override; 25 | 26 | FloatC pdf(const IntersectionC &its, const Vector3fC &wo, MaskC active) const override; 27 | FloatD pdf(const IntersectionD &its, const Vector3fD &wo, MaskD active) const override; 28 | bool anisotropic() const override { return false; } 29 | bool hasbssdf() const override { return false; } 30 | 31 | std::string to_string() const override { return std::string("Diffuse[id=") + m_id + "]"; } 32 | void setSigmaS(ScalarVector3f &a){return;}; 33 | void setSigmaA(ScalarVector3f &a){return;}; 34 | Bitmap3fD m_reflectance; 35 | 36 | // Xi Deng added to support bssrdf 37 | SpectrumC eval(const IntersectionC &its, const BSDFSampleC &bs, MaskC active = true) const override; 38 | SpectrumD eval(const IntersectionD &its, const BSDFSampleD &bs, MaskD active = true) const override; 39 | 40 | BSDFSampleC sample(const Scene *scene, const IntersectionC &its, const Vector8fC &sample, MaskC active = true) const override; 41 | BSDFSampleD sample(const Scene *scene, const IntersectionD &its, const Vector8fD &sample, MaskD active = true) const override; 42 | 43 | FloatC pdf(const IntersectionC &its, const BSDFSampleC &wo, MaskC active) const override; 44 | FloatD pdf(const IntersectionD &its, const BSDFSampleD &wo, MaskD active) const override; 45 | 46 | FloatC pdfpoint(const IntersectionC &its, const BSDFSampleC &bs, MaskC active) const override {return 1.0f;} 47 | FloatD pdfpoint(const IntersectionD &its, const BSDFSampleD &bs, MaskD active) const override {return 1.0f;} 48 | 49 | protected: 50 | template 51 | Spectrum __eval(const Intersection&, const Vector3f&, Mask) const; 52 | 53 | template 54 | BSDFSample __sample(const Intersection&, const Vector8f&, Mask) const; 55 | 56 | template 57 | Float __pdf(const Intersection &, const Vector3f &, Mask) const; 58 | PSDR_CLASS_DECL_END(Diffuse) 59 | } // namespace psdr 60 | -------------------------------------------------------------------------------- /include/psdr/bsdf/ggx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "bsdf.h" 5 | 6 | namespace psdr 7 | { 8 | 9 | struct GGXDistribution { 10 | public: 11 | GGXDistribution() : m_alpha_u(0.1f), m_alpha_v(0.1f) {} 12 | GGXDistribution(const FloatD &alpha) : m_alpha_u(alpha), m_alpha_v(alpha) {} 13 | GGXDistribution(const FloatD &alpha_u, const FloatD &alpha_v) : m_alpha_u(alpha_u), m_alpha_v(alpha_v) {} 14 | 15 | template 16 | Float G(const Vector3f& wi, const Vector3f& wo, const Vector3f& m) const; 17 | 18 | template 19 | Float eval(const Vector3f& m) const; 20 | 21 | template 22 | Vector3f sample(const Vector3f& wi, const Vector3f& sample) const; 23 | 24 | template 25 | Float smith_g1(const Vector3f& v, const Vector3f& m) const; 26 | 27 | template 28 | Vector2f sample_visible_11(const Float& cos_theta_i, const Vector2f& sample) const; 29 | 30 | FloatD m_alpha_u, m_alpha_v; 31 | }; 32 | 33 | } // namespace psdr 34 | -------------------------------------------------------------------------------- /include/psdr/bsdf/microfacet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "bsdf.h" 5 | 6 | namespace psdr 7 | { 8 | 9 | PSDR_CLASS_DECL_BEGIN(Microfacet, final, BSDF) 10 | public: 11 | Microfacet() : m_specularReflectance(0.5f), m_diffuseReflectance(0.5f), m_roughness(0.5f) {} 12 | 13 | Microfacet(const ScalarVector3f &specularRef, const ScalarVector3f &diffuseRef, float roughnessRef) : 14 | m_specularReflectance(specularRef), m_diffuseReflectance(diffuseRef), m_roughness(roughnessRef) {} 15 | 16 | Microfacet(const char *spec_refl_file, const char *diff_refl_file, const char *roughness_file); 17 | 18 | Microfacet(const Bitmap3fD &spec_refl, const Bitmap3fD &diff_refl, const Bitmap1fD &roughness); 19 | 20 | void setDiffuseReflectance(std::string filename){ 21 | m_diffuseReflectance.load_openexr(filename.c_str()); 22 | } 23 | 24 | void setSpecularReflectance(std::string filename){ 25 | m_specularReflectance.load_openexr(filename.c_str()); 26 | } 27 | 28 | void setAlphaTexture(std::string filename){ 29 | m_roughness.load_openexr(filename.c_str()); 30 | } 31 | 32 | 33 | SpectrumC eval(const IntersectionC &its, const Vector3fC &wo, MaskC active = true) const override; 34 | SpectrumD eval(const IntersectionD &its, const Vector3fD &wo, MaskD active = true) const override; 35 | 36 | // Begin: Xi Deng added to support bssrdf 37 | SpectrumC eval(const IntersectionC &its, const BSDFSampleC &bs, MaskC active = true) const override; 38 | SpectrumD eval(const IntersectionD &its, const BSDFSampleD &bs, MaskD active = true) const override; 39 | FloatC pdf(const IntersectionC &its, const BSDFSampleC &wo, MaskC active = true) const override; 40 | FloatD pdf(const IntersectionD &its, const BSDFSampleD &wo, MaskD active = true) const override; 41 | FloatC pdfpoint(const IntersectionC &its, const BSDFSampleC &bs, MaskC active) const override {return 1.0f;} 42 | FloatD pdfpoint(const IntersectionD &its, const BSDFSampleD &bs, MaskD active) const override {return 1.0f;} 43 | // End 44 | 45 | void setSigmaS(ScalarVector3f &a) {return;} 46 | void setSigmaA(ScalarVector3f &a) {return;} 47 | 48 | BSDFSampleC sample(const Scene *scene, const IntersectionC &its, const Vector8fC &sample, MaskC active = true) const override; 49 | BSDFSampleD sample(const Scene *scene, const IntersectionD &its, const Vector8fD &sample, MaskD active = true) const override; 50 | 51 | FloatC pdf(const IntersectionC &its, const Vector3fC &wo, MaskC active) const override; 52 | FloatD pdf(const IntersectionD &its, const Vector3fD &wo, MaskD active) const override; 53 | 54 | bool anisotropic() const override { return false; } 55 | bool hasbssdf() const override { return false; } 56 | 57 | std::string to_string() const override { return std::string("Microfacet[id=") + m_id + "]"; } 58 | 59 | Bitmap3fD m_specularReflectance, 60 | m_diffuseReflectance; 61 | Bitmap1fD m_roughness; 62 | 63 | protected: 64 | template 65 | Spectrum __eval(const Intersection &its, const Vector3f &wo, Mask active = true) const; 66 | 67 | template 68 | BSDFSample __sample(const Intersection&, const Vector8f&, Mask) const; 69 | 70 | template 71 | Float __pdf(const Intersection &, const Vector3f &, Mask) const; 72 | PSDR_CLASS_DECL_END(Microfacet) 73 | 74 | } // namespace psdr 75 | -------------------------------------------------------------------------------- /include/psdr/bsdf/roughconductor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "bsdf.h" 5 | 6 | namespace psdr 7 | { 8 | 9 | PSDR_CLASS_DECL_BEGIN(RoughConductor, final, BSDF) 10 | public: 11 | RoughConductor() 12 | : m_alpha_u(0.1f), m_alpha_v(0.1f), m_eta(0.0f), m_k(1.0f), m_specular_reflectance(1.0f) { m_anisotropic = false; } 13 | 14 | RoughConductor(const Bitmap1fD &alpha, const Bitmap3fD &eta, const Bitmap3fD &k) 15 | : m_alpha_u(alpha), m_alpha_v(alpha), m_eta(eta), m_k(k), m_specular_reflectance(1.0f) { m_anisotropic = false; } 16 | 17 | RoughConductor(const Bitmap1fD &alpha, const Bitmap3fD &eta, const Bitmap3fD &k, const Bitmap3fD &sr) 18 | : m_alpha_u(alpha), m_alpha_v(alpha), m_eta(eta), m_k(k), m_specular_reflectance(sr) { m_anisotropic = false; } 19 | 20 | RoughConductor(const Bitmap1fD &alpha_u, const Bitmap1fD &alpha_v, const Bitmap3fD &eta, const Bitmap3fD &k) 21 | : m_alpha_u(alpha_u), m_alpha_v(alpha_v), m_eta(eta), m_k(k), m_specular_reflectance(1.0f) { m_anisotropic = true; } 22 | 23 | RoughConductor(const Bitmap1fD &alpha_u, const Bitmap1fD &alpha_v, const Bitmap3fD &eta, const Bitmap3fD &k, const Bitmap3fD &sr) 24 | : m_alpha_u(alpha_u), m_alpha_v(alpha_v), m_eta(eta), m_k(k), m_specular_reflectance(sr) { m_anisotropic = true; } 25 | 26 | SpectrumC eval(const IntersectionC &its, const Vector3fC &wo, MaskC active = true) const override; 27 | SpectrumD eval(const IntersectionD &its, const Vector3fD &wo, MaskD active = true) const override; 28 | 29 | // Begin: Xi Deng added to support bssrdf 30 | SpectrumC eval(const IntersectionC &its, const BSDFSampleC &bs, MaskC active = true) const override; 31 | SpectrumD eval(const IntersectionD &its, const BSDFSampleD &bs, MaskD active = true) const override; 32 | FloatC pdf(const IntersectionC &its, const BSDFSampleC &wo, MaskC active = true) const override; 33 | FloatD pdf(const IntersectionD &its, const BSDFSampleD &wo, MaskD active = true) const override; 34 | FloatC pdfpoint(const IntersectionC &its, const BSDFSampleC &bs, MaskC active) const override {return 1.0f;} 35 | FloatD pdfpoint(const IntersectionD &its, const BSDFSampleD &bs, MaskD active) const override {return 1.0f;} 36 | 37 | // End 38 | void setSigmaS(ScalarVector3f &a) {return;} 39 | void setSigmaA(ScalarVector3f &a) {return;} 40 | 41 | BSDFSampleC sample(const Scene *scene, const IntersectionC &its, const Vector8fC &sample, MaskC active = true) const override; 42 | BSDFSampleD sample(const Scene *scene, const IntersectionD &its, const Vector8fD &sample, MaskD active = true) const override; 43 | 44 | FloatC pdf(const IntersectionC &its, const Vector3fC &wo, MaskC active = true) const override; 45 | FloatD pdf(const IntersectionD &its, const Vector3fD &wo, MaskD active = true) const override; 46 | 47 | 48 | bool anisotropic() const override { return m_anisotropic; } 49 | bool hasbssdf() const override { return false; } 50 | 51 | std::string to_string() const override { return std::string("RoughConductor[id=") + m_id + "]"; } 52 | 53 | Bitmap1fD m_alpha_u, m_alpha_v; 54 | Bitmap3fD m_eta, m_k; 55 | Bitmap3fD m_specular_reflectance; 56 | bool m_anisotropic; 57 | 58 | protected: 59 | template 60 | Spectrum __eval(const Intersection&, const Vector3f&, Mask) const; 61 | 62 | template 63 | BSDFSample __sample(const Intersection&, const Vector8f&, Mask) const; 64 | 65 | template 66 | Float __pdf(const Intersection &, const Vector3f &, Mask) const; 67 | PSDR_CLASS_DECL_END(RoughConductor) 68 | 69 | } // namespace psdr 70 | -------------------------------------------------------------------------------- /include/psdr/constants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace psdr 6 | { 7 | 8 | constexpr float Epsilon = 1e-5f; 9 | constexpr float RayEpsilon = 1e-3f; 10 | constexpr float ShadowEpsilon = 1e-3f; 11 | constexpr float EdgeEpsilon = 1e-5f; 12 | 13 | constexpr float E = 2.71828182845904523536f; 14 | constexpr float Pi = 3.14159265358979323846f; 15 | constexpr float TwoPi = 6.28318530717958647692f; 16 | constexpr float InvPi = 0.31830988618379067154f; 17 | constexpr float InvTwoPi = 0.15915494309189533577f; 18 | constexpr float InvFourPi = 0.07957747154594766788f; 19 | constexpr float SqrtPi = 1.77245385090551602793f; 20 | constexpr float InvSqrtPi = 0.56418958354775628695f; 21 | constexpr float SqrtTwo = 1.41421356237309504880f; 22 | constexpr float InvSqrtTwo = 0.70710678118654752440f; 23 | constexpr float SqrtTwoPi = 2.50662827463100050242f; 24 | constexpr float InvSqrtTwoPi = 0.39894228040143267794f; 25 | 26 | constexpr float Infinity = std::numeric_limits::infinity(); 27 | 28 | } // namespace psdr 29 | -------------------------------------------------------------------------------- /include/psdr/core/bitmap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | // layer map 7 | namespace psdr 8 | { 9 | 10 | template 11 | struct Layermap { 12 | static_assert(channels == 1 || channels == 3); 13 | using ScalarValue = typename std::conditional::type; 14 | 15 | template 16 | using Value = typename std::conditional, Vector3f>::type; 17 | 18 | using ValueC = Value; 19 | using ValueD = Value; 20 | 21 | Layermap(); 22 | Layermap(const char *file_name, int number=1); 23 | Layermap(ScalarValue value); 24 | }; 25 | 26 | // Xi Deng add a layer map 27 | 28 | template 29 | struct Bitmap { 30 | static_assert(channels == 1 || channels == 3); 31 | using ScalarValue = typename std::conditional::type; 32 | 33 | template 34 | using Value = typename std::conditional, Vector3f>::type; 35 | 36 | using ValueC = Value; 37 | using ValueD = Value; 38 | 39 | Bitmap(); 40 | Bitmap(const char *file_name); 41 | Bitmap(ScalarValue value); 42 | Bitmap(int width, int height, const ValueD &data); 43 | 44 | void load_openexr(const char *file_name); 45 | 46 | inline void fill(ScalarValue value) { 47 | m_resolution = ScalarVector2i(1, 1); 48 | m_data = ValueD(value); 49 | } 50 | 51 | template Value eval(Vector2f uv, bool flip_v = true) const; 52 | 53 | ScalarVector2i m_resolution; 54 | ValueD m_data; 55 | }; 56 | 57 | using Bitmap1fD = Bitmap<1>; 58 | using Bitmap3fD = Bitmap<3>; 59 | 60 | } // namespace psdr 61 | 62 | -------------------------------------------------------------------------------- /include/psdr/core/bitmap_loader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace psdr 6 | { 7 | 8 | 9 | struct BitmapLoader { 10 | static std::pair load_openexr_rgba(const char *file_name); 11 | }; 12 | 13 | 14 | } // namespace psdr 15 | -------------------------------------------------------------------------------- /include/psdr/core/cube_distrb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "pmf.h" 5 | 6 | namespace psdr 7 | { 8 | 9 | template 10 | struct HyperCubeDistribution { 11 | static_assert(ndim > 1); 12 | 13 | void set_resolution(const Array &reso); 14 | void set_mass(const FloatC &pmf); 15 | 16 | FloatC sample_reuse(Vectorf &samples) const; 17 | FloatC pdf(const Vectorf &p) const; 18 | 19 | bool m_ready = false; 20 | Array m_resolution = 0; 21 | 22 | DiscreteDistribution m_distrb; 23 | 24 | int m_num_cells; 25 | Vectori m_cells; 26 | Array m_unit; 27 | }; 28 | 29 | } // namespace psdr 30 | -------------------------------------------------------------------------------- /include/psdr/core/intersection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "frame.h" 4 | 5 | namespace psdr 6 | { 7 | 8 | template 9 | struct Interaction_ { 10 | static constexpr bool ad = std::is_same_v; 11 | 12 | template 13 | inline Interaction_(const Interaction_ &in) : wi(in.wi), p(in.p), t(in.t) {} 14 | 15 | virtual Mask is_valid() const = 0; 16 | 17 | Vector3f wi, p; 18 | Float t = Infinity; 19 | 20 | ENOKI_STRUCT(Interaction_, wi, p, t) 21 | }; 22 | 23 | 24 | template 25 | struct Intersection_ : public Interaction_ { 26 | PSDR_IMPORT_BASE(Interaction_, ad, wi, p, t) 27 | 28 | Mask is_valid() const override { 29 | return neq(shape, nullptr); 30 | } 31 | 32 | inline Mask is_emitter(Mask active) const { 33 | return neq(shape->emitter(active), nullptr); 34 | } 35 | 36 | inline Spectrum Le(Mask active) const { 37 | return shape->emitter(active)->eval(*this, active); 38 | } 39 | 40 | MeshArray shape; 41 | 42 | Vector3f n; // geometric normal 43 | Frame sh_frame; // shading frame 44 | 45 | Vector2f uv; 46 | Float J; // Jacobian determinant for material-form reparam 47 | 48 | // Xi Deng added 49 | Float num; // number of intersection along the ray 50 | // Int pixelIdx; 51 | ENOKI_DERIVED_STRUCT(Intersection_, Interaction_, 52 | ENOKI_BASE_FIELDS(wi, p, t), 53 | ENOKI_DERIVED_FIELDS(shape, n, sh_frame, uv, J, num) 54 | ) 55 | }; 56 | 57 | 58 | // template 59 | // struct Intersections__ { 60 | // static constexpr bool ad = std::is_same_v; 61 | 62 | // template 63 | // inline Intersections__(const Float num) : num(num) {} 64 | 65 | // Array, 20> shape; 66 | 67 | // Array, 20> n; // geometric normal 68 | // Array, 20> sh_frame; // shading frame 69 | 70 | // Array, 20> uv; 71 | // Array, 20> J; // Jacobian determinant for material-form reparam 72 | 73 | // // Xi Deng added 74 | // Array< 20> num; // number of intersection along the ray 75 | 76 | // Float num; 77 | // ENOKI_STRUCT(Intersections__, its, num) 78 | // }; 79 | 80 | 81 | //inline IntersectionC detach(const IntersectionD &its) { 82 | // IntersectionC result; 83 | // result.wi = detach(its.wi); 84 | // result.p = detach(its.p); 85 | // result.t = detach(its.t); 86 | // result.shape = detach(its.shape); 87 | // result.n = detach(its.n); 88 | // result.sh_frame = detach(its.sh_frame); 89 | // result.uv = detach(its.uv); 90 | // result.J = detach(its.J); 91 | // return result; 92 | //} 93 | 94 | } // namespace psdr 95 | 96 | ENOKI_STRUCT_SUPPORT(psdr::Interaction_, wi, p, t) 97 | ENOKI_STRUCT_SUPPORT(psdr::Intersection_, wi, p, t, shape, n, sh_frame, uv, J, num) 98 | // ENOKI_STRUCT_SUPPORT(psdr::Intersections__, its, num) -------------------------------------------------------------------------------- /include/psdr/core/pmf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace psdr 6 | { 7 | 8 | struct DiscreteDistribution { 9 | DiscreteDistribution() = default; 10 | 11 | void init(const FloatC &pmf); 12 | 13 | std::pair sample(const FloatC &samples) const; 14 | 15 | template 16 | std::pair sample_reuse(Float &samples) const; 17 | 18 | const FloatC &pmf() const { return m_pmf_normalized; } 19 | 20 | int m_size; 21 | FloatC m_sum; 22 | 23 | protected: 24 | FloatC m_pmf, m_pmf_normalized, m_cmf; 25 | }; 26 | 27 | } // namespace psdr 28 | -------------------------------------------------------------------------------- /include/psdr/core/ray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace psdr 6 | { 7 | 8 | template 9 | struct Ray { 10 | inline Ray() = default; 11 | 12 | inline Ray(const Vector3f &o, const Vector3f &d, const Float &tmax) : o(o), d(d), tmax(tmax) { 13 | assert(slices(o) == slices(d) && slices(o) == slices(tmax)); 14 | } 15 | 16 | inline Ray(const Vector3f &o, const Vector3f &d) : o(o), d(d) { 17 | assert(slices(o) == slices(d)); 18 | tmax = full>(Infinity, slices(o)); 19 | } 20 | 21 | template inline Ray(const Ray &ray) : o(ray.o), d(ray.d), tmax(ray.tmax) {} 22 | 23 | Vector3f o, d; 24 | Float tmax; 25 | 26 | Vector3f operator() (const Float &t) const { return fmadd(d, t, o); } 27 | 28 | inline Ray reversed() const { return Ray(o, -d, tmax); } 29 | }; 30 | 31 | 32 | inline RayC detach(const RayD &ray) { 33 | return RayC(detach(ray.o), detach(ray.d), detach(ray.tmax)); 34 | } 35 | 36 | } // namespace psdr 37 | -------------------------------------------------------------------------------- /include/psdr/core/records.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "ray.h" 5 | #include "intersection.h" 6 | 7 | namespace psdr 8 | { 9 | 10 | template 11 | struct SampleRecord_ { 12 | static constexpr bool ad = std::is_same_v; 13 | 14 | Float pdf; 15 | Mask is_valid; 16 | 17 | ENOKI_STRUCT(SampleRecord_, pdf, is_valid) 18 | }; 19 | 20 | 21 | template 22 | struct PositionSample_ : public SampleRecord_ { 23 | PSDR_IMPORT_BASE(SampleRecord_, ad, pdf, is_valid) 24 | 25 | Vector3f p, n; 26 | Float J; 27 | 28 | ENOKI_DERIVED_STRUCT(PositionSample_, Base, 29 | ENOKI_BASE_FIELDS(pdf, is_valid), 30 | ENOKI_DERIVED_FIELDS(p, n, J) 31 | ) 32 | }; 33 | 34 | 35 | struct BoundarySegSampleDirect : public SampleRecord_ { 36 | PSDR_IMPORT_BASE(SampleRecord_, pdf, is_valid) 37 | 38 | // Sample point on a face edge 39 | Vector3fD p0; 40 | Vector3fC edge, edge2; 41 | 42 | // Sample point on an emitter 43 | Vector3fC p2, n; 44 | }; 45 | 46 | } // namespace psdr 47 | 48 | ENOKI_STRUCT_SUPPORT(psdr::SampleRecord_, pdf, is_valid) 49 | ENOKI_STRUCT_SUPPORT(psdr::PositionSample_, pdf, is_valid, p, n, J) 50 | -------------------------------------------------------------------------------- /include/psdr/core/sampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace psdr 7 | { 8 | 9 | struct Sampler { 10 | using PCG32 = enoki::PCG32; 11 | 12 | // std::shared_ptr clone(); 13 | 14 | void seed(UInt64C seed_value); 15 | 16 | inline bool is_ready() const { return m_rng != nullptr; } 17 | 18 | template Float next_1d(); 19 | 20 | template inline Vector2f next_2d() { 21 | return Vector2f(next_1d(), next_1d()); 22 | } 23 | 24 | template inline Vectorf next_nd() { 25 | static_assert(n > 0); 26 | if constexpr ( n == 1 ) { 27 | return next_1d(); 28 | } else { 29 | constexpr int m = n / 2; 30 | return concat(next_nd(), next_nd()); 31 | } 32 | } 33 | 34 | int64_t m_sample_count = 0; 35 | uint64_t m_base_seed = PCG32_DEFAULT_STATE; 36 | std::unique_ptr m_rng = nullptr; 37 | }; 38 | 39 | } // namespace psdr 40 | -------------------------------------------------------------------------------- /include/psdr/core/transform.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace psdr 7 | { 8 | 9 | namespace transform 10 | { 11 | 12 | /// Create a translation transformation 13 | template 14 | static Matrix translate(const Array &v) { 15 | return enoki::translate>(v); 16 | } 17 | 18 | /// Create a scale transformation 19 | template 20 | static Matrix scale(const Array &v) { 21 | return enoki::scale>(v); 22 | } 23 | 24 | /// Create a rotation transformation around an arbitrary axis in 3D. The angle is specified in degrees 25 | template 26 | static Matrix rotate(const Array &axis, float angle) { 27 | return enoki::rotate>(axis, deg_to_rad(angle)); 28 | } 29 | 30 | /** \brief Create a perspective transformation. 31 | * (Maps [near, far] to [0, 1]) 32 | * 33 | * Projects vectors in camera space onto a plane at z=1: 34 | * 35 | * x_proj = x / z 36 | * y_proj = y / z 37 | * z_proj = (far * (z - near)) / (z * (far-near)) 38 | * 39 | * Camera-space depths are not mapped linearly! 40 | * 41 | * \param fov Field of view in degrees 42 | * \param near Near clipping plane 43 | * \param far Far clipping plane 44 | */ 45 | static inline ScalarMatrix4f perspective(float fov, float near_, float far_) { 46 | float recip = 1.f / (far_ - near_); 47 | 48 | /* Perform a scale so that the field of view is mapped 49 | to the interval [-1, 1] */ 50 | float tan = enoki::tan(deg_to_rad(fov * .5f)), 51 | cot = 1.f / tan; 52 | 53 | ScalarMatrix4f trafo = diag(ScalarVector4f(cot, cot, far_ * recip, 0.f)); 54 | trafo(2, 3) = -near_ * far_ * recip; 55 | trafo(3, 2) = 1.f; 56 | 57 | return trafo; 58 | } 59 | 60 | /** \brief Create a look-at camera transformation 61 | * 62 | * \param origin Camera position 63 | * \param target Target vector 64 | * \param up Up vector 65 | */ 66 | template 67 | static Matrix look_at(const Array &origin, const Array &target, const Array &up) { 68 | Array dir = normalize(target - origin); 69 | Array left = normalize(cross(up, dir)); 70 | Array new_up = cross(dir, left); 71 | 72 | return Matrix::from_cols( 73 | concat(left, 0.0f), 74 | concat(new_up, 0.0f), 75 | concat(dir, 0.0f), 76 | concat(origin, 1.0f) 77 | ); 78 | } 79 | 80 | 81 | } // namespace transform 82 | 83 | 84 | template 85 | static Array transform_pos(const Matrix &mat, const Array &vec) { 86 | Array tmp = mat*concat(vec, 1.f); 87 | return head<3>(tmp)/tmp.w(); 88 | } 89 | 90 | 91 | template 92 | static Array transform_dir(const Matrix &mat, const Array &vec) { 93 | return head<3>(mat*concat(vec, 0.f)); 94 | } 95 | 96 | } // namespace psdr 97 | -------------------------------------------------------------------------------- /include/psdr/core/warp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "frame.h" 5 | 6 | namespace psdr 7 | { 8 | 9 | namespace warp 10 | { 11 | 12 | /// Low-distortion concentric square to disk mapping by Peter Shirley 13 | template 14 | inline Vector2f square_to_uniform_disk_concentric(const Vector2f &sample) { 15 | Float x = fmsub(2.f, sample.x(), 1.f), 16 | y = fmsub(2.f, sample.y(), 1.f); 17 | 18 | /* Modified concentric map code with less branching (by Dave Cline), see 19 | http://psgraphics.blogspot.ch/2011/01/improved-code-for-concentric-map.html 20 | 21 | Original non-vectorized version: 22 | 23 | Value phi, r; 24 | if (x == 0 && y == 0) { 25 | r = phi = 0; 26 | } else if (x * x > y * y) { 27 | r = x; 28 | phi = (math::Pi / 4.f) * (y / x); 29 | } else { 30 | r = y; 31 | phi = (math::Pi / 2.f) - (x / y) * (math::Pi / 4.f); 32 | } 33 | */ 34 | 35 | Mask is_zero = eq(x, zero>()) && 36 | eq(y, zero>()), 37 | quadrant_1_or_3 = abs(x) < abs(y); 38 | 39 | Float r = select(quadrant_1_or_3, y, x), 40 | rp = select(quadrant_1_or_3, x, y); 41 | 42 | Float phi = .25f * Pi * rp / r; 43 | masked(phi, quadrant_1_or_3) = .5f * Pi - phi; 44 | masked(phi, is_zero) = zero>(); 45 | 46 | auto [s, c] = sincos(phi); 47 | return { r * c, r * s }; 48 | } 49 | 50 | 51 | /// Sample a cosine-weighted vector on the unit hemisphere with respect to solid angles 52 | template 53 | inline Vector3f square_to_cosine_hemisphere(const Vector2f &sample) { 54 | // Low-distortion warping technique based on concentric disk mapping 55 | Vector2f p = square_to_uniform_disk_concentric(sample); 56 | 57 | // Guard against numerical imprecisions 58 | Float z = safe_sqrt(1.f - squared_norm(p)); 59 | 60 | return { p.x(), p.y(), z }; 61 | } 62 | 63 | 64 | /// Density of \ref square_to_cosine_hemisphere() with respect to solid angles 65 | template 66 | inline Float square_to_cosine_hemisphere_pdf(const Vector3f &v) { 67 | if constexpr (TestDomain) 68 | return select(abs(squared_norm(v) - 1.f) > RayEpsilon || 69 | v.z() < 0.f, zero>(), InvPi * v.z()); 70 | else 71 | return InvPi * v.z(); 72 | } 73 | 74 | 75 | /// Convert an uniformly distributed square sample into barycentric coordinates 76 | template 77 | inline Vector2f square_to_uniform_triangle(const Vector2f &sample) { 78 | Float t = safe_sqrt(1.f - sample.x()); 79 | return { 1.f - t, t * sample.y() }; 80 | } 81 | 82 | /// Density of \ref square_to_uniform_triangle per unit area. 83 | template 84 | inline Float square_to_uniform_triangle_pdf(const Vector2f &p) { 85 | if constexpr (TestDomain) { 86 | return select( 87 | p.x() < zero>() || p.y() < zero>() 88 | || (p.x() + p.y() > 1.f), 89 | zero>(), 90 | 2.f 91 | ); 92 | } else { 93 | return 2.f; 94 | } 95 | } 96 | 97 | 98 | } // namespace warp 99 | 100 | } // namespace psdr 101 | -------------------------------------------------------------------------------- /include/psdr/edge/edge.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace psdr 8 | { 9 | 10 | /******************************************** 11 | * Primary edge info types 12 | ********************************************/ 13 | 14 | struct PrimaryEdgeSample { 15 | FloatD x_dot_n; 16 | IntC idx; 17 | RayC ray_n, ray_p; 18 | 19 | #ifdef PSDR_PRIMARY_EDGE_VIS_CHECK 20 | RayC ray_c; 21 | #endif 22 | 23 | FloatC pdf; 24 | }; 25 | 26 | 27 | template 28 | struct PrimaryEdgeInfo_ { 29 | static constexpr bool ad = std::is_same_v; 30 | 31 | #ifdef PSDR_PRIMARY_EDGE_VIS_CHECK 32 | Vector3f p0, p1; 33 | #else 34 | Vector2f p0, p1; 35 | #endif 36 | Vector2f edge_normal; 37 | Float edge_length; 38 | 39 | ENOKI_STRUCT(PrimaryEdgeInfo_, p0, p1, edge_normal, edge_length) 40 | }; 41 | 42 | using PrimaryEdgeInfo = PrimaryEdgeInfo_; 43 | 44 | 45 | /******************************************** 46 | * Secondary edge info 47 | ********************************************/ 48 | 49 | template 50 | struct SecondaryEdgeInfo_ { 51 | static constexpr bool ad = std::is_same_v; 52 | 53 | // p0 and (p0 + e1) are the two endpoints of the edge 54 | Vector3f p0, e1; 55 | 56 | // n0 and n1 are the normals of the two faces sharing the edge 57 | Vector3f n0, n1; 58 | 59 | // p2 is the third vertex of the face with normal n0 60 | Vector3f p2; 61 | 62 | Mask is_boundary; 63 | 64 | ENOKI_STRUCT(SecondaryEdgeInfo_, p0, e1, n0, n1, p2, is_boundary) 65 | }; 66 | 67 | using SecondaryEdgeInfo = SecondaryEdgeInfo_; 68 | 69 | } // namespace psdr 70 | 71 | ENOKI_STRUCT_SUPPORT(psdr::PrimaryEdgeInfo_, p0, p1, edge_normal, edge_length) 72 | ENOKI_STRUCT_SUPPORT(psdr::SecondaryEdgeInfo_, p0, e1, n0, n1, p2, is_boundary) 73 | -------------------------------------------------------------------------------- /include/psdr/emitter/area.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "emitter.h" 5 | 6 | namespace psdr 7 | { 8 | 9 | PSDR_CLASS_DECL_BEGIN(AreaLight, final, Emitter) 10 | public: 11 | AreaLight(const ScalarVector3f &radiance, const Mesh *mesh) : m_radiance(radiance), m_mesh(mesh) {} 12 | 13 | void configure() override; 14 | void setposition(Vector3fD p) override; 15 | 16 | SpectrumC eval(const IntersectionC &its, MaskC active = true) const override; 17 | SpectrumD eval(const IntersectionD &its, MaskD active = true) const override; 18 | 19 | PositionSampleC sample_position(const Vector3fC &ref_p, const Vector2fC &sample2, MaskC active = true) const override; 20 | PositionSampleD sample_position(const Vector3fD &ref_p, const Vector2fD &sample2, MaskD active = true) const override; 21 | 22 | FloatC sample_position_pdf(const Vector3fC &ref_p, const IntersectionC &its, MaskC active = true) const override; 23 | FloatD sample_position_pdf(const Vector3fD &ref_p, const IntersectionD &its, MaskD active = true) const override; 24 | 25 | std::string to_string() const override; 26 | 27 | SpectrumD m_radiance; 28 | const Mesh *m_mesh; 29 | 30 | ENOKI_PINNED_OPERATOR_NEW(FloatD) 31 | 32 | protected: 33 | template 34 | PositionSample __sample_position(const Vector2f&, Mask) const; 35 | 36 | template 37 | Float __sample_position_pdf(const Vector3f&, const Intersection&, Mask) const; 38 | PSDR_CLASS_DECL_END(AreaLight) 39 | 40 | } // namespace psdr 41 | -------------------------------------------------------------------------------- /include/psdr/emitter/emitter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace psdr 7 | { 8 | 9 | PSDR_CLASS_DECL_BEGIN(Emitter,, Object) 10 | public: 11 | virtual ~Emitter() override {} 12 | 13 | virtual void configure() = 0; 14 | virtual void setposition(Vector3fD p) = 0; 15 | // Returns the emitted radiance at its.p in direction its.wi 16 | 17 | virtual SpectrumC eval(const IntersectionC &its, MaskC active = true) const = 0; 18 | virtual SpectrumD eval(const IntersectionD &its, MaskD active = true) const = 0; 19 | 20 | virtual PositionSampleC sample_position(const Vector3fC &ref_p, const Vector2fC &sample2, MaskC active = true) const = 0; 21 | virtual PositionSampleD sample_position(const Vector3fD &ref_p, const Vector2fD &sample2, MaskD active = true) const = 0; 22 | 23 | virtual FloatC sample_position_pdf(const Vector3fC &ref_p, const IntersectionC &its, MaskC active = true) const = 0; 24 | virtual FloatD sample_position_pdf(const Vector3fD &ref_p, const IntersectionD &its, MaskD active = true) const = 0; 25 | 26 | bool m_ready = false; 27 | float m_sampling_weight = 1.f; 28 | 29 | ENOKI_PINNED_OPERATOR_NEW(FloatD) 30 | 31 | PSDR_CLASS_DECL_END(Emitter) 32 | 33 | } // namespace psdr 34 | 35 | ENOKI_CALL_SUPPORT_BEGIN(psdr::Emitter) 36 | ENOKI_CALL_SUPPORT_METHOD(eval) 37 | ENOKI_CALL_SUPPORT_METHOD(sample_position) 38 | ENOKI_CALL_SUPPORT_METHOD(sample_position_pdf) 39 | ENOKI_CALL_SUPPORT_END(psdr::Emitter) 40 | -------------------------------------------------------------------------------- /include/psdr/emitter/envmap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "emitter.h" 7 | 8 | namespace psdr 9 | { 10 | 11 | PSDR_CLASS_DECL_BEGIN(EnvironmentMap, final, Emitter) 12 | public: 13 | inline EnvironmentMap(const char *file_name) { 14 | m_radiance.load_openexr(file_name); 15 | } 16 | 17 | void configure() override; 18 | void setposition(Vector3fD p) override; 19 | 20 | inline void set_transform(const Matrix4fD &mat) { 21 | m_to_world_left = mat; 22 | m_ready = false; 23 | } 24 | 25 | SpectrumC eval(const IntersectionC &its, MaskC active = true) const override; 26 | SpectrumD eval(const IntersectionD &its, MaskD active = true) const override; 27 | 28 | template 29 | Spectrum eval_direction(const Vector3f &wi, Mask active = true) const; 30 | 31 | PositionSampleC sample_position(const Vector3fC &ref_p, const Vector2fC &sample2, MaskC active = true) const override; 32 | PositionSampleD sample_position(const Vector3fD &ref_p, const Vector2fD &sample2, MaskD active = true) const override; 33 | 34 | FloatC sample_position_pdf(const Vector3fC &ref_p, const IntersectionC &its, MaskC active = true) const override; 35 | FloatD sample_position_pdf(const Vector3fD &ref_p, const IntersectionD &its, MaskD active = true) const override; 36 | 37 | std::string to_string() const override; 38 | 39 | Bitmap3fD m_radiance; // stored in latitude-longitude format 40 | FloatD m_scale = 1.f; 41 | 42 | Matrix4fD m_to_world_raw = identity(), 43 | m_to_world_left = identity(), 44 | m_to_world, m_from_world; 45 | 46 | Vector3fC m_lower, m_upper; 47 | HyperCubeDistribution2f m_cell_distrb; 48 | 49 | ENOKI_PINNED_OPERATOR_NEW(FloatD) 50 | 51 | protected: 52 | template 53 | PositionSample __sample_position(const Vector3f &ref_p, const Vector2f&, Mask) const; 54 | 55 | std::pair sample_direction(Vector2fC&) const; 56 | 57 | template 58 | Float __sample_position_pdf(const Vector3f &, const Intersection &, Mask) const; 59 | PSDR_CLASS_DECL_END(AreaLight) 60 | 61 | } // namespace psdr 62 | -------------------------------------------------------------------------------- /include/psdr/emitter/point.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "emitter.h" 5 | #include 6 | 7 | namespace psdr 8 | { 9 | 10 | PSDR_CLASS_DECL_BEGIN(PointLight, final, Emitter) 11 | public: 12 | PointLight(const ScalarVector3f &power, const Matrix4fD trans) : m_power(power) { 13 | m_position = transform_pos(trans, zero()); 14 | } 15 | 16 | void configure() override; 17 | void setposition(Vector3fD p) override; 18 | 19 | 20 | SpectrumC eval(const IntersectionC &its, MaskC active = true) const override; 21 | SpectrumD eval(const IntersectionD &its, MaskD active = true) const override; 22 | 23 | PositionSampleC sample_position(const Vector3fC &ref_p, const Vector2fC &sample2, MaskC active = true) const override; 24 | PositionSampleD sample_position(const Vector3fD &ref_p, const Vector2fD &sample2, MaskD active = true) const override; 25 | 26 | FloatC sample_position_pdf(const Vector3fC &ref_p, const IntersectionC &its, MaskC active = true) const override; 27 | FloatD sample_position_pdf(const Vector3fD &ref_p, const IntersectionD &its, MaskD active = true) const override; 28 | 29 | std::string to_string() const override; 30 | 31 | SpectrumD m_power; 32 | Vector3fD m_position; 33 | 34 | ENOKI_PINNED_OPERATOR_NEW(FloatD) 35 | 36 | protected: 37 | template 38 | PositionSample __sample_position(const Vector3f &ref_p, const Vector2f&, Mask) const; 39 | 40 | template 41 | Float __sample_position_pdf(const Vector3f&, const Intersection&, Mask) const; 42 | 43 | PSDR_CLASS_DECL_END(PointLight) 44 | 45 | } // namespace psdr 46 | -------------------------------------------------------------------------------- /include/psdr/fwd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace psdr 4 | { 5 | // Core classes 6 | 7 | template struct Frame_; 8 | template 9 | using Frame = Frame_>; 10 | using FrameC = Frame; 11 | using FrameD = Frame; 12 | 13 | template struct Ray; 14 | using RayC = Ray; 15 | using RayD = Ray; 16 | 17 | template struct Interaction_; 18 | 19 | template 20 | using Interaction = Interaction_>; 21 | using InteractionC = Interaction; 22 | using InteractionD = Interaction; 23 | 24 | 25 | 26 | struct Intersection_OptiX; 27 | struct LayerIntersection; 28 | 29 | // template struct Intersection; 30 | template struct Intersection_; 31 | 32 | template 33 | using Intersection = Intersection_>; 34 | 35 | using IntersectionC = Intersection; 36 | using IntersectionD = Intersection; 37 | 38 | template 39 | using IntersectionArray = Array, 20>; 40 | 41 | // using IntersectionArray = Type; 42 | // using IntersectionArrayC = IntersectionArray; 43 | // using IntersectionArrayD = IntersectionArray; 44 | // using IntersectionVector = Intersections__>; 45 | 46 | struct Sampler; 47 | 48 | struct DiscreteDistribution; 49 | 50 | template struct HyperCubeDistribution; 51 | using HyperCubeDistribution2f = HyperCubeDistribution<2>; 52 | using HyperCubeDistribution3f = HyperCubeDistribution<3>; 53 | 54 | struct MicrofacetDistribution; 55 | 56 | // Sampling records 57 | 58 | template struct SampleRecord_; 59 | template 60 | using SampleRecord = SampleRecord_>; 61 | using SampleRecordC = SampleRecord; 62 | using SampleRecordD = SampleRecord; 63 | 64 | template struct DirectionSample_; 65 | template 66 | using DirectionSample = DirectionSample_>; 67 | using DirectionSampleC = DirectionSample; 68 | using DirectionSampleD = DirectionSample; 69 | 70 | template struct PositionSample_; 71 | template 72 | using PositionSample = PositionSample_>; 73 | using PositionSampleC = PositionSample; 74 | using PositionSampleD = PositionSample; 75 | 76 | template struct BSDFSample_; 77 | template 78 | using BSDFSample = BSDFSample_>; 79 | using BSDFSampleC = BSDFSample; 80 | using BSDFSampleD = BSDFSample; 81 | 82 | // Xi Deng added 83 | // template struct BSSDFSample_; 84 | // template 85 | // using BSSDFSample = BSSDFSample_>; 86 | // using BSSDFSampleC = BSSDFSample; 87 | // using BSSDFSampleD = BSSDFSample; 88 | // Xi Deng added 89 | 90 | template struct SensorDirectSample_; 91 | template 92 | using SensorDirectSample = SensorDirectSample_>; 93 | using SensorDirectSampleC = SensorDirectSample; 94 | using SensorDirectSampleD = SensorDirectSample; 95 | 96 | struct BoundarySegSampleDirect; 97 | 98 | // Main classes 99 | class BSDF; 100 | template 101 | using BSDFArray = Type; 102 | using BSDFArrayC = BSDFArray; 103 | using BSDFArrayD = BSDFArray; 104 | 105 | class Diffuse; 106 | class RoughConductor; 107 | // class Subsurface; 108 | 109 | class Emitter; 110 | template 111 | using EmitterArray = Type; 112 | using EmitterArrayC = EmitterArray; 113 | using EmitterArrayD = EmitterArray; 114 | 115 | class AreaLight; 116 | class EnvironmentMap; 117 | 118 | class Sensor; 119 | class PerspectiveCamera; 120 | 121 | class Mesh; 122 | template 123 | using MeshArray = Type; 124 | using MeshArrayC = MeshArray; 125 | using MeshArrayD = MeshArray; 126 | 127 | class Integrator; 128 | class FieldExtractionIntegrator; 129 | class DirectIntegrator; 130 | class LaserIntegrator; 131 | class ColocateIntegrator; 132 | class OldDirectIntegrator; 133 | class Integrator; 134 | 135 | class Scene_OptiX; 136 | class Scene; 137 | class SceneLoader; 138 | } 139 | -------------------------------------------------------------------------------- /include/psdr/integrator/bdlaser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "integrator.h" 4 | 5 | namespace psdr 6 | { 7 | 8 | PSDR_CLASS_DECL_BEGIN(BDLaserIntegrator, final, Integrator) 9 | public: 10 | BDLaserIntegrator(int bsdf_samples = 1, int light_samples = 1); 11 | virtual ~BDLaserIntegrator(); 12 | 13 | void preprocess_secondary_edges(const Scene &scene, int sensor_id, const ScalarVector4i &reso, int nrounds = 1) override; 14 | 15 | bool m_hide_emitters = false; 16 | 17 | protected: 18 | SpectrumC Li(const Scene &scene, Sampler &sampler, const RayC &ray, MaskC active = true, int sensor_id = 0) const override; 19 | SpectrumD Li(const Scene &scene, Sampler &sampler, const RayD &ray, MaskD active = true, int sensor_id = 0) const override; 20 | 21 | template 22 | Spectrum __Li(const Scene &scene, Sampler &sampler, const Ray &ray, Mask active) const; 23 | 24 | void render_secondary_edges(const Scene &scene, int sensor_id, SpectrumD &result) const override; 25 | 26 | template 27 | std::pair> eval_secondary_edge(const Scene &scene, const Sensor &sensor, const Vector3fC &sample3) const; 28 | 29 | int m_bsdf_samples, m_light_samples; 30 | std::vector m_warpper; 31 | PSDR_CLASS_DECL_END(BDLaserIntegrator) 32 | 33 | } // namespace psdr 34 | -------------------------------------------------------------------------------- /include/psdr/integrator/colocate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "integrator.h" 4 | 5 | namespace psdr 6 | { 7 | 8 | PSDR_CLASS_DECL_BEGIN(ColocateIntegrator, final, Integrator) 9 | public: 10 | ColocateIntegrator(int bsdf_samples = 1, int light_samples = 1); 11 | virtual ~ColocateIntegrator(); 12 | 13 | void preprocess_secondary_edges(const Scene &scene, int sensor_id, const ScalarVector4i &reso, int nrounds = 1) override; 14 | 15 | bool m_hide_emitters = false; 16 | 17 | protected: 18 | SpectrumC Li(const Scene &scene, Sampler &sampler, const RayC &ray, MaskC active = true, int sensor_id=0) const override; 19 | SpectrumD Li(const Scene &scene, Sampler &sampler, const RayD &ray, MaskD active = true, int sensor_id=0) const override; 20 | 21 | template 22 | Spectrum __Li(const Scene &scene, Sampler &sampler, const Ray &ray, Mask active, int sensor_id) const; 23 | 24 | void render_secondary_edges(const Scene &scene, int sensor_id, SpectrumD &result) const override; 25 | 26 | template 27 | std::pair> eval_secondary_edge(const Scene &scene, const Sensor &sensor, const Vector3fC &sample3) const; 28 | 29 | int m_bsdf_samples, m_light_samples; 30 | std::vector m_warpper; 31 | PSDR_CLASS_DECL_END(ColocateIntegrator) 32 | 33 | } // namespace psdr 34 | -------------------------------------------------------------------------------- /include/psdr/integrator/direct.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "integrator.h" 4 | 5 | namespace psdr 6 | { 7 | 8 | PSDR_CLASS_DECL_BEGIN(DirectIntegrator, final, Integrator) 9 | public: 10 | DirectIntegrator(int bsdf_samples = 1, int light_samples = 1); 11 | virtual ~DirectIntegrator(); 12 | 13 | void preprocess_secondary_edges(const Scene &scene, int sensor_id, const ScalarVector4i &reso, int nrounds = 1) override; 14 | 15 | bool m_hide_emitters = false; 16 | 17 | protected: 18 | SpectrumC Li(const Scene &scene, Sampler &sampler, const RayC &ray, MaskC active = true, int sensor_id=0) const override; 19 | SpectrumD Li(const Scene &scene, Sampler &sampler, const RayD &ray, MaskD active = true, int sensor_id=0) const override; 20 | 21 | 22 | IntC _compress(IntC input, MaskC mask) const; 23 | 24 | template 25 | Spectrum __Li(const Scene &scene, Sampler &sampler, const Ray &ray, Mask active) const; 26 | 27 | void render_secondary_edges(const Scene &scene, int sensor_id, SpectrumD &result) const override; 28 | 29 | template 30 | std::pair> eval_secondary_edge(const Scene &scene, const Sensor &sensor, const Vector3fC &sample3) const; 31 | 32 | template 33 | void eval_secondary_edge_bssrdf(const Scene &scene, const IntersectionC &its, const Sensor &sensor, const Vector3fC &sample3, SpectrumD &result) const; 34 | 35 | int m_bsdf_samples, m_light_samples; 36 | std::vector m_warpper; 37 | PSDR_CLASS_DECL_END(DirectIntegrator) 38 | 39 | } // namespace psdr 40 | -------------------------------------------------------------------------------- /include/psdr/integrator/direct_origin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "integrator.h" 4 | 5 | namespace psdr 6 | { 7 | 8 | PSDR_CLASS_DECL_BEGIN(OldDirectIntegrator, final, Integrator) 9 | public: 10 | OldDirectIntegrator(int bsdf_samples = 1, int light_samples = 1); 11 | virtual ~OldDirectIntegrator(); 12 | 13 | void preprocess_secondary_edges(const Scene &scene, int sensor_id, const ScalarVector4i &reso, int nrounds = 1) override; 14 | 15 | bool m_hide_emitters = false; 16 | 17 | protected: 18 | SpectrumC Li(const Scene &scene, Sampler &sampler, const RayC &ray, MaskC active = true, int sensor_id = 0) const override; 19 | SpectrumD Li(const Scene &scene, Sampler &sampler, const RayD &ray, MaskD active = true, int sensor_id = 0) const override; 20 | 21 | template 22 | Spectrum __Li(const Scene &scene, Sampler &sampler, const Ray &ray, Mask active) const; 23 | 24 | void render_secondary_edges(const Scene &scene, int sensor_id, SpectrumD &result) const override; 25 | 26 | template 27 | std::pair> eval_secondary_edge(const Scene &scene, const Sensor &sensor, const Vector3fC &sample3) const; 28 | 29 | int m_bsdf_samples, m_light_samples; 30 | std::vector m_warpper; 31 | PSDR_CLASS_DECL_END(OldDirectIntegrator) 32 | 33 | } // namespace psdr 34 | -------------------------------------------------------------------------------- /include/psdr/integrator/field.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "integrator.h" 4 | 5 | namespace psdr 6 | { 7 | 8 | PSDR_CLASS_DECL_BEGIN(FieldExtractionIntegrator, final, Integrator) 9 | public: 10 | FieldExtractionIntegrator(const char *field); 11 | 12 | std::string m_field; 13 | 14 | protected: 15 | SpectrumC Li(const Scene &scene, Sampler &sampler, const RayC &ray, MaskC active = true, int sensor_id = 0) const override; 16 | SpectrumD Li(const Scene &scene, Sampler &sampler, const RayD &ray, MaskD active = true, int sensor_id = 0) const override; 17 | 18 | template 19 | Spectrum __Li(const Scene &scene, const Ray &ray, Mask active) const; 20 | PSDR_CLASS_DECL_END(FieldExtractionIntegrator) 21 | 22 | } // namespace psdr 23 | -------------------------------------------------------------------------------- /include/psdr/integrator/integrator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace psdr 7 | { 8 | 9 | PSDR_CLASS_DECL_BEGIN(Integrator,, Object) 10 | public: 11 | virtual ~Integrator() {} 12 | 13 | SpectrumC renderC(const Scene &scene, int sensor_id = 0) const; 14 | SpectrumD renderD(const Scene &scene, int sensor_id = 0) const; 15 | 16 | virtual void preprocess_secondary_edges(const Scene &scene, int sensor_id, const ScalarVector4i &reso, int nrounds = 1) {} 17 | 18 | protected: 19 | virtual SpectrumC Li(const Scene &scene, Sampler &sampler, const RayC &ray, MaskC active = true, int sensor_id=0) const = 0; 20 | virtual SpectrumD Li(const Scene &scene, Sampler &sampler, const RayD &ray, MaskD active = true, int sensor_id=0) const = 0; 21 | 22 | virtual void render_primary_edges(const Scene &scene, int sensor_id, SpectrumD &result) const; 23 | 24 | virtual void render_secondary_edges(const Scene &scene, int sensor_id, SpectrumD &result) const {} 25 | 26 | template 27 | Spectrum __render(const Scene &scene, int sensor_id) const; 28 | PSDR_CLASS_DECL_END(SamplingIntegrator) 29 | 30 | } // namespace psdr 31 | -------------------------------------------------------------------------------- /include/psdr/integrator/laser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "integrator.h" 4 | 5 | namespace psdr 6 | { 7 | 8 | PSDR_CLASS_DECL_BEGIN(LaserIntegrator, final, Integrator) 9 | public: 10 | LaserIntegrator(int bsdf_samples = 1, int light_samples = 1); 11 | virtual ~LaserIntegrator(); 12 | 13 | void preprocess_secondary_edges(const Scene &scene, int sensor_id, const ScalarVector4i &reso, int nrounds = 1) override; 14 | 15 | bool m_hide_emitters = false; 16 | 17 | protected: 18 | SpectrumC Li(const Scene &scene, Sampler &sampler, const RayC &ray, MaskC active = true, int sensor_id = 0) const override; 19 | SpectrumD Li(const Scene &scene, Sampler &sampler, const RayD &ray, MaskD active = true, int sensor_id = 0) const override; 20 | 21 | template 22 | Spectrum __Li(const Scene &scene, Sampler &sampler, const Ray &ray, Mask active) const; 23 | 24 | void render_secondary_edges(const Scene &scene, int sensor_id, SpectrumD &result) const override; 25 | 26 | template 27 | std::pair> eval_secondary_edge(const Scene &scene, const Sensor &sensor, const Vector3fC &sample3) const; 28 | 29 | int m_bsdf_samples, m_light_samples; 30 | std::vector m_warpper; 31 | PSDR_CLASS_DECL_END(LaserIntegrator) 32 | 33 | } // namespace psdr 34 | -------------------------------------------------------------------------------- /include/psdr/macros.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef _WIN32 4 | # define likely(x) (x) 5 | # define unlikely(x) (x) 6 | #else 7 | # define likely(x) __builtin_expect((x),1) 8 | # define unlikely(x) __builtin_expect((x),0) 9 | #endif 10 | 11 | // #define PSDR_OPTIX_DEBUG 12 | #define PSDR_MESH_ENABLE_1D_VERTEX_OFFSET 13 | // #define PSDR_PRIMARY_EDGE_VIS_CHECK 14 | 15 | 16 | #define PSDR_CLASS_DECL_BEGIN(_class_, _mode_, _parent_) \ 17 | class _class_ _mode_ : public _parent_ { 18 | 19 | 20 | #define PSDR_CLASS_DECL_END(_class_) \ 21 | public: \ 22 | virtual std::string type_name() const override { \ 23 | return #_class_; \ 24 | } \ 25 | }; 26 | 27 | 28 | #define PSDR_IMPORT_BASE_HELPER(...) Base, ##__VA_ARGS__ 29 | 30 | #define PSDR_IMPORT_BASE(Name, ...) \ 31 | using Base = Name; \ 32 | ENOKI_USING_MEMBERS(PSDR_IMPORT_BASE_HELPER(__VA_ARGS__)) 33 | -------------------------------------------------------------------------------- /include/psdr/object.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Object Base Class 4 | 5 | class Object { 6 | public: 7 | virtual ~Object() {} 8 | 9 | virtual std::string type_name() const = 0; 10 | 11 | void LOG(const char *msg) const { 12 | std::cout << "[" << type_name() << "] " << msg << std::endl; 13 | } 14 | 15 | virtual std::string to_string() const { 16 | std::stringstream oss; 17 | oss << type_name(); 18 | if ( m_id != "" ) oss << "[id=" << m_id << "]"; 19 | return oss.str(); 20 | } 21 | 22 | std::string m_id = ""; 23 | }; 24 | -------------------------------------------------------------------------------- /include/psdr/optix/ptx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(_WIN32) || defined(_WIN64) 4 | # define PSDRAPI __declspec(dllimport) 5 | # define PSDRCLASSAPI 6 | #else 7 | # define PSDRAPI __attribute__ ((visibility ("default"))) 8 | # define PSDRCLASSAPI PSDRAPI 9 | #endif 10 | 11 | #define OPTIX_SAMPLE_NAME_STRINGIFY2(name) #name 12 | #define OPTIX_SAMPLE_NAME_STRINGIFY(name) OPTIX_SAMPLE_NAME_STRINGIFY2(name) 13 | #define OPTIX_SAMPLE_NAME OPTIX_SAMPLE_NAME_STRINGIFY(OPTIX_SAMPLE_NAME_DEFINE) 14 | 15 | namespace psdr 16 | { 17 | 18 | PSDRAPI const char* getPtxString(const char* sample, const char* filename, const char** log = NULL ); 19 | 20 | } // end namespace PSDR 21 | -------------------------------------------------------------------------------- /include/psdr/psdr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | constexpr int PSDR_NUM_CHANNELS = 3; 9 | 10 | #include "macros.h" 11 | #include "types.h" 12 | #include "constants.h" 13 | #include "fwd.h" 14 | #include "macros.h" 15 | #include "object.h" 16 | #include "utils.h" 17 | -------------------------------------------------------------------------------- /include/psdr/scene/scene.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace psdr 9 | { 10 | 11 | typedef struct LayerIntersection { 12 | void reserve(int64_t size, int64_t depth=0); 13 | int64_t size; 14 | int64_t depth; 15 | Vector2fD uvs; 16 | IntC numIntersections; 17 | IntC shape_ids; 18 | } LayerIntersection; 19 | 20 | PSDR_CLASS_DECL_BEGIN(Scene, final, Object) 21 | friend class SceneLoader; 22 | 23 | public: 24 | using ParamMap = std::unordered_map; 25 | 26 | Scene(); 27 | ~Scene() override; 28 | 29 | void load_file(const char *file_name, bool auto_configure = true); 30 | void load_string(const char *scene_xml, bool auto_configure = true); 31 | 32 | void configure(); 33 | bool is_ready() const; 34 | 35 | void setseed(const int seed) { 36 | m_seed = seed; 37 | // m_samplers[0].seed(m_seed); 38 | } 39 | 40 | void setlightposition(Vector3fD p){ 41 | m_emitters[0]->setposition(p); 42 | } 43 | 44 | template 45 | Intersection ray_intersect(const Ray &ray, Mask active = true, TriangleInfoD *out_info = nullptr) const; 46 | 47 | template 48 | Intersection ray_all_intersect(const Ray &ray, Mask active, const Vector8f &sample, const int depth, TriangleInfoD *out_info = nullptr) const; 49 | 50 | template 51 | LayerIntersection ray_all_layer(const Ray &ray, Mask active, const int depth) const; 52 | 53 | template 54 | Spectrum Lenv(const Vector3f &wi, Mask active = true) const; 55 | 56 | template 57 | PositionSample sample_emitter_position(const Vector3f &ref_p, const Vector2f &sample, Mask active = true) const; 58 | 59 | template 60 | Float emitter_position_pdf(const Vector3f &ref_p, const Intersection &its, Mask active = true) const; 61 | 62 | BoundarySegSampleDirect sample_boundary_segment_direct(const Vector3fC &sample3, MaskC active = true) const; 63 | 64 | std::string to_string() const override; 65 | 66 | int m_num_sensors; 67 | int m_seed = 0; 68 | std::vector m_sensors; 69 | 70 | std::vector m_emitters; 71 | EnvironmentMap *m_emitter_env; 72 | EmitterArrayD m_emitters_cuda; 73 | DiscreteDistribution *m_emitters_distrb; 74 | 75 | std::vector m_bsdfs; 76 | 77 | int m_num_meshes; 78 | std::vector m_meshes; 79 | MeshArrayD m_meshes_cuda; 80 | 81 | // Scene bounding box 82 | Vector3fC m_lower, m_upper; 83 | 84 | ParamMap m_param_map; 85 | 86 | RenderOption m_opts; 87 | mutable Sampler *m_samplers; 88 | 89 | protected: 90 | TriangleInfoD m_triangle_info; 91 | TriangleUVD m_triangle_uv; 92 | MaskD m_triangle_face_normals; 93 | bool m_has_bound_mesh; 94 | 95 | SecondaryEdgeInfo m_sec_edge_info; 96 | DiscreteDistribution *m_sec_edge_distrb; 97 | 98 | bool m_loaded; 99 | Scene_OptiX *m_optix; 100 | 101 | PSDR_CLASS_DECL_END(Scene) 102 | 103 | } // namespace psdr 104 | -------------------------------------------------------------------------------- /include/psdr/scene/scene_loader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace pugi 6 | { 7 | class xml_document; 8 | class xml_node; 9 | } // namespace pugi 10 | 11 | 12 | namespace psdr 13 | { 14 | 15 | class SceneLoader { 16 | public: 17 | static void load_from_file(const char *file_name, Scene &scene); 18 | static void load_from_string(const char *scene_xml, Scene &scene); 19 | 20 | protected: 21 | static void load_scene(const pugi::xml_document &doc, Scene &scene); 22 | static void load_sensor(const pugi::xml_node &node, Scene &scene); 23 | static void load_emitter(const pugi::xml_node &node, Scene &scene); 24 | static void load_bsdf(const pugi::xml_node &node, Scene &scene); 25 | static void load_shape(const pugi::xml_node &node, Scene &scene); 26 | }; 27 | 28 | } // namespace psdr 29 | -------------------------------------------------------------------------------- /include/psdr/scene/scene_optix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct PathTracerState; 6 | 7 | namespace psdr 8 | { 9 | 10 | struct Intersection_OptiX { 11 | void reserve(int64_t size, int64_t depth=0); 12 | 13 | int64_t m_size = 0; 14 | int64_t m_depth = 0; 15 | IntC triangle_id; 16 | IntC shape_id; 17 | Vector2fC uv; 18 | //* xi deng added 19 | IntC numIntersections; 20 | IntC triangle_ids; 21 | IntC shape_ids; 22 | Vector2fC uvs; 23 | 24 | }; 25 | 26 | 27 | class Scene_OptiX { 28 | friend class Scene; 29 | //friend std::unique_ptr std::make_unique(); 30 | 31 | public: 32 | ~Scene_OptiX(); 33 | 34 | protected: 35 | Scene_OptiX(); 36 | void configure(const std::vector &meshes); 37 | bool is_ready() const; 38 | 39 | template 40 | Vector2i ray_intersect(const Ray &ray, Mask &active) const; 41 | 42 | template 43 | Vector3i ray_all_intersect(const Ray &ray, Mask &active, const Vector8f &sample, const int depth) const; 44 | 45 | template 46 | Vector2i ray_all_layer(const Ray &ray, Mask &active, const int depth) const; 47 | 48 | PathTracerState *m_accel; 49 | mutable Intersection_OptiX m_its; 50 | // std::vector m_buildInput; 51 | // std::vector vertex_buffer_ptrs(num_meshes); 52 | }; 53 | 54 | } // namespace psdr 55 | -------------------------------------------------------------------------------- /include/psdr/sensor/perspective.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "sensor.h" 5 | 6 | namespace psdr 7 | { 8 | 9 | PSDR_CLASS_DECL_BEGIN(PerspectiveCamera, final, Sensor) 10 | public: 11 | PerspectiveCamera(float fov_x, float near, float far) : m_fov_x(fov_x), m_near_clip(near), m_far_clip(far) {} 12 | 13 | void configure() override; 14 | 15 | RayC sample_primary_ray(const Vector2fC &samples) const override; 16 | RayD sample_primary_ray(const Vector2fD &samples) const override; 17 | 18 | SensorDirectSampleC sample_direct(const Vector3fC &p) const override; 19 | 20 | PrimaryEdgeSample sample_primary_edge(const FloatC &sample1) const override; 21 | 22 | std::string to_string() const override; 23 | 24 | float m_fov_x, 25 | m_near_clip, 26 | m_far_clip; 27 | 28 | Matrix4fD m_sample_to_camera, m_camera_to_sample, 29 | m_world_to_sample, m_sample_to_world; 30 | 31 | Vector3fD m_camera_pos, m_camera_dir; 32 | FloatD m_inv_area; 33 | PSDR_CLASS_DECL_END(PerspectiveCamera) 34 | 35 | } // namespace psdr 36 | -------------------------------------------------------------------------------- /include/psdr/sensor/sensor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace psdr 9 | { 10 | 11 | template 12 | struct SensorDirectSample_ : public SampleRecord_ { 13 | PSDR_IMPORT_BASE(SampleRecord_, ad, pdf, is_valid) 14 | 15 | Vector2f q; 16 | Int pixel_idx; 17 | Float sensor_val; 18 | 19 | ENOKI_DERIVED_STRUCT(SensorDirectSample_, Base, 20 | ENOKI_BASE_FIELDS(pdf, is_valid), 21 | ENOKI_DERIVED_FIELDS(q, pixel_idx, sensor_val) 22 | ) 23 | }; 24 | 25 | PSDR_CLASS_DECL_BEGIN(Sensor,, Object) 26 | public: 27 | virtual ~Sensor() override {} 28 | 29 | virtual void configure(); 30 | 31 | virtual RayC sample_primary_ray(const Vector2fC &samples) const = 0; 32 | virtual RayD sample_primary_ray(const Vector2fD &samples) const = 0; 33 | 34 | virtual SensorDirectSampleC sample_direct(const Vector3fC &p) const = 0; 35 | 36 | virtual PrimaryEdgeSample sample_primary_edge(const FloatC &sample1) const = 0; 37 | 38 | ScalarVector2i m_resolution; 39 | ScalarVector2i m_cropsize; 40 | ScalarVector2i m_cropoffset; 41 | 42 | float m_aspect; 43 | 44 | Matrix4fD m_to_world = identity(); 45 | 46 | const Scene *m_scene = nullptr; 47 | 48 | // Properties for primary edge sampling 49 | 50 | bool m_enable_edges = false; 51 | PrimaryEdgeInfo m_edge_info; 52 | DiscreteDistribution m_edge_distrb; 53 | PSDR_CLASS_DECL_END(Sensor) 54 | 55 | } // namespace psdr 56 | 57 | ENOKI_STRUCT_SUPPORT(psdr::SensorDirectSample_, pdf, is_valid, q, pixel_idx, sensor_val) 58 | 59 | ENOKI_CALL_SUPPORT_BEGIN(psdr::Sensor) 60 | ENOKI_CALL_SUPPORT_METHOD(sample_primary_ray) 61 | ENOKI_CALL_SUPPORT_METHOD(sample_primary_edge) 62 | ENOKI_CALL_SUPPORT_END(psdr::Sensor) 63 | -------------------------------------------------------------------------------- /include/psdr/shape/mesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace psdr 8 | { 9 | 10 | PSDR_CLASS_DECL_BEGIN(Mesh, final, Object) 11 | public: 12 | Mesh() = default; 13 | ~Mesh() override; 14 | 15 | 16 | void load(const char *fname, bool verbose = false); 17 | 18 | // xi deng added for multilayer bssrdf 19 | void instance(const Mesh *mesh, float offset=0.01f); 20 | // xi deng added for multilayer bssrdf 21 | void configure(); 22 | void prepare_optix_buffers(); 23 | 24 | inline void set_transform(const Matrix4fD &mat, bool set_left = true) { 25 | if ( set_left ) { 26 | m_to_world_left = mat; 27 | } else { 28 | m_to_world_right = mat; 29 | } 30 | m_ready = false; 31 | } 32 | 33 | inline void append_transform(const Matrix4fD &mat, bool append_left = true) { 34 | if ( append_left ) { 35 | m_to_world_left = mat*m_to_world_left; 36 | } else { 37 | m_to_world_right *= mat; 38 | } 39 | m_ready = false; 40 | } 41 | 42 | #ifdef PSDR_MESH_ENABLE_1D_VERTEX_OFFSET 43 | void shift_vertices(); 44 | #endif 45 | 46 | // void offset_vertices(float depth); 47 | 48 | PositionSampleC sample_position(const Vector2fC &sample2, MaskC active = true) const; 49 | PositionSampleD sample_position(const Vector2fD &sample2, MaskD active = true) const; 50 | 51 | FloatC sample_position_pdf(const IntersectionC &its, MaskC active = true) const; 52 | FloatD sample_position_pdf(const IntersectionD &its, MaskD active = true) const; 53 | 54 | void dump(const char *fname) const; 55 | 56 | std::string to_string() const override; 57 | 58 | bool m_ready = false; 59 | 60 | bool m_use_face_normals = false, 61 | m_has_uv = false; 62 | 63 | bool m_enable_edges = true; // Indicates if the mesh creates primiary and secondary edges 64 | 65 | Matrix4fD m_to_world_raw = identity(), 66 | m_to_world_left = identity(), 67 | m_to_world_right = identity(); 68 | 69 | const BSDF* m_bsdf = nullptr; 70 | const Emitter* m_emitter = nullptr; 71 | 72 | int m_num_vertices = 0, 73 | m_num_faces = 0; 74 | 75 | Vector3fD m_vertex_positions_raw, 76 | m_vertex_normals_raw; 77 | 78 | #ifdef PSDR_MESH_ENABLE_1D_VERTEX_OFFSET 79 | FloatD m_vertex_offset; 80 | #endif 81 | Vector2fD m_vertex_uv; 82 | 83 | // When PSDR_MESH_ENABLE_1D_VERTEX_OFFSET is defined: 84 | // m_vertex_positions = m_to_world * (m_vertex_positions_raw + 85 | // m_vertex_offset * m_vertex_normals_raw) 86 | // Otherwise: 87 | // m_vertex_positions = m_to_world * m_vertex_positions_raw 88 | // 89 | Vector3fD m_vertex_positions; 90 | 91 | Vector3iD m_face_indices, 92 | m_face_uv_indices; 93 | 94 | // 0, 1: storing vertex indices of the end points 95 | // 2, 3: storing face indices sharing each edge 96 | // 4 : storing the third vertex of face with index stored in [2] 97 | Vectori<5, true> m_edge_indices; 98 | 99 | float m_total_area, m_inv_total_area; 100 | int m_layer_count = -1; // -1 for no layers, 0 for layers' mesh, > 0 for the outmost surface 101 | 102 | // For position sampling 103 | DiscreteDistribution *m_face_distrb = nullptr; 104 | 105 | // Temporary triangle info for Scene::configure() 106 | TriangleInfoD *m_triangle_info = nullptr; 107 | TriangleUVD *m_triangle_uv = nullptr; 108 | SecondaryEdgeInfo *m_sec_edge_info = nullptr; 109 | 110 | // For OptiX ray tracing 111 | FloatC m_vertex_buffer; 112 | IntC m_face_buffer; 113 | 114 | ENOKI_PINNED_OPERATOR_NEW(FloatD) 115 | 116 | protected: 117 | template 118 | PositionSample __sample_position(const Vector2f&, Mask) const; 119 | PSDR_CLASS_DECL_END(Mesh) 120 | 121 | } // namespace psdr 122 | 123 | ENOKI_CALL_SUPPORT_BEGIN(psdr::Mesh) 124 | ENOKI_CALL_SUPPORT_GETTER(bsdf, m_bsdf) 125 | ENOKI_CALL_SUPPORT_GETTER(emitter, m_emitter) 126 | ENOKI_CALL_SUPPORT_METHOD(sample_position) 127 | ENOKI_CALL_SUPPORT_METHOD(sample_position_pdf) 128 | ENOKI_CALL_SUPPORT_END(psdr::Mesh) 129 | -------------------------------------------------------------------------------- /include/pugixml/pugiconfig.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * pugixml parser - version 1.10 3 | * -------------------------------------------------------- 4 | * Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 5 | * Report bugs and download new versions at https://pugixml.org/ 6 | * 7 | * This library is distributed under the MIT License. See notice at the end 8 | * of this file. 9 | * 10 | * This work is based on the pugxml parser, which is: 11 | * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) 12 | */ 13 | 14 | #ifndef HEADER_PUGICONFIG_HPP 15 | #define HEADER_PUGICONFIG_HPP 16 | 17 | // Uncomment this to enable wchar_t mode 18 | // #define PUGIXML_WCHAR_MODE 19 | 20 | // Uncomment this to enable compact mode 21 | // #define PUGIXML_COMPACT 22 | 23 | // Uncomment this to disable XPath 24 | // #define PUGIXML_NO_XPATH 25 | 26 | // Uncomment this to disable STL 27 | // #define PUGIXML_NO_STL 28 | 29 | // Uncomment this to disable exceptions 30 | // #define PUGIXML_NO_EXCEPTIONS 31 | 32 | // Set this to control attributes for public classes/functions, i.e.: 33 | // #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL 34 | // #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL 35 | // #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall 36 | // In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead 37 | 38 | // Tune these constants to adjust memory-related behavior 39 | // #define PUGIXML_MEMORY_PAGE_SIZE 32768 40 | // #define PUGIXML_MEMORY_OUTPUT_STACK 10240 41 | // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 42 | 43 | // Uncomment this to switch to header-only version 44 | #define PUGIXML_HEADER_ONLY 45 | 46 | // Uncomment this to enable long long support 47 | // #define PUGIXML_HAS_LONG_LONG 48 | 49 | #endif 50 | 51 | /** 52 | * Copyright (c) 2006-2019 Arseny Kapoulkine 53 | * 54 | * Permission is hereby granted, free of charge, to any person 55 | * obtaining a copy of this software and associated documentation 56 | * files (the "Software"), to deal in the Software without 57 | * restriction, including without limitation the rights to use, 58 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 59 | * copies of the Software, and to permit persons to whom the 60 | * Software is furnished to do so, subject to the following 61 | * conditions: 62 | * 63 | * The above copyright notice and this permission notice shall be 64 | * included in all copies or substantial portions of the Software. 65 | * 66 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 67 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 68 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 69 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 70 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 71 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 72 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 73 | * OTHER DEALINGS IN THE SOFTWARE. 74 | */ 75 | -------------------------------------------------------------------------------- /setpath.sh: -------------------------------------------------------------------------------- 1 | # 2 | # This script adds Mitsuba to the current path. 3 | # It works with both Bash and Zsh. 4 | # 5 | # NOTE: this script must be sourced and not run, i.e. 6 | # . setpath.sh for Bash 7 | # source setpath.sh for Zsh or Bash 8 | # 9 | 10 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then 11 | echo "The setpath.sh script must be sourced, not executed. In other words, run\n" 12 | echo "$ source setpath.sh\n" 13 | echo "If you wish to use the Mitsuba Python bindings, you should also specify" 14 | echo "your Python version /before/ sourcing setpath.sh, e.g.\n" 15 | echo "$ export PSDRPHY_VER=3.3" 16 | echo "$ source setpath.sh" 17 | exit 0 18 | fi 19 | 20 | if [ "$BASH_VERSION" ]; then 21 | PSDR_DIR=$(dirname "$BASH_SOURCE") 22 | export PSDR_DIR=$(builtin cd "$PSDR_DIR"; builtin pwd) 23 | elif [ "$ZSH_VERSION" ]; then 24 | export PSDR_DIR=$(dirname "$0:A") 25 | fi 26 | 27 | if [ "$PSDRPHY_VER" ]; then 28 | pyver=$PSDRPHY_VER 29 | else 30 | pyver=`python --version 2>&1 | grep -oE '([[:digit:]].[[:digit:]])' | head -n1` 31 | fi 32 | 33 | if [[ "$(uname)" == 'Darwin' ]]; then 34 | export PYTHONPATH="$PSDR_DIR/build/lib:$PSDR_DIR/ext/enoki/build:$PYTHONPATH" 35 | else 36 | export PYTHONPATH="$PSDR_DIR/build/lib:$PSDR_DIR/ext/enoki/build:$PYTHONPATH" 37 | fi 38 | unset pyver 39 | 40 | if [[ "$(uname)" == 'Darwin' ]]; then 41 | export PATH="$PSDR_DIR/build:$PSDR_DIR/ext/enoki/build:$PATH" 42 | else 43 | export LD_LIBRARY_PATH="$PSDR_DIR/build/lib:$PSDR_DIR/ext/enoki/build:$LD_LIBRARY_PATH" 44 | export PATH="$PSDR_DIR/build:$PSDR_DIR/ext/enoki/build:$PATH" 45 | fi 46 | -------------------------------------------------------------------------------- /src/bsdf/bssdf.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace psdr { 5 | SpectrumC BSSDF::eval(const IntersectionC &its, const Vector3fC &wo, const Vector3fC &po, MaskC active) const { 6 | return SpectrumC(1.0f);//__S(its, wo, po); 7 | } 8 | 9 | SpectrumD BSSDF::eval(const IntersectionD &its, const Vector3fD &wo, const Vector3fD &po, MaskD active) const { 10 | return SpectrumD(1.0f);//__S(its, wo, po); 11 | } 12 | 13 | BSSDFSampleC BSSDF::sample(const IntersectionC &its, const Vector3fC &sampleP, MaskC active) const { 14 | return __samplePos(its, sampleP, active); 15 | } 16 | 17 | BSSDFSampleD BSSDF::sample(const IntersectionD &its, const Vector3fD &sampleP, MaskD active) const { 18 | return __samplePos(its, sampleP, active); 19 | } 20 | 21 | FloatC BSSDF::pdfPo(const IntersectionC &its, const Vector3fC &po, MaskC active) const { 22 | return 1.0; 23 | } 24 | 25 | FloatD BSSDF::pdfPo(const IntersectionD &its, const Vector3fD &po, MaskD active) const { 26 | return 1.0; 27 | } 28 | 29 | template 30 | BSSDFSample BSSDF::__samplePos(const Intersection &its, const Vector3f &sample, Mask active) const { 31 | // Choose projection axis for BSSRDF sampling 32 | // Choose Spectral channel for BSSRDF sampling 33 | // Sample BSSRDF profile in polar coordinates 34 | // Compute BSSRDF profile bounds and intersection height 35 | // Compute BSSRDF sampling ray segment 36 | // Intersect BSSRDF sampling ray against the scene geometry 37 | // Randomly choose one of several intersections during BSSRDF sampling 38 | // Compute sample PDF and return the spatial BSSRDF term Sp 39 | Float cos_theta_i = Frame::cos_theta(its.wi); 40 | BSSDFSample bs; 41 | 42 | bs.po = warp::square_to_cosine_hemisphere(tail<2>(sample)); 43 | bs.pdf = warp::square_to_cosine_hemisphere_pdf(bs.po); 44 | bs.is_valid = active && (cos_theta_i > 0.f); 45 | return bs; 46 | } 47 | } -------------------------------------------------------------------------------- /src/bsdf/diffuse.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace psdr 6 | { 7 | 8 | Diffuse::Diffuse(const char *refl_file) : m_reflectance(refl_file) {} 9 | 10 | 11 | Diffuse::Diffuse(const Bitmap3fD &reflectance) : m_reflectance(reflectance) {} 12 | 13 | 14 | SpectrumC Diffuse::eval(const IntersectionC &its, const Vector3fC &wo, MaskC active) const { 15 | return __eval(its, wo, active); 16 | } 17 | 18 | 19 | SpectrumD Diffuse::eval(const IntersectionD &its, const Vector3fD &wo, MaskD active) const { 20 | return __eval(its, wo, active); 21 | } 22 | 23 | 24 | // Begin: Xi Deng added to support bssrdf 25 | SpectrumC Diffuse::eval(const IntersectionC &its, const BSDFSampleC &bs, MaskC active) const { 26 | // Vector3fC wo = its.sh_frame.to_world(bs.wo); 27 | return __eval(its, bs.wo, active); 28 | } 29 | 30 | 31 | SpectrumD Diffuse::eval(const IntersectionD &its, const BSDFSampleD &bs, MaskD active) const { 32 | // Vector3fD wo = its.sh_frame.to_world(bs.wo); 33 | return __eval(its, bs.wo, active); 34 | } 35 | 36 | FloatC Diffuse::pdf(const IntersectionC &its, const BSDFSampleC &bs, MaskC active) const { 37 | return __pdf(its, bs.wo, active); 38 | } 39 | 40 | 41 | FloatD Diffuse::pdf(const IntersectionD &its, const BSDFSampleD &bs, MaskD active) const { 42 | return __pdf(its, bs.wo, active); 43 | } 44 | 45 | // 46 | 47 | 48 | template 49 | Spectrum Diffuse::__eval(const Intersection &its, const Vector3f &wo, Mask active) const { 50 | Float cos_theta_i = Frame::cos_theta(its.wi), 51 | cos_theta_o = Frame::cos_theta(wo); 52 | 53 | active &= (cos_theta_i > 0.f && cos_theta_o > 0.f); 54 | // std::cout<<"cos_theta_i = "<(m_resolution - 1); 64 | Vector2i pos = floor2int, Vector2f>(uv); 65 | Vector2f w1 = uv - Vector2f(pos), w0 = 1.0f - w1; 66 | pos = min(pos, m_resolution - 2); 67 | 68 | //Int idx = pos.y()*width + pos.x(); 69 | Int idx = fmadd(pos.y(), width, pos.x()); 70 | Value v00, v10, v01, v11; 71 | if constexpr ( ad ) { 72 | v00 = gather(m_data, idx); 73 | v10 = gather(m_data, idx + 1); 74 | v01 = gather(m_data, idx + width); 75 | v11 = gather(m_data, idx + width + 1); 76 | } else { 77 | const ValueC &data = detach(m_data); 78 | v00 = gather(data, idx); 79 | v10 = gather(data, idx + 1); 80 | v01 = gather(data, idx + width); 81 | v11 = gather(data, idx + width + 1); 82 | } 83 | 84 | // Bilinear interpolation 85 | Value v0 = fmadd(w0.x(), v00, w1.x()*v10), 86 | v1 = fmadd(w0.x(), v01, w1.x()*v11); 87 | return fmadd(w0.y(), v0, w1.y()*v1); 88 | } 89 | } 90 | 91 | 92 | // Explicit instantiations 93 | template struct Bitmap<1>; 94 | template struct Bitmap<3>; 95 | 96 | template FloatC Bitmap<1>::eval(Vector2fC, bool) const; 97 | template FloatD Bitmap<1>::eval(Vector2fD, bool) const; 98 | 99 | template Vector3fC Bitmap<3>::eval(Vector2fC, bool) const; 100 | template Vector3fD Bitmap<3>::eval(Vector2fD, bool) const; 101 | 102 | } // namespace psdr 103 | -------------------------------------------------------------------------------- /src/core/bitmap_loader.cpp: -------------------------------------------------------------------------------- 1 | #ifdef _WIN32 2 | # define OPENEXR_DLL 3 | #endif 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace psdr 12 | { 13 | 14 | std::pair BitmapLoader::load_openexr_rgba(const char *file_name) { 15 | Imf::RgbaInputFile file(file_name); 16 | Imath::Box2i dw = file.dataWindow(); 17 | 18 | Imf::Array2D pixels; 19 | 20 | int width = dw.max.x - dw.min.x + 1; 21 | int height = dw.max.y - dw.min.y + 1; 22 | pixels.resizeErase(height, width); 23 | file.setFrameBuffer(&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width); 24 | file.readPixels(dw.min.y, dw.max.y); 25 | 26 | // std::cout << width << ' ' << height << std::endl; 27 | int size = width*height; 28 | 29 | std::vector buf[4]; 30 | for ( int i = 0; i < 4; ++i ) buf[i].resize(size); 31 | 32 | 33 | int offset = 0; 34 | for ( int i = 0; i < height; ++i ) 35 | for ( int j = 0; j < width; ++j ) { 36 | buf[0][offset] = pixels[i][j].r; 37 | buf[1][offset] = pixels[i][j].g; 38 | buf[2][offset] = pixels[i][j].b; 39 | buf[3][offset] = pixels[i][j].a; 40 | ++offset; 41 | } 42 | 43 | return { 44 | Vector4fC( 45 | FloatC::copy(buf[0].data(), size), 46 | FloatC::copy(buf[1].data(), size), 47 | FloatC::copy(buf[2].data(), size), 48 | FloatC::copy(buf[3].data(), size) 49 | ), 50 | ScalarVector2i(width, height) 51 | }; 52 | } 53 | 54 | } // namespace psdr 55 | -------------------------------------------------------------------------------- /src/core/cube_distrb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace psdr 5 | { 6 | 7 | template 8 | void HyperCubeDistribution::set_resolution(const Array &reso) { 9 | if ( m_resolution != reso ) { 10 | Array prod_reso; 11 | prod_reso[ndim - 1] = reso[ndim - 1]; 12 | for ( int i = ndim - 2; i >= 0; --i ) 13 | prod_reso[i] = reso[i]*prod_reso[i + 1]; 14 | PSDR_ASSERT(prod_reso[0] < std::numeric_limits::max()); 15 | 16 | m_num_cells = static_cast(prod_reso[0]); 17 | m_resolution = reso; 18 | m_unit = rcp(Array(reso)); 19 | 20 | IntC &cur = m_cells[ndim - 1]; 21 | cur = arange(m_num_cells); 22 | for ( int i = 0; i < ndim - 1; ++i ) { 23 | int denorm = static_cast(prod_reso[i + 1]); 24 | m_cells[i] = divisor(denorm)(cur); 25 | cur -= m_cells[i]*denorm; 26 | } 27 | m_ready = false; 28 | } 29 | } 30 | 31 | 32 | template 33 | void HyperCubeDistribution::set_mass(const FloatC &pmf) { 34 | PSDR_ASSERT(static_cast(slices(pmf)) == m_num_cells); 35 | m_distrb.init(pmf); 36 | m_ready = true; 37 | } 38 | 39 | 40 | template 41 | FloatC HyperCubeDistribution::sample_reuse(Vectorf &samples) const { 42 | PSDR_ASSERT(m_ready); 43 | auto [idx, pdf] = m_distrb.sample_reuse(samples[ndim - 1]); 44 | samples += gather>(m_cells, idx); 45 | samples *= m_unit; 46 | return pdf*static_cast(m_num_cells); 47 | } 48 | 49 | 50 | template 51 | FloatC HyperCubeDistribution::pdf(const Vectorf &p) const { 52 | PSDR_ASSERT(m_ready); 53 | 54 | auto ip = floor2int, Vectorf>(p*m_resolution); 55 | MaskC valid = (ip[0] >= 0 && ip[0] < m_resolution[0]); 56 | IntC idx = ip[0]; 57 | for ( int i = 1; i < ndim; ++i ) { 58 | valid &= (ip[i] >= 0 && ip[i] < m_resolution[i]); 59 | idx = fmadd(idx, m_resolution[i], ip[i]); 60 | } 61 | return (gather(m_distrb.pmf(), idx)*static_cast(m_num_cells)) & valid; 62 | } 63 | 64 | // Explicit instantiations 65 | template void HyperCubeDistribution<2>::set_resolution(const ScalarVector2i&); 66 | template void HyperCubeDistribution<2>::set_mass(const FloatC&); 67 | template FloatC HyperCubeDistribution<2>::sample_reuse(Vector2fC&) const; 68 | template FloatC HyperCubeDistribution<2>::pdf(const Vector2fC&) const; 69 | 70 | template void HyperCubeDistribution<3>::set_resolution(const ScalarVector3i &reso); 71 | template void HyperCubeDistribution<3>::set_mass(const FloatC &pmf); 72 | template FloatC HyperCubeDistribution<3>::sample_reuse(Vector3fC &samples) const; 73 | template FloatC HyperCubeDistribution<3>::pdf(const Vector3fC&) const; 74 | 75 | } // namespace psdr 76 | -------------------------------------------------------------------------------- /src/core/pmf.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace psdr 5 | { 6 | // pmf probaibility mass function 7 | void DiscreteDistribution::init(const FloatC &pmf) { 8 | m_size = static_cast(slices(pmf)); 9 | m_sum = hsum(pmf); 10 | m_pmf = pmf; 11 | m_cmf = psum(m_pmf); 12 | m_pmf_normalized = pmf/m_sum; 13 | //std::cout << m_cmf << std::endl; 14 | } 15 | 16 | 17 | std::pair DiscreteDistribution::sample(const FloatC &_samples) const { 18 | if ( unlikely(m_size == 1) ) { 19 | return { zero(), full(1.f) }; 20 | } 21 | FloatC samples = _samples*m_sum; 22 | IntC idx = binary_search( 23 | 0, m_size - 1, [&](IntC i) { return gather(m_cmf, i) < samples; } 24 | ); 25 | return { idx, gather(m_pmf, idx)/m_sum }; 26 | } 27 | 28 | 29 | template 30 | std::pair DiscreteDistribution::sample_reuse(Float &samples) const { 31 | if ( unlikely(m_size == 1) ) { 32 | return { zero(), full(1.f) }; 33 | } 34 | samples *= m_sum; 35 | IntC idx; 36 | if constexpr ( ad ) { 37 | idx = binary_search( 38 | 0, m_size - 1, [&](IntC i) { return gather(m_cmf, i) < detach(samples); } 39 | ); 40 | } else { 41 | idx = binary_search( 42 | 0, m_size - 1, [&](IntC i) { return gather(m_cmf, i) < samples; } 43 | ); 44 | } 45 | samples -= gather(m_cmf, idx - 1, idx > 0); 46 | FloatC pmf = gather(m_pmf, idx); 47 | masked(samples, pmf > 0.f) /= pmf; 48 | samples = clamp(samples, 0.f, 1.f); 49 | return { idx, pmf/m_sum }; 50 | } 51 | 52 | // Explicit instantiations 53 | template std::pair DiscreteDistribution::sample_reuse(FloatC&) const; 54 | template std::pair DiscreteDistribution::sample_reuse(FloatD&) const; 55 | 56 | } // namespace psdr 57 | -------------------------------------------------------------------------------- /src/core/sampler.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace psdr 5 | { 6 | 7 | template 8 | uint64_array_t sample_tea_64(UInt32 v0, UInt32 v1, int rounds = 4) { 9 | UIntC sum = 0; 10 | 11 | for ( int i = 0; i < rounds; ++i ) { 12 | sum += 0x9e3779b9; 13 | v0 += (sl<4>(v1) + 0xa341316c) ^ (v1 + sum) ^ (sr<5>(v1) + 0xc8013ea4); 14 | v1 += (sl<4>(v0) + 0xad90777d) ^ (v0 + sum) ^ (sr<5>(v0) + 0x7e95761e); 15 | } 16 | 17 | return uint64_array_t(v0) + sl<32>(uint64_array_t(v1)); 18 | } 19 | 20 | 21 | // std::shared_ptr Sampler::clone() { 22 | // std::shared_ptr sampler = std::make_shared(); 23 | // sampler->m_sample_count = m_sample_count; 24 | // sampler->m_base_seed = m_base_seed; 25 | // return sampler; 26 | // } 27 | 28 | 29 | void Sampler::seed(UInt64C seed_value) { 30 | if ( !m_rng ) 31 | m_rng = std::make_unique(); 32 | 33 | seed_value += m_base_seed; 34 | 35 | UInt64C idx = arange(seed_value.size()); 36 | m_rng->seed(sample_tea_64(seed_value, idx), 37 | sample_tea_64(idx, seed_value)); 38 | 39 | m_sample_count = static_cast(slices(seed_value)); 40 | } 41 | 42 | 43 | template 44 | Float Sampler::next_1d() { 45 | if ( m_rng == nullptr ) 46 | throw Exception("Sampler::seed() must be invoked before using this sampler!"); 47 | else { 48 | if constexpr (ad) { 49 | return FloatD(m_rng->next_float32()); 50 | } else { 51 | return m_rng->next_float32(); 52 | } 53 | } 54 | } 55 | 56 | 57 | // Explicit instanciations 58 | template FloatC Sampler::next_1d(); 59 | template FloatD Sampler::next_1d(); 60 | 61 | } // namespace psdr 62 | -------------------------------------------------------------------------------- /src/emitter/area.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace psdr 8 | { 9 | 10 | void AreaLight::setposition(Vector3fD p){} 11 | 12 | void AreaLight::configure() { 13 | PSDR_ASSERT((m_mesh != nullptr) && m_mesh->m_ready); 14 | PSDR_ASSERT(slices(m_radiance) == 1U); 15 | 16 | m_sampling_weight = m_mesh->m_total_area* 17 | rgb2luminance(detach(m_radiance))[0]; 18 | m_ready = true; 19 | } 20 | 21 | 22 | SpectrumC AreaLight::eval(const IntersectionC &its, MaskC active) const { 23 | PSDR_ASSERT(m_ready); 24 | return select(active && FrameC::cos_theta(its.wi) > 0.f, detach(m_radiance), 0.f); 25 | } 26 | 27 | 28 | SpectrumD AreaLight::eval(const IntersectionD &its, MaskD active) const { 29 | PSDR_ASSERT(m_ready); 30 | return select(active && FrameD::cos_theta(its.wi) > 0.f, m_radiance, 0.f); 31 | } 32 | 33 | 34 | PositionSampleC AreaLight::sample_position(const Vector3fC &ref_p, const Vector2fC &sample2, MaskC active) const { 35 | return __sample_position(sample2, active); 36 | } 37 | 38 | 39 | PositionSampleD AreaLight::sample_position(const Vector3fD &ref_p, const Vector2fD &sample2, MaskD active) const { 40 | return __sample_position(sample2, active); 41 | } 42 | 43 | 44 | template 45 | PositionSample AreaLight::__sample_position(const Vector2f &sample2, Mask active) const { 46 | PSDR_ASSERT(m_ready); 47 | return m_mesh->sample_position(sample2, active); 48 | } 49 | 50 | 51 | FloatC AreaLight::sample_position_pdf(const Vector3fC &ref_p, const IntersectionC &its, MaskC active) const { 52 | return __sample_position_pdf(ref_p, its, active); 53 | } 54 | 55 | 56 | FloatD AreaLight::sample_position_pdf(const Vector3fD &ref_p, const IntersectionD &its, MaskD active) const { 57 | return __sample_position_pdf(ref_p, its, active); 58 | } 59 | 60 | 61 | template 62 | Float AreaLight::__sample_position_pdf(const Vector3f &ref_p, const Intersection &its, Mask active) const { 63 | return m_sampling_weight*its.shape->sample_position_pdf(its, active); 64 | } 65 | 66 | 67 | std::string AreaLight::to_string() const { 68 | std::ostringstream oss; 69 | oss << "AreaLight[radiance = " << m_radiance << ", sampling_weight = " << m_sampling_weight << "]"; 70 | return oss.str(); 71 | } 72 | 73 | } // namespace psdr 74 | -------------------------------------------------------------------------------- /src/emitter/point.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace psdr 8 | { 9 | 10 | void PointLight::configure() { 11 | 12 | } 13 | 14 | void PointLight::setposition(Vector3fD p){m_position = p;} 15 | 16 | SpectrumC PointLight::eval(const IntersectionC &its, MaskC active) const { 17 | FloatC distance = norm(its.p - detach(m_position)); 18 | return detach(m_power) / (4.0f * Pi * distance * distance); 19 | } 20 | 21 | 22 | SpectrumD PointLight::eval(const IntersectionD &its, MaskD active) const { 23 | FloatD distance = norm(its.p - m_position); 24 | return m_power / (4.0f * Pi * distance * distance); 25 | } 26 | 27 | 28 | PositionSampleC PointLight::sample_position(const Vector3fC &ref_p, const Vector2fC &sample2, MaskC active) const { 29 | return __sample_position(ref_p, sample2, active); 30 | } 31 | 32 | 33 | PositionSampleD PointLight::sample_position(const Vector3fD &ref_p, const Vector2fD &sample2, MaskD active) const { 34 | return __sample_position(ref_p, sample2, active); 35 | } 36 | 37 | 38 | template 39 | PositionSample PointLight::__sample_position(const Vector3f &ref_p, const Vector2f&sample2, Mask active) const { 40 | PositionSample result; 41 | if constexpr (ad){ 42 | result.p = Vector3fD(m_position); 43 | result.n = Vector3fD(normalize(ref_p - result.p)); 44 | } else{ 45 | result.p = Vector3fC(detach(m_position)); 46 | result.n = Vector3fC(normalize(ref_p - result.p)); 47 | } 48 | result.J = 1.0f; 49 | result.pdf = 1.0f; 50 | return result; 51 | } 52 | 53 | 54 | FloatC PointLight::sample_position_pdf(const Vector3fC &ref_p, const IntersectionC &its, MaskC active) const { 55 | return FloatC(1.0f); 56 | } 57 | 58 | 59 | FloatD PointLight::sample_position_pdf(const Vector3fD &ref_p, const IntersectionD &its, MaskD active) const { 60 | return FloatD(1.0f); 61 | } 62 | 63 | 64 | template 65 | Float PointLight::__sample_position_pdf(const Vector3f &ref_p, const Intersection &its, Mask active) const { 66 | return Float(1.0f); 67 | } 68 | 69 | 70 | std::string PointLight::to_string() const { 71 | std::ostringstream oss; 72 | oss << "PointLight[power = " << m_power; 73 | return oss.str(); 74 | } 75 | 76 | } // namespace psdr 77 | -------------------------------------------------------------------------------- /src/integrator/field.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace psdr 8 | { 9 | 10 | FieldExtractionIntegrator::FieldExtractionIntegrator(const char *field) : m_field(field) { 11 | PSDR_ASSERT_MSG( 12 | m_field == "silhouette" || 13 | m_field == "position" || 14 | m_field == "depth" || 15 | m_field == "geoNormal" || 16 | m_field == "shNormal" || 17 | m_field == "uv", 18 | "Unsupported field: " + m_field 19 | ); 20 | } 21 | 22 | 23 | SpectrumC FieldExtractionIntegrator::Li(const Scene &scene, Sampler &sampler, const RayC &ray, MaskC active, int sensor_id) const { 24 | return __Li(scene, ray, active); 25 | } 26 | 27 | 28 | SpectrumD FieldExtractionIntegrator::Li(const Scene &scene, Sampler &sampler, const RayD &ray, MaskD active, int sensor_id) const { 29 | return __Li(scene, ray, active); 30 | } 31 | 32 | 33 | template 34 | Spectrum FieldExtractionIntegrator::__Li(const Scene &scene, const Ray &ray, Mask active) const { 35 | Intersection its = scene.ray_intersect(ray); 36 | Vector3f result; 37 | 38 | if ( m_field == "silhouette" ) { 39 | result = full>(1.f); 40 | } else if ( m_field == "position" ) { 41 | result = its.p; 42 | } else if ( m_field == "depth" ) { 43 | result = its.t; 44 | } else if ( m_field == "geoNormal" ) { 45 | result = its.n; 46 | } else if ( m_field == "shNormal" ) { 47 | result = its.sh_frame.n; 48 | } else if ( m_field == "uv" ) { 49 | result = concat(its.uv, 0.f); 50 | } else { 51 | PSDR_ASSERT(false); 52 | } 53 | return result & (active && its.is_valid()); 54 | } 55 | 56 | } // namespace psdr 57 | -------------------------------------------------------------------------------- /src/intersect/AllIntersectRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CUDABuffer.h" 4 | #include "LaunchParams.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace dx { 14 | class AllIntersectRenderer 15 | { 16 | public: 17 | 18 | AllIntersectRenderer(); 19 | 20 | void render(); 21 | 22 | void resize(const int x,const int y); 23 | 24 | void downloadPixels(uint32_t h_pixels[]); 25 | 26 | protected: 27 | 28 | void initOptix(); 29 | 30 | void createContext(); 31 | 32 | void createModule(); 33 | 34 | void createRaygenPrograms(); 35 | 36 | void createMissPrograms(); 37 | 38 | void createHitgraoupProgram(); 39 | 40 | void createPipline(); 41 | 42 | void buildSBT(); 43 | 44 | protected: 45 | CUcontext cudaContext; 46 | CUstream stream; 47 | cudaDeviceProp deviceProps; 48 | 49 | OptixDeviceContext optixContext; 50 | 51 | OptixPipeline pipeline; 52 | OptixPipelineCompileOptions pipelineCompileOptions = {}; 53 | OptixPipelineLinkOptions pipelineLinkOptions = {}; 54 | 55 | OptixModule module; 56 | OptixModuleCompileOptions moduleCompileOptions = {}; 57 | 58 | std::vector raygenPGs; 59 | CUDABuffer raygenRecordsBuffer; 60 | std::vector missPGs; 61 | CUDABuffer missRecordsBuffer; 62 | std::vector hitgroupPGs; 63 | CUDABuffer hitgroupRecordsBuffer; 64 | OptixShaderBindingTable sbt = {}; 65 | 66 | LaunchParams launchParams; 67 | CUDABuffer launchParamsBuffer; 68 | 69 | CUDABuffer colorBuffer; 70 | }; 71 | } // :: dx -------------------------------------------------------------------------------- /src/intersect/CUDABuffer.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2018-2019 Ingo Wald // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #pragma once 18 | 19 | #include "intersect.h" 20 | // common std stuff 21 | #include 22 | #include 23 | #include 24 | 25 | /*! \namespace osc - Optix Siggraph Course */ 26 | namespace dx { 27 | 28 | /*! simple wrapper for creating, and managing a device-side CUDA 29 | buffer */ 30 | struct CUDABuffer { 31 | inline CUdeviceptr d_pointer() const 32 | { return (CUdeviceptr)d_ptr; } 33 | 34 | //! re-size buffer to given number of bytes 35 | void resize(size_t size) 36 | { 37 | if (d_ptr) free(); 38 | alloc(size); 39 | } 40 | 41 | //! allocate to given number of bytes 42 | void alloc(size_t size) 43 | { 44 | assert(d_ptr == nullptr); 45 | this->sizeInBytes = size; 46 | CUDA_CHECK(Malloc( (void**)&d_ptr, sizeInBytes)); 47 | } 48 | 49 | //! free allocated memory 50 | void free() 51 | { 52 | CUDA_CHECK(Free(d_ptr)); 53 | d_ptr = nullptr; 54 | sizeInBytes = 0; 55 | } 56 | 57 | template 58 | void alloc_and_upload(const std::vector &vt) 59 | { 60 | alloc(vt.size()*sizeof(T)); 61 | upload((const T*)vt.data(),vt.size()); 62 | } 63 | 64 | template 65 | void upload(const T *t, size_t count) 66 | { 67 | assert(d_ptr != nullptr); 68 | assert(sizeInBytes == count*sizeof(T)); 69 | CUDA_CHECK(Memcpy(d_ptr, (void *)t, 70 | count*sizeof(T), cudaMemcpyHostToDevice)); 71 | } 72 | 73 | template 74 | void download(T *t, size_t count) 75 | { 76 | assert(d_ptr != nullptr); 77 | assert(sizeInBytes == count*sizeof(T)); 78 | CUDA_CHECK(Memcpy((void *)t, d_ptr, 79 | count*sizeof(T), cudaMemcpyDeviceToHost)); 80 | } 81 | 82 | size_t sizeInBytes { 0 }; 83 | void *d_ptr { nullptr }; 84 | }; 85 | 86 | } // ::dx 87 | -------------------------------------------------------------------------------- /src/intersect/LaunchParams.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dx { 6 | struct LaunchParams { 7 | 8 | uint32_t sizeX; 9 | uint32_t sizeY; 10 | uint32_t *colorBuffer; 11 | int frameID { 0 }; 12 | 13 | struct { 14 | float p_x, p_y, p_z; 15 | float d_x, d_y, d_z; 16 | float h_x, h_y, h_z; 17 | float v_x, v_y, v_z; 18 | } camera; 19 | 20 | OptixTraversableHandle traversable; 21 | }; 22 | } // ::dx -------------------------------------------------------------------------------- /src/intersect/intersect.cpp: -------------------------------------------------------------------------------- 1 | #include "AllIntersectRenderer.h" 2 | 3 | 4 | #define STB_IMAGE_WRITE_IMPLEMENTATION 5 | #include "ext/stb_image_write.h" 6 | 7 | /* namespace xd code */ 8 | namespace dx { 9 | 10 | extern "C" int main(int ac, char **av) 11 | { 12 | try { 13 | AllIntersectRenderer sample; 14 | 15 | int sx = 1200; 16 | int sy = 1024; 17 | sample.resize(sx, sy); 18 | sample.render(); 19 | 20 | std::vector pixels(sx*sy); 21 | sample.downloadPixels(pixels.data()); 22 | 23 | const std::string fileName = "osc_example2.png"; 24 | stbi_write_png(fileName.c_str(),sx,sy,4, 25 | pixels.data(),sx*sizeof(uint32_t)); 26 | std::cout << std::endl 27 | << "Image rendered, and saved to " << fileName << " ... done." << std::endl 28 | << std::endl; 29 | } catch (std::runtime_error& e) { 30 | std::cout << "FATAL ERROR: " << e.what() << std::endl; 31 | exit(1); 32 | } 33 | return 0; 34 | } 35 | 36 | } // :: dx -------------------------------------------------------------------------------- /src/intersect/intersect.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include "LaunchParams.h" 3 | 4 | 5 | using namespace dx; 6 | 7 | namespace dx{ 8 | 9 | 10 | //* user specified launchparam struct 11 | extern "C" __constant__ LaunchParams launchParams; 12 | 13 | static __forceinline__ __device__ 14 | void *unpackPointer( uint32_t i0, uint32_t i1 ) 15 | { 16 | const uint64_t uptr = static_cast( i0 ) << 32 | i1; 17 | void* ptr = reinterpret_cast( uptr ); 18 | return ptr; 19 | } 20 | 21 | static __forceinline__ __device__ 22 | void packPointer( void* ptr, uint32_t& i0, uint32_t& i1) 23 | { 24 | const uint64_t uptr = reinterpret_cast( ptr ); 25 | i0 = uptr >> 32; 26 | i1 = uptr & 0x00000000ffffffff; 27 | } 28 | 29 | template 30 | static __forceinline__ __device__ T *getPRD() 31 | { 32 | const uint32_t u0 = optixGetPayload_0(); 33 | const uint32_t u1 = optixGetPayload_1(); 34 | return reinterpret_cast( unpackPointer( u0, u1 )); 35 | } 36 | 37 | 38 | extern "C" __global__ void __miss__radiance(){ 39 | uint32_t &prd = *(uint32_t*)getPRD(); 40 | prd = 0xffffffff; 41 | } 42 | 43 | extern "C" __global__ void __anyhit__radiance(){ /*! for this simple example, this will remain empty */ } 44 | 45 | 46 | extern "C" __global__ void __closesthit__radiance(){ 47 | const int primID = optixGetPrimitiveIndex(); 48 | uint32_t &prd = *(uint32_t*)getPRD(); 49 | const int r = primID % 256; 50 | prd = 0xff000000 | (r << 0); 51 | } 52 | 53 | extern "C" __global__ void __raygen__renderFrame() 54 | { 55 | const int ix = optixGetLaunchIndex().x; 56 | const int iy = optixGetLaunchIndex().y; 57 | 58 | const auto &camera = launchParams.camera; 59 | 60 | uint32_t rgba; 61 | uint32_t u0, u1; 62 | packPointer( &rgba, u0, u1); 63 | 64 | 65 | 66 | const uint32_t rgba = 0xff000000 | (r<<0) | (g<<8) | (b<<16); 67 | 68 | const uint32_t fbIndex = ix+iy*launchParams.sizeX; 69 | launchParams.colorBuffer[fbIndex] = rgba; 70 | } 71 | } -------------------------------------------------------------------------------- /src/intersect/intersect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define OPTIX_CHECK( call ) \ 10 | { \ 11 | OptixResult res = call; \ 12 | if( res != OPTIX_SUCCESS ) \ 13 | { \ 14 | fprintf( stderr, "Optix call (%s) failed with code %d (line %d) \n ", #call, res, __LINE__ ); \ 15 | exit( 2 ); \ 16 | } \ 17 | } 18 | 19 | 20 | 21 | #define CUDA_CHECK_NOEXCEPT(call) \ 22 | { \ 23 | cuda##call; \ 24 | } 25 | 26 | #define CUDA_CHECK(call) \ 27 | { \ 28 | cudaError_t rc = cuda##call; \ 29 | if ( rc != cudaSuccess) { \ 30 | std::stringstream txt; \ 31 | cudaError_t err = rc; \ 32 | txt << " CUDA Error " << cudaGetErrorName(err) \ 33 | << " ( " << cudaGetErrorString(err) << " ) ";\ 34 | throw std::runtime_error(txt.str()); \ 35 | } \ 36 | } 37 | 38 | #define CUDA_SYNC_CHECK() \ 39 | { \ 40 | cudaDeviceSynchronize(); \ 41 | cudaError_t error = cudaGetLastError(); \ 42 | if( error != cudaSuccess) \ 43 | { \ 44 | fprintf( stderr, "error (%s: line %d): %s\n", __FILE__, __LINE__, cudaGetErrorString( error ) ); \ 45 | exit(2); \ 46 | } \ 47 | } 48 | 49 | #ifndef PRINT 50 | # define PRINT(var) std::cout << #var << "=" << var << std::endl; 51 | # define PING std::cout << __FILE__ << "::" << __LINE__ << ": " << __FUNCTION__ << std::endl; 52 | #endif -------------------------------------------------------------------------------- /src/optix/ptx.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #ifdef _WIN32 5 | # include 6 | #else 7 | # include 8 | #endif 9 | #include 10 | #include 11 | 12 | namespace psdr 13 | { 14 | 15 | static bool fileExists( const char* path ) 16 | { 17 | std::ifstream str( path ); 18 | return static_cast( str ); 19 | } 20 | 21 | static bool fileExists( const std::string& path ) 22 | { 23 | return fileExists( path.c_str() ); 24 | } 25 | 26 | static bool readSourceFile( std::string& str, const std::string& filename ) 27 | { 28 | // Try to open file 29 | std::ifstream file( filename.c_str() ); 30 | if( file.good() ) 31 | { 32 | // Found usable source file 33 | std::stringstream source_buffer; 34 | source_buffer << file.rdbuf(); 35 | str = source_buffer.str(); 36 | return true; 37 | } 38 | return false; 39 | } 40 | 41 | static std::string samplePTXFilePath( const char* sampleName, const char* fileName ) 42 | { 43 | // Allow for overrides. 44 | static const char* directories[] = 45 | { 46 | PTX_OUTPUT_DIR 47 | }; 48 | for( const char* directory : directories ) 49 | { 50 | if( directory ) 51 | { 52 | std::string path = directory; 53 | path += '/'; 54 | path += "ptx"; 55 | path += "_generated_"; 56 | path += fileName; 57 | path += ".ptx"; 58 | if( fileExists( path ) ) 59 | return path; 60 | } 61 | } 62 | 63 | std::string error = "samplePTXFilePath couldn't locate "; 64 | error += fileName; 65 | error += " for sample "; 66 | error += sampleName; 67 | throw Exception( error.c_str() ); 68 | } 69 | 70 | static void getPtxStringFromFile( std::string& ptx, const char* sample_name, const char* filename ) 71 | { 72 | const std::string sourceFilePath = samplePTXFilePath( sample_name, filename ); 73 | 74 | // Try to open source PTX file 75 | if( !readSourceFile( ptx, sourceFilePath ) ) 76 | { 77 | std::string err = "Couldn't open source file " + sourceFilePath; 78 | throw std::runtime_error( err.c_str() ); 79 | } 80 | } 81 | 82 | struct PtxSourceCache 83 | { 84 | std::map map; 85 | ~PtxSourceCache() 86 | { 87 | for( std::map::const_iterator it = map.begin(); it != map.end(); ++it ) 88 | delete it->second; 89 | } 90 | }; 91 | static PtxSourceCache g_ptxSourceCache; 92 | 93 | const char* getPtxString( const char* sample, const char* filename, const char** log ) 94 | { 95 | if( log ) 96 | *log = NULL; 97 | 98 | std::string * ptx, cu; 99 | std::string key = std::string( filename ) + ";" + ( sample ? sample : "" ); 100 | std::map::iterator elem = g_ptxSourceCache.map.find( key ); 101 | 102 | if( elem == g_ptxSourceCache.map.end() ) 103 | { 104 | ptx = new std::string(); 105 | getPtxStringFromFile( *ptx, sample, filename ); 106 | g_ptxSourceCache.map[key] = ptx; 107 | } 108 | else 109 | { 110 | ptx = elem->second; 111 | } 112 | 113 | return ptx->c_str(); 114 | } 115 | 116 | } // namespace sutil 117 | -------------------------------------------------------------------------------- /src/sensor/sensor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace psdr 6 | { 7 | 8 | void Sensor::configure() { 9 | m_aspect = static_cast(m_resolution.x())/m_resolution.y(); 10 | PSDR_ASSERT_MSG(std::abs(det(Matrix3fD(m_to_world))[0] - 1.f) < Epsilon, 11 | "Sensor transformation should not involve scaling!"); 12 | } 13 | 14 | } // namespace psdr 15 | --------------------------------------------------------------------------------