├── bakeryoptix ├── eigen │ ├── Eigen │ ├── src │ │ ├── Core │ │ │ ├── util │ │ │ │ ├── NonMPL2.h │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── ReenableStupidWarnings.h │ │ │ │ └── DisableStupidWarnings.h │ │ │ ├── arch │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── SSE │ │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── NEON │ │ │ │ │ └── CMakeLists.txt │ │ │ │ ├── AltiVec │ │ │ │ │ └── CMakeLists.txt │ │ │ │ └── Default │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── Settings.h │ │ │ ├── products │ │ │ │ └── CMakeLists.txt │ │ │ ├── CMakeLists.txt │ │ │ └── CoreIterators.h │ │ ├── QR │ │ │ ├── CMakeLists.txt │ │ │ └── HouseholderQR_MKL.h │ │ ├── SVD │ │ │ └── CMakeLists.txt │ │ ├── misc │ │ │ ├── CMakeLists.txt │ │ │ ├── Solve.h │ │ │ ├── Kernel.h │ │ │ └── Image.h │ │ ├── Jacobi │ │ │ └── CMakeLists.txt │ │ ├── LU │ │ │ ├── arch │ │ │ │ └── CMakeLists.txt │ │ │ ├── CMakeLists.txt │ │ │ └── Determinant.h │ │ ├── plugins │ │ │ ├── CMakeLists.txt │ │ │ ├── MatrixCwiseUnaryOps.h │ │ │ └── CommonCwiseBinaryOps.h │ │ ├── Cholesky │ │ │ └── CMakeLists.txt │ │ ├── SparseLU │ │ │ ├── CMakeLists.txt │ │ │ └── SparseLU_Utils.h │ │ ├── SparseQR │ │ │ └── CMakeLists.txt │ │ ├── SparseCore │ │ │ ├── CMakeLists.txt │ │ │ ├── SparseFuzzy.h │ │ │ ├── SparseRedux.h │ │ │ ├── SparseTranspose.h │ │ │ └── SparseView.h │ │ ├── StlSupport │ │ │ ├── CMakeLists.txt │ │ │ └── details.h │ │ ├── Eigenvalues │ │ │ └── CMakeLists.txt │ │ ├── Householder │ │ │ ├── CMakeLists.txt │ │ │ └── BlockHouseholder.h │ │ ├── SPQRSupport │ │ │ └── CMakeLists.txt │ │ ├── Geometry │ │ │ ├── arch │ │ │ │ └── CMakeLists.txt │ │ │ └── CMakeLists.txt │ │ ├── MetisSupport │ │ │ └── CMakeLists.txt │ │ ├── PaStiXSupport │ │ │ └── CMakeLists.txt │ │ ├── CholmodSupport │ │ │ └── CMakeLists.txt │ │ ├── PardisoSupport │ │ │ └── CMakeLists.txt │ │ ├── SparseCholesky │ │ │ └── CMakeLists.txt │ │ ├── SuperLUSupport │ │ │ └── CMakeLists.txt │ │ ├── UmfPackSupport │ │ │ └── CMakeLists.txt │ │ ├── OrderingMethods │ │ │ └── CMakeLists.txt │ │ ├── Eigen2Support │ │ │ ├── Geometry │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── All.h │ │ │ ├── CMakeLists.txt │ │ │ ├── Macros.h │ │ │ ├── TriangularSolver.h │ │ │ ├── Memory.h │ │ │ ├── QR.h │ │ │ ├── Lazy.h │ │ │ ├── MathFunctions.h │ │ │ ├── VectorBlock.h │ │ │ └── Meta.h │ │ ├── IterativeLinearSolvers │ │ │ └── CMakeLists.txt │ │ └── CMakeLists.txt │ ├── .hg_archival.txt │ ├── Dense │ ├── .hgeol │ ├── signature_of_eigen3_matrix_library │ ├── README.txt │ ├── Array │ ├── .hgignore │ ├── Householder │ ├── CMakeLists.txt │ ├── Sparse │ ├── Jacobi │ ├── StdList │ ├── QtAlignedMalloc │ ├── MetisSupport │ ├── COPYING.README │ ├── LeastSquares │ ├── StdDeque │ ├── StdVector │ ├── Cholesky │ ├── PardisoSupport │ ├── SVD │ ├── SPQRSupport │ ├── QR │ ├── SparseQR │ ├── LU │ ├── UmfPackSupport │ ├── Eigenvalues │ ├── COPYING.BSD │ ├── SparseCholesky │ ├── PaStiXSupport │ ├── .hgtags │ ├── IterativeLinearSolvers │ ├── Geometry │ ├── CholmodSupport │ ├── SparseLU │ ├── SparseCore │ ├── SuperLUSupport │ ├── COPYING.MINPACK │ └── OrderingMethods ├── main.cpp ├── utils │ ├── perf_moment.h │ ├── custom_crash_handler.h │ ├── base64.h │ ├── string_operations.cpp │ ├── string_codecvt.h │ ├── progress_reporter.h │ ├── miniz │ │ ├── minizpp.h │ │ └── minizpp.cpp │ ├── cout_progress.h │ ├── load_util.h │ ├── string_codecvt.cpp │ ├── base64.cpp │ ├── alphanum.h │ ├── dbg_output.h │ ├── binary_reader.h │ ├── vector_operations.h │ ├── filesystem.h │ ├── blob.cpp │ ├── cout_progress.cpp │ ├── alphanum.cpp │ ├── binary_reader.cpp │ └── variant.cpp ├── dds │ └── dds_loader.h ├── bake_kernels__cpu.h ├── pack.jsh ├── bake_wrap.h ├── baked_data.h ├── bake_filter.h ├── bake_filter_least_squares.h ├── bake_kernels.h ├── bake_util.h ├── raymiss.cu ├── bake_ao_optix_prime.h ├── bake_sample.h ├── rayexception.cu ├── rayanyhit_proctree.cu ├── dx_shaders.h ├── raybb.cu ├── bake_kernels__cpu.cpp ├── platform.h ├── rayanyhit.cu ├── rayanyhit_tree.cu ├── ray.h └── rayintersection.cu ├── .gitattributes ├── .vscode └── tasks.json ├── bakeryoptix.sln ├── README.md └── bake-cars.jsh /bakeryoptix/eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | //#include "Sparse" 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /bakeryoptix/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ac-custom-shaders-patch/acc-bakeryoptix/HEAD/bakeryoptix/main.cpp -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /bakeryoptix/utils/perf_moment.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ac-custom-shaders-patch/acc-bakeryoptix/HEAD/bakeryoptix/utils/perf_moment.h -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(SSE) 2 | ADD_SUBDIRECTORY(AltiVec) 3 | ADD_SUBDIRECTORY(NEON) 4 | ADD_SUBDIRECTORY(Default) 5 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/.hg_archival.txt: -------------------------------------------------------------------------------- 1 | repo: 8a21fd850624c931e448cbcfb38168cb2717c790 2 | node: b30b87236a1b1552af32ac34075ee5696a9b5a33 3 | branch: 3.2 4 | tag: 3.2.7 5 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /bakeryoptix/utils/custom_crash_handler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace utils 6 | { 7 | void make_minidump(EXCEPTION_POINTERS* e); 8 | } 9 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/.hgeol: -------------------------------------------------------------------------------- 1 | [patterns] 2 | scripts/*.in = LF 3 | debug/msvc/*.dat = CRLF 4 | unsupported/test/mpreal/*.* = CRLF 5 | ** = native 6 | 7 | [repository] 8 | native = LF 9 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/QR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_QR_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_QR_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/QR COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SVD/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SVD_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SVD_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SVD COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_misc_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_misc_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/misc COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Jacobi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Jacobi_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Jacobi_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Jacobi COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/LU/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_LU_arch_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_LU_arch_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/LU/arch COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_plugins_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_plugins_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/plugins COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/utils/base64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace utils 5 | { 6 | struct base64 7 | { 8 | static std::string decode(const std::string& encoded_string); 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Cholesky/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Cholesky_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Cholesky_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Cholesky COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SparseLU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseLU_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseLU_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseLU COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SparseQR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseQR_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseQR_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseQR/ COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_util_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_util_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/util COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/LU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_LU_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_LU_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/LU COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(arch) 9 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SparseCore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseCore_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseCore_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseCore COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/StlSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_StlSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_StlSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/StlSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigenvalues/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_EIGENVALUES_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_EIGENVALUES_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigenvalues COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Householder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Householder_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Householder_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Householder COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SPQRSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SPQRSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SPQRSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SPQRSupport/ COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/arch/SSE/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_SSE_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_SSE_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/SSE COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/products/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_Product_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_Product_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/products COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Geometry/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Geometry_arch_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Geometry_arch_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Geometry/arch COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/MetisSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_MetisSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_MetisSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/MetisSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/PaStiXSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_PastixSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_PastixSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/PaStiXSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/CholmodSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_CholmodSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_CholmodSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/CholmodSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/arch/NEON/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_NEON_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_NEON_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/NEON COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/PardisoSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_PardisoSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_PardisoSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/PardisoSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SparseCholesky/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseCholesky_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseCholesky_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseCholesky COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SuperLUSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SuperLUSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SuperLUSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SuperLUSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/UmfPackSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_UmfPackSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_UmfPackSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/UmfPackSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/OrderingMethods/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_OrderingMethods_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_OrderingMethods_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/OrderingMethods COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/arch/AltiVec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_AltiVec_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_AltiVec_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/AltiVec COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/arch/Default/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_Default_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_Default_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/Default COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Geometry_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Geometry_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Geometry COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(arch) 9 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/Geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Eigen2Support_Geometry_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Eigen2Support_Geometry_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support/Geometry 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/signature_of_eigen3_matrix_library: -------------------------------------------------------------------------------- 1 | This file is just there as a signature to help identify directories containing Eigen3. When writing a script looking for Eigen3, just look for this file. This is especially useful to help disambiguate with Eigen2... 2 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Eigen2Support_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Eigen2Support_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(Geometry) -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/IterativeLinearSolvers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_IterativeLinearSolvers_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_IterativeLinearSolvers_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/IterativeLinearSolvers COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /bakeryoptix/dds/dds_loader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | struct dds_loader 6 | { 7 | uint32_t width{}, height{}; 8 | std::unique_ptr data; 9 | 10 | dds_loader() = default; 11 | dds_loader(const char* data, size_t size); 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(products) 9 | ADD_SUBDIRECTORY(util) 10 | ADD_SUBDIRECTORY(arch) 11 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/README.txt: -------------------------------------------------------------------------------- 1 | For convenience, this directory contains all headers from an Eigen 3.2.7 install, along with open source licences. No modifications have been made. You can substitute a newer version of the Eigen library when configuring CMake. 2 | 3 | Eigen is used for least squares fitting in the baking sample. 4 | 5 | http://eigen.tuxfamily.org 6 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB Eigen_src_subdirectories "*") 2 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 3 | foreach(f ${Eigen_src_subdirectories}) 4 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" ) 5 | add_subdirectory(${f}) 6 | endif() 7 | endforeach() 8 | -------------------------------------------------------------------------------- /bakeryoptix/bake_kernels__cpu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace bake 5 | { 6 | struct AOSamples; 7 | void generate_rays_host(unsigned int seed, int px, int py, int sqrt_passes, float scene_offset, const AOSamples& ao_samples, Ray* rays); 8 | void update_ao_host(size_t num_samples, float max_distance, const float* hits, float* ao); 9 | } 10 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/Array: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ARRAY_MODULE_H 2 | #define EIGEN_ARRAY_MODULE_H 3 | 4 | // include Core first to handle Eigen2 support macros 5 | #include "Core" 6 | 7 | #ifndef EIGEN2_SUPPORT 8 | #error The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core. 9 | #endif 10 | 11 | #endif // EIGEN_ARRAY_MODULE_H 12 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | qrc_*cxx 3 | *.orig 4 | *.pyc 5 | *.diff 6 | diff 7 | *.save 8 | save 9 | *.old 10 | *.gmo 11 | *.qm 12 | core 13 | core.* 14 | *.bak 15 | *~ 16 | build* 17 | *.moc.* 18 | *.moc 19 | ui_* 20 | CMakeCache.txt 21 | tags 22 | .*.swp 23 | activity.png 24 | *.out 25 | *.php* 26 | *.log 27 | *.orig 28 | *.rej 29 | log 30 | patch 31 | a 32 | a.* 33 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #endif 12 | #endif 13 | 14 | #endif // EIGEN_WARNINGS_DISABLED 15 | -------------------------------------------------------------------------------- /bakeryoptix/utils/string_operations.cpp: -------------------------------------------------------------------------------- 1 | #include "string_operations.h" 2 | 3 | #define XXH_STATIC_LINKING_ONLY 4 | #include 5 | #include "xxhash/xxhash.h" 6 | 7 | namespace utils 8 | { 9 | std::array& utils_inner::format_storage() 10 | { 11 | static thread_local std::array s{}; 12 | return s; 13 | } 14 | 15 | uint64_t hash_code(const void* data, size_t size) 16 | { 17 | return XXH3_64bits(data, size); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /bakeryoptix/utils/string_codecvt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | const std::string& utf16_to_utf8(const std::string& s); 7 | std::string utf16_to_utf8(const wchar_t* s, size_t len); 8 | std::string utf16_to_utf8(const std::wstring& s); 9 | 10 | const std::wstring& utf8_to_utf16(const std::wstring& s); 11 | std::wstring utf8_to_utf16(const char* s, size_t len); 12 | std::wstring utf8_to_utf16(const std::string& s); 13 | -------------------------------------------------------------------------------- /bakeryoptix/utils/progress_reporter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | struct cout_progress 8 | { 9 | std::chrono::steady_clock::time_point start; 10 | uint32_t total_steps; 11 | uint32_t current_step{}; 12 | uint32_t last_length{}; 13 | 14 | cout_progress(uint32_t total_steps); 15 | ~cout_progress(); 16 | 17 | void erase(); 18 | void report(const std::string& comment = ""); 19 | 20 | private: 21 | std::string get_msg(const std::string& comment) const; 22 | }; 23 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "Bake cars", 8 | "type": "shell", 9 | "command": "nodesh bake-cars.jsh", 10 | "problemMatcher": [], 11 | "group": { 12 | "kind": "build", 13 | "isDefault": true 14 | }, 15 | "presentation": { 16 | "echo": false, 17 | "clear": true, 18 | "focus": false, 19 | "showReuseMessage": false, 20 | "panel": "shared", 21 | "reveal": "always" 22 | } 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /bakeryoptix/eigen/Householder: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 2 | #define EIGEN_HOUSEHOLDER_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Householder_Module Householder module 9 | * This module provides Householder transformations. 10 | * 11 | * \code 12 | * #include 13 | * \endcode 14 | */ 15 | 16 | #include "src/Householder/Householder.h" 17 | #include "src/Householder/HouseholderSequence.h" 18 | #include "src/Householder/BlockHouseholder.h" 19 | 20 | #include "src/Core/util/ReenableStupidWarnings.h" 21 | 22 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 23 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 24 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(RegexUtils) 2 | test_escape_string_as_regex() 3 | 4 | file(GLOB Eigen_directory_files "*") 5 | 6 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 7 | 8 | foreach(f ${Eigen_directory_files}) 9 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src") 10 | list(APPEND Eigen_directory_files_to_install ${f}) 11 | endif() 12 | endforeach(f ${Eigen_directory_files}) 13 | 14 | install(FILES 15 | ${Eigen_directory_files_to_install} 16 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel 17 | ) 18 | 19 | add_subdirectory(src) 20 | -------------------------------------------------------------------------------- /bakeryoptix/utils/miniz/minizpp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace utils 5 | { 6 | enum class mz_result : int 7 | { 8 | ok = 0, 9 | stream_end = 1, 10 | need_dict = 2, 11 | err_no = -1, 12 | stream_error = -2, 13 | data_error = -3, 14 | mem_error = -4, 15 | buf_error = -5, 16 | version_error = -6, 17 | limit_exceed_1 = 13, 18 | limit_exceed_2 = 14, 19 | param_error = -10000 20 | }; 21 | 22 | std::ostream& operator<<(std::ostream& os, mz_result self); 23 | mz_result mz_compress_dynamic(std::string& output, const char* data, std::size_t size); 24 | mz_result mz_uncompress_dynamic(std::string& output, const char* data, std::size_t size, std::size_t size_limit = 1000000000); 25 | } 26 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/Sparse: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSE_MODULE_H 2 | #define EIGEN_SPARSE_MODULE_H 3 | 4 | /** \defgroup Sparse_Module Sparse meta-module 5 | * 6 | * Meta-module including all related modules: 7 | * - \ref SparseCore_Module 8 | * - \ref OrderingMethods_Module 9 | * - \ref SparseCholesky_Module 10 | * - \ref SparseLU_Module 11 | * - \ref SparseQR_Module 12 | * - \ref IterativeLinearSolvers_Module 13 | * 14 | * \code 15 | * #include 16 | * \endcode 17 | */ 18 | 19 | #include "SparseCore" 20 | #include "OrderingMethods" 21 | #include "SparseCholesky" 22 | #include "SparseLU" 23 | #include "SparseQR" 24 | #include "IterativeLinearSolvers" 25 | 26 | #endif // EIGEN_SPARSE_MODULE_H 27 | 28 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/Macros.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_MACROS_H 11 | #define EIGEN2_MACROS_H 12 | 13 | #define ei_assert eigen_assert 14 | #define ei_internal_assert eigen_internal_assert 15 | 16 | #define EIGEN_ALIGN_128 EIGEN_ALIGN16 17 | 18 | #define EIGEN_ARCH_WANTS_ALIGNMENT EIGEN_ALIGN_STATICALLY 19 | 20 | #endif // EIGEN2_MACROS_H 21 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/Jacobi: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_JACOBI_MODULE_H 2 | #define EIGEN_JACOBI_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Jacobi_Module Jacobi module 9 | * This module provides Jacobi and Givens rotations. 10 | * 11 | * \code 12 | * #include 13 | * \endcode 14 | * 15 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 16 | * - MatrixBase::applyOnTheLeft() 17 | * - MatrixBase::applyOnTheRight(). 18 | */ 19 | 20 | #include "src/Jacobi/Jacobi.h" 21 | 22 | #include "src/Core/util/ReenableStupidWarnings.h" 23 | 24 | #endif // EIGEN_JACOBI_MODULE_H 25 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 26 | 27 | -------------------------------------------------------------------------------- /bakeryoptix/utils/cout_progress.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | struct cout_progress 6 | { 7 | std::chrono::steady_clock::time_point start; 8 | std::chrono::steady_clock::time_point last_report; 9 | size_t total_steps; 10 | size_t current_step{}; 11 | size_t last_report_step{}; 12 | size_t last_length{}; 13 | double avg_speed{}; 14 | bool show_steps{}; 15 | bool use_moment_speed{}; 16 | 17 | cout_progress(size_t total_steps, bool show_steps = false, bool use_moment_speed = false); 18 | ~cout_progress(); 19 | 20 | void erase(); 21 | void report(const std::string& comment = ""); 22 | 23 | private: 24 | bool shown_eta{}; 25 | std::string get_msg(const std::string& comment, const std::chrono::steady_clock::time_point& now); 26 | }; 27 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | 2 | #ifndef EIGEN_QTMALLOC_MODULE_H 3 | #define EIGEN_QTMALLOC_MODULE_H 4 | 5 | #include "Core" 6 | 7 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 8 | 9 | #include "src/Core/util/DisableStupidWarnings.h" 10 | 11 | void *qMalloc(size_t size) 12 | { 13 | return Eigen::internal::aligned_malloc(size); 14 | } 15 | 16 | void qFree(void *ptr) 17 | { 18 | Eigen::internal::aligned_free(ptr); 19 | } 20 | 21 | void *qRealloc(void *ptr, size_t size) 22 | { 23 | void* newPtr = Eigen::internal::aligned_malloc(size); 24 | memcpy(newPtr, ptr, size); 25 | Eigen::internal::aligned_free(ptr); 26 | return newPtr; 27 | } 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif 32 | 33 | #endif // EIGEN_QTMALLOC_MODULE_H 34 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 35 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_METISSUPPORT_MODULE_H 2 | #define EIGEN_METISSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | 13 | /** \ingroup Support_modules 14 | * \defgroup MetisSupport_Module MetisSupport module 15 | * 16 | * \code 17 | * #include 18 | * \endcode 19 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 20 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 21 | */ 22 | 23 | 24 | #include "src/MetisSupport/MetisSupport.h" 25 | 26 | #include "src/Core/util/ReenableStupidWarnings.h" 27 | 28 | #endif // EIGEN_METISSUPPORT_MODULE_H 29 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/COPYING.README: -------------------------------------------------------------------------------- 1 | Eigen is primarily MPL2 licensed. See COPYING.MPL2 and these links: 2 | http://www.mozilla.org/MPL/2.0/ 3 | http://www.mozilla.org/MPL/2.0/FAQ.html 4 | 5 | Some files contain third-party code under BSD or LGPL licenses, whence the other 6 | COPYING.* files here. 7 | 8 | All the LGPL code is either LGPL 2.1-only, or LGPL 2.1-or-later. 9 | For this reason, the COPYING.LGPL file contains the LGPL 2.1 text. 10 | 11 | If you want to guarantee that the Eigen code that you are #including is licensed 12 | under the MPL2 and possibly more permissive licenses (like BSD), #define this 13 | preprocessor symbol: 14 | EIGEN_MPL2_ONLY 15 | For example, with most compilers, you could add this to your project CXXFLAGS: 16 | -DEIGEN_MPL2_ONLY 17 | This will cause a compilation error to be generated if you #include any code that is 18 | LGPL licensed. 19 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/LeastSquares: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_REGRESSION_MODULE_H 2 | #define EIGEN_REGRESSION_MODULE_H 3 | 4 | #ifndef EIGEN2_SUPPORT 5 | #error LeastSquares is only available in Eigen2 support mode (define EIGEN2_SUPPORT) 6 | #endif 7 | 8 | // exclude from normal eigen3-only documentation 9 | #ifdef EIGEN2_SUPPORT 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Eigenvalues" 16 | #include "Geometry" 17 | 18 | /** \defgroup LeastSquares_Module LeastSquares module 19 | * This module provides linear regression and related features. 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/Eigen2Support/LeastSquares.h" 27 | 28 | #include "src/Core/util/ReenableStupidWarnings.h" 29 | 30 | #endif // EIGEN2_SUPPORT 31 | 32 | #endif // EIGEN_REGRESSION_MODULE_H 33 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/Cholesky: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_CHOLESKY_MODULE_H 2 | #define EIGEN_CHOLESKY_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Cholesky_Module Cholesky module 9 | * 10 | * 11 | * 12 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 13 | * Those decompositions are accessible via the following MatrixBase methods: 14 | * - MatrixBase::llt(), 15 | * - MatrixBase::ldlt() 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | */ 21 | 22 | #include "src/misc/Solve.h" 23 | #include "src/Cholesky/LLT.h" 24 | #include "src/Cholesky/LDLT.h" 25 | #ifdef EIGEN_USE_LAPACKE 26 | #include "src/Cholesky/LLT_MKL.h" 27 | #endif 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_CHOLESKY_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 2 | #define EIGEN_PARDISOSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | 10 | #include 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup PardisoSupport_Module PardisoSupport module 14 | * 15 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | * 21 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 22 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 23 | * 24 | */ 25 | 26 | #include "src/PardisoSupport/PardisoSupport.h" 27 | 28 | #include "src/Core/util/ReenableStupidWarnings.h" 29 | 30 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 31 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/SVD: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SVD_MODULE_H 2 | #define EIGEN_SVD_MODULE_H 3 | 4 | #include "QR" 5 | #include "Householder" 6 | #include "Jacobi" 7 | 8 | #include "src/Core/util/DisableStupidWarnings.h" 9 | 10 | /** \defgroup SVD_Module SVD module 11 | * 12 | * 13 | * 14 | * This module provides SVD decomposition for matrices (both real and complex). 15 | * This decomposition is accessible via the following MatrixBase method: 16 | * - MatrixBase::jacobiSvd() 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/misc/Solve.h" 24 | #include "src/SVD/JacobiSVD.h" 25 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 26 | #include "src/SVD/JacobiSVD_MKL.h" 27 | #endif 28 | #include "src/SVD/UpperBidiagonalization.h" 29 | 30 | #ifdef EIGEN2_SUPPORT 31 | #include "src/Eigen2Support/SVD.h" 32 | #endif 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif // EIGEN_SVD_MODULE_H 37 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 38 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 2 | #define EIGEN_SPQRSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "SuiteSparseQR.hpp" 9 | 10 | /** \ingroup Support_modules 11 | * \defgroup SPQRSupport_Module SuiteSparseQR module 12 | * 13 | * This module provides an interface to the SPQR library, which is part of the suitesparse package. 14 | * 15 | * \code 16 | * #include 17 | * \endcode 18 | * 19 | * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). 20 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 21 | * 22 | */ 23 | 24 | #include "src/misc/Solve.h" 25 | #include "src/misc/SparseSolve.h" 26 | #include "src/CholmodSupport/CholmodSupport.h" 27 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | // template 14 | // template 15 | // bool SparseMatrixBase::isApprox( 16 | // const OtherDerived& other, 17 | // typename NumTraits::Real prec 18 | // ) const 19 | // { 20 | // const typename internal::nested::type nested(derived()); 21 | // const typename internal::nested::type otherNested(other.derived()); 22 | // return (nested - otherNested).cwise().abs2().sum() 23 | // <= prec * prec * (std::min)(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum()); 24 | // } 25 | 26 | #endif // EIGEN_SPARSE_FUZZY_H 27 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/QR: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_QR_MODULE_H 2 | #define EIGEN_QR_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "Cholesky" 9 | #include "Jacobi" 10 | #include "Householder" 11 | 12 | /** \defgroup QR_Module QR module 13 | * 14 | * 15 | * 16 | * This module provides various QR decompositions 17 | * This module also provides some MatrixBase methods, including: 18 | * - MatrixBase::qr(), 19 | * 20 | * \code 21 | * #include 22 | * \endcode 23 | */ 24 | 25 | #include "src/misc/Solve.h" 26 | #include "src/QR/HouseholderQR.h" 27 | #include "src/QR/FullPivHouseholderQR.h" 28 | #include "src/QR/ColPivHouseholderQR.h" 29 | #ifdef EIGEN_USE_LAPACKE 30 | #include "src/QR/HouseholderQR_MKL.h" 31 | #include "src/QR/ColPivHouseholderQR_MKL.h" 32 | #endif 33 | 34 | #ifdef EIGEN2_SUPPORT 35 | #include "src/Eigen2Support/QR.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #ifdef EIGEN2_SUPPORT 41 | #include "Eigenvalues" 42 | #endif 43 | 44 | #endif // EIGEN_QR_MODULE_H 45 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 46 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/SparseQR: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSEQR_MODULE_H 2 | #define EIGEN_SPARSEQR_MODULE_H 3 | 4 | #include "SparseCore" 5 | #include "OrderingMethods" 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup SparseQR_Module SparseQR module 9 | * \brief Provides QR decomposition for sparse matrices 10 | * 11 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 12 | * The columns of the input matrix should be reordered to limit the fill-in during the 13 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 14 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 15 | * of built-in and external ordering methods. 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | * 21 | * 22 | */ 23 | 24 | #include "src/misc/Solve.h" 25 | #include "src/misc/SparseSolve.h" 26 | 27 | #include "OrderingMethods" 28 | #include "src/SparseCore/SparseColEtree.h" 29 | #include "src/SparseQR/SparseQR.h" 30 | 31 | #include "src/Core/util/ReenableStupidWarnings.h" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/LU: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_LU_MODULE_H 2 | #define EIGEN_LU_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup LU_Module LU module 9 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 10 | * This module defines the following MatrixBase methods: 11 | * - MatrixBase::inverse() 12 | * - MatrixBase::determinant() 13 | * 14 | * \code 15 | * #include 16 | * \endcode 17 | */ 18 | 19 | #include "src/misc/Solve.h" 20 | #include "src/misc/Kernel.h" 21 | #include "src/misc/Image.h" 22 | #include "src/LU/FullPivLU.h" 23 | #include "src/LU/PartialPivLU.h" 24 | #ifdef EIGEN_USE_LAPACKE 25 | #include "src/LU/PartialPivLU_MKL.h" 26 | #endif 27 | #include "src/LU/Determinant.h" 28 | #include "src/LU/Inverse.h" 29 | 30 | #if defined EIGEN_VECTORIZE_SSE 31 | #include "src/LU/arch/Inverse_SSE.h" 32 | #endif 33 | 34 | #ifdef EIGEN2_SUPPORT 35 | #include "src/Eigen2Support/LU.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_LU_MODULE_H 41 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 42 | -------------------------------------------------------------------------------- /bakeryoptix/pack.jsh: -------------------------------------------------------------------------------- 1 | { 2 | let result = `#pragma once 3 | #include 4 | 5 | `; 6 | 7 | for (let f of $.glob('../x64/Release/*.ptx')) { 8 | let s = $.readText(f).replace(/\/\/.*\r?\n/g, '').trim().replace(/\\/g, '\\\\').replace(/\r?\n/g, '\\n').replace(/\s+/g, ' ').replace(/"/g, '\\"'); 9 | let p = s.match(/.{1,119}[^\\]/g); 10 | $.echo(p.length); 11 | result += `inline std::string ptx_program_${path.basename(f, '.cu.ptx')}(){ 12 | std::string s; 13 | ${[].map.call(p, x => `s += "${x}";`).join('\n ')} 14 | return s; 15 | }\n\n` 16 | } 17 | 18 | fs.writeFileSync('ptx_programs.h', result); 19 | } 20 | 21 | { 22 | let result = `#pragma once 23 | #include 24 | 25 | `; 26 | 27 | for (let f of $.glob('../x64/Release/*.fxo')) { 28 | let s = fs.readFileSync(f).toString('base64').replace(/\/\/.*\r?\n/g, '').trim().replace(/\\/g, '\\\\').replace(/\r?\n/g, '\\n').replace(/\s+/g, ' ').replace(/"/g, '\\"'); 29 | let p = s.match(/.{1,119}[^\\]/g); 30 | $.echo(p.length); 31 | result += `inline std::string dx_shader_${path.basename(f, '.fxo')}(){ 32 | std::string s; 33 | ${[].map.call(p, x => `s += "${x}";`).join('\n ')} 34 | return s; 35 | }\n\n` 36 | } 37 | 38 | fs.writeFileSync('dx_shaders.h', result); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /bakeryoptix/bake_wrap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace bake { 7 | struct Scene; 8 | } 9 | 10 | struct bake_params { 11 | int num_samples; 12 | int min_samples_per_face; 13 | bool disable_normals; 14 | bool missing_normals_up; 15 | bool fix_incorrect_normals; 16 | bool debug_mode; 17 | 18 | uint32_t stack_size = 1024; 19 | size_t batch_size = 2000000; 20 | 21 | bool sample_on_points; 22 | bake::Vec3 sample_offset; 23 | 24 | bool use_ground_plane_blocker; 25 | int ground_upaxis; 26 | float ground_scale_factor; 27 | float ground_offset_factor; 28 | 29 | int num_rays; 30 | int bounce_counts; 31 | float scene_offset_scale_horizontal; 32 | float scene_offset_scale_vertical; 33 | float scene_albedo; 34 | float trees_light_pass_chance; 35 | 36 | bake::VertexFilterMode filter_mode; 37 | float regularization_weight; 38 | 39 | struct light_emitter 40 | { 41 | std::array pos; 42 | float intensity; 43 | }; 44 | std::vector light_emitters; 45 | }; 46 | 47 | struct bake_wrap final 48 | { 49 | static baked_data bake_scene(const std::shared_ptr& scene, 50 | const std::vector>& blockers, 51 | const bake_params& config, bool verbose = false); 52 | }; 53 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 2 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup UmfPackSupport_Module UmfPackSupport module 14 | * 15 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 16 | * It provides the following factorization class: 17 | * - class UmfPackLU: a multifrontal sequential LU factorization. 18 | * 19 | * \code 20 | * #include 21 | * \endcode 22 | * 23 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 24 | * The dependencies depend on how umfpack has been compiled. 25 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 26 | * 27 | */ 28 | 29 | #include "src/misc/Solve.h" 30 | #include "src/misc/SparseSolve.h" 31 | 32 | #include "src/UmfPackSupport/UmfPackSupport.h" 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 37 | -------------------------------------------------------------------------------- /bakeryoptix.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bakeryoptix", "bakeryoptix\bakeryoptix.vcxproj", "{E8286CC2-0FEF-4BF5-8935-F716E6D3AF89}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {E8286CC2-0FEF-4BF5-8935-F716E6D3AF89}.Debug|x64.ActiveCfg = Debug|x64 17 | {E8286CC2-0FEF-4BF5-8935-F716E6D3AF89}.Debug|x64.Build.0 = Debug|x64 18 | {E8286CC2-0FEF-4BF5-8935-F716E6D3AF89}.Debug|x86.ActiveCfg = Debug|Win32 19 | {E8286CC2-0FEF-4BF5-8935-F716E6D3AF89}.Debug|x86.Build.0 = Debug|Win32 20 | {E8286CC2-0FEF-4BF5-8935-F716E6D3AF89}.Release|x64.ActiveCfg = Release|x64 21 | {E8286CC2-0FEF-4BF5-8935-F716E6D3AF89}.Release|x64.Build.0 = Release|x64 22 | {E8286CC2-0FEF-4BF5-8935-F716E6D3AF89}.Release|x86.ActiveCfg = Release|Win32 23 | {E8286CC2-0FEF-4BF5-8935-F716E6D3AF89}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /bakeryoptix/utils/load_util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | inline void expand_bbox(float bbox_min[3], float bbox_max[3], const float v[3]) 10 | { 11 | for (size_t k = 0; k < 3; ++k) 12 | { 13 | bbox_min[k] = std::min(bbox_min[k], v[k]); 14 | bbox_max[k] = std::max(bbox_max[k], v[k]); 15 | } 16 | } 17 | 18 | namespace bake 19 | { 20 | struct Mesh; 21 | } 22 | 23 | namespace utils { 24 | class path; 25 | } 26 | 27 | struct load_params 28 | { 29 | float normals_bias{}; 30 | std::vector exclude_patch; 31 | std::vector exclude_blockers; 32 | bool exclude_blockers_alpha_test{}; 33 | bool exclude_blockers_alpha_blend{}; 34 | 35 | utils::path car_configs_dir; 36 | utils::path track_configs_dir; 37 | }; 38 | 39 | std::vector collect_configs(const utils::path& filename, const load_params& params); 40 | std::shared_ptr load_hierarchy(const utils::path& filename); 41 | std::shared_ptr load_model(const utils::path& filename, const load_params& params); 42 | std::shared_ptr load_ksanim(const utils::path& filename, bool include_static = false); 43 | std::vector load_ailane(const utils::path& filename); 44 | void replacement_optimization(const utils::path& filename); 45 | 46 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_EIGENVALUES_MODULE_H 2 | #define EIGEN_EIGENVALUES_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "Cholesky" 9 | #include "Jacobi" 10 | #include "Householder" 11 | #include "LU" 12 | #include "Geometry" 13 | 14 | /** \defgroup Eigenvalues_Module Eigenvalues module 15 | * 16 | * 17 | * 18 | * This module mainly provides various eigenvalue solvers. 19 | * This module also provides some MatrixBase methods, including: 20 | * - MatrixBase::eigenvalues(), 21 | * - MatrixBase::operatorNorm() 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | */ 27 | 28 | #include "src/Eigenvalues/Tridiagonalization.h" 29 | #include "src/Eigenvalues/RealSchur.h" 30 | #include "src/Eigenvalues/EigenSolver.h" 31 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 32 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 33 | #include "src/Eigenvalues/HessenbergDecomposition.h" 34 | #include "src/Eigenvalues/ComplexSchur.h" 35 | #include "src/Eigenvalues/ComplexEigenSolver.h" 36 | #include "src/Eigenvalues/RealQZ.h" 37 | #include "src/Eigenvalues/GeneralizedEigenSolver.h" 38 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 39 | #ifdef EIGEN_USE_LAPACKE 40 | #include "src/Eigenvalues/RealSchur_MKL.h" 41 | #include "src/Eigenvalues/ComplexSchur_MKL.h" 42 | #include "src/Eigenvalues/SelfAdjointEigenSolver_MKL.h" 43 | #endif 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_EIGENVALUES_MODULE_H 48 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 49 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/COPYING.BSD: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * 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 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ -------------------------------------------------------------------------------- /bakeryoptix/eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2013 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSECHOLESKY_MODULE_H 11 | #define EIGEN_SPARSECHOLESKY_MODULE_H 12 | 13 | #include "SparseCore" 14 | #include "OrderingMethods" 15 | 16 | #include "src/Core/util/DisableStupidWarnings.h" 17 | 18 | /** 19 | * \defgroup SparseCholesky_Module SparseCholesky module 20 | * 21 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 22 | * Those decompositions are accessible via the following classes: 23 | * - SimplicialLLt, 24 | * - SimplicialLDLt 25 | * 26 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #ifdef EIGEN_MPL2_ONLY 34 | #error The SparseCholesky module has nothing to offer in MPL2 only mode 35 | #endif 36 | 37 | #include "src/misc/Solve.h" 38 | #include "src/misc/SparseSolve.h" 39 | #include "src/SparseCholesky/SimplicialCholesky.h" 40 | 41 | #ifndef EIGEN_MPL2_ONLY 42 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 43 | #endif 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 48 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 2 | #define EIGEN_PASTIXSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | extern "C" { 10 | #include 11 | #include 12 | } 13 | 14 | #ifdef complex 15 | #undef complex 16 | #endif 17 | 18 | /** \ingroup Support_modules 19 | * \defgroup PaStiXSupport_Module PaStiXSupport module 20 | * 21 | * This module provides an interface to the PaSTiX library. 22 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 23 | * It provides the two following main factorization classes: 24 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 25 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 26 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | * 32 | * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. 33 | * The dependencies depend on how PaSTiX has been compiled. 34 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 35 | * 36 | */ 37 | 38 | #include "src/misc/Solve.h" 39 | #include "src/misc/SparseSolve.h" 40 | 41 | #include "src/PaStiXSupport/PaStiXSupport.h" 42 | 43 | 44 | #include "src/Core/util/ReenableStupidWarnings.h" 45 | 46 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 47 | -------------------------------------------------------------------------------- /bakeryoptix/utils/string_codecvt.cpp: -------------------------------------------------------------------------------- 1 | #include "string_codecvt.h" 2 | 3 | #include 4 | #include 5 | 6 | const std::string& utf16_to_utf8(const std::string& s) 7 | { 8 | return s; 9 | } 10 | 11 | std::string utf16_to_utf8(const wchar_t* s, size_t len) 12 | { 13 | std::string result; 14 | if (len > 0) 15 | { 16 | result.resize(len * 2); 17 | auto r = WideCharToMultiByte(CP_UTF8, 0, s, int(len), &result[0], int(result.size()), nullptr, nullptr); 18 | if (r == 0) 19 | { 20 | result.resize(WideCharToMultiByte(CP_UTF8, 0, s, int(len), nullptr, 0, nullptr, nullptr)); 21 | r = WideCharToMultiByte(CP_UTF8, 0, s, int(len), &result[0], int(result.size()), nullptr, nullptr); 22 | } 23 | result.resize(r); 24 | } 25 | return result; 26 | } 27 | 28 | std::string utf16_to_utf8(const std::wstring& s) 29 | { 30 | return utf16_to_utf8(s.c_str(), s.size()); 31 | } 32 | 33 | const std::wstring& utf8_to_utf16(const std::wstring& s) 34 | { 35 | return s; 36 | } 37 | 38 | std::wstring utf8_to_utf16(const char* s, size_t len) 39 | { 40 | // return std::wstring_convert>().from_bytes(s, s + len); 41 | 42 | std::wstring result; 43 | result.resize(len); 44 | if (len > 0) 45 | { 46 | auto r = MultiByteToWideChar(CP_UTF8, 0, s, int(len), &result[0], int(result.size())); 47 | if (r == 0) 48 | { 49 | result.resize(MultiByteToWideChar(CP_UTF8, 0, s, int(len), nullptr, 0)); 50 | r = MultiByteToWideChar(CP_UTF8, 0, s, int(len), &result[0], int(result.size())); 51 | } 52 | result.resize(r); 53 | } 54 | return result; 55 | } 56 | 57 | std::wstring utf8_to_utf16(const std::string& s) 58 | { 59 | return utf8_to_utf16(s.c_str(), s.size()); 60 | } 61 | -------------------------------------------------------------------------------- /bakeryoptix/utils/base64.cpp: -------------------------------------------------------------------------------- 1 | #include "base64.h" 2 | 3 | namespace utils 4 | { 5 | static const std::string base64_chars = 6 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 7 | "abcdefghijklmnopqrstuvwxyz" 8 | "0123456789+/"; 9 | 10 | static bool is_base64(char c) 11 | { 12 | return isalnum(c) || c == '+' || c == '/'; 13 | } 14 | 15 | std::string base64::decode(const std::string& encoded_string) 16 | { 17 | auto in_len = int(encoded_string.size()); 18 | auto i = 0; 19 | auto in = 0; 20 | uint8_t char_array_4[4], char_array_3[3]; 21 | std::string ret; 22 | 23 | while (in_len-- && encoded_string[in] != '=' && is_base64(encoded_string[in])) 24 | { 25 | char_array_4[i++] = encoded_string[in]; 26 | in++; 27 | if (i == 4) 28 | { 29 | for (i = 0; i < 4; i++) char_array_4[i] = uint8_t(base64_chars.find(char_array_4[i])); 30 | char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); 31 | char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); 32 | char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; 33 | for (i = 0; i < 3; i++) ret.push_back(char_array_3[i]); 34 | i = 0; 35 | } 36 | } 37 | 38 | if (i) 39 | { 40 | for (auto j = i; j < 4; j++) char_array_4[j] = 0; 41 | for (auto j = 0; j < 4; j++) char_array_4[j] = uint8_t(base64_chars.find(char_array_4[j])); 42 | char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); 43 | char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); 44 | char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; 45 | for (auto j = 0; j < i - 1; j++) ret.push_back(char_array_3[j]); 46 | } 47 | 48 | return ret; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/TriangularSolver.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TRIANGULAR_SOLVER2_H 11 | #define EIGEN_TRIANGULAR_SOLVER2_H 12 | 13 | namespace Eigen { 14 | 15 | const unsigned int UnitDiagBit = UnitDiag; 16 | const unsigned int SelfAdjointBit = SelfAdjoint; 17 | const unsigned int UpperTriangularBit = Upper; 18 | const unsigned int LowerTriangularBit = Lower; 19 | 20 | const unsigned int UpperTriangular = Upper; 21 | const unsigned int LowerTriangular = Lower; 22 | const unsigned int UnitUpperTriangular = UnitUpper; 23 | const unsigned int UnitLowerTriangular = UnitLower; 24 | 25 | template 26 | template 27 | typename ExpressionType::PlainObject 28 | Flagged::solveTriangular(const MatrixBase& other) const 29 | { 30 | return m_matrix.template triangularView().solve(other.derived()); 31 | } 32 | 33 | template 34 | template 35 | void Flagged::solveTriangularInPlace(const MatrixBase& other) const 36 | { 37 | m_matrix.template triangularView().solveInPlace(other.derived()); 38 | } 39 | 40 | } // end namespace Eigen 41 | 42 | #endif // EIGEN_TRIANGULAR_SOLVER2_H 43 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/.hgtags: -------------------------------------------------------------------------------- 1 | 2db9468678c6480c9633b6272ff0e3599d1e11a3 2.0-beta3 2 | 375224817dce669b6fa31d920d4c895a63fabf32 2.0-beta1 3 | 3b8120f077865e2a072e10f5be33e1d942b83a06 2.0-rc1 4 | 19dfc0e7666bcee26f7a49eb42f39a0280a3485e 2.0-beta5 5 | 7a7d8a9526f003ffa2430dfb0c2c535b5add3023 2.0-beta4 6 | 7d14ad088ac23769c349518762704f0257f6a39b 2.0.1 7 | b9d48561579fd7d4c05b2aa42235dc9de6484bf2 2.0-beta6 8 | e17630a40408243cb1a51ad0fe3a99beb75b7450 before-hg-migration 9 | eda654d4cda2210ce80719addcf854773e6dec5a 2.0.0 10 | ee9a7c468a9e73fab12f38f02bac24b07f29ed71 2.0-beta2 11 | d49097c25d8049e730c254a2fed725a240ce4858 after-hg-migration 12 | 655348878731bcb5d9bbe0854077b052e75e5237 actual-start-from-scratch 13 | 12a658962d4e6dfdc9a1c350fe7b69e36e70675c 3.0-beta1 14 | 5c4180ad827b3f869b13b1d82f5a6ce617d6fcee 3.0-beta2 15 | 7ae24ca6f3891d5ac58ddc7db60ad413c8d6ec35 3.0-beta3 16 | c40708b9088d622567fecc9208ad4a426621d364 3.0-beta4 17 | b6456624eae74f49ae8683d8e7b2882a2ca0342a 3.0-rc1 18 | a810d5dbab47acfe65b3350236efdd98f67d4d8a 3.1.0-alpha1 19 | 304c88ca3affc16dd0b008b1104873986edd77af 3.1.0-alpha2 20 | 920fc730b5930daae0a6dbe296d60ce2e3808215 3.1.0-beta1 21 | 8383e883ebcc6f14695ff0b5e20bb631abab43fb 3.1.0-rc1 22 | bf4cb8c934fa3a79f45f1e629610f0225e93e493 3.1.0-rc2 23 | da195914abcc1d739027cbee7c52077aab30b336 3.2-beta1 24 | 4b687cad1d23066f66863f4f87298447298443df 3.2-rc1 25 | 1eeda7b1258bcd306018c0738e2b6a8543661141 3.2-rc2 26 | ffa86ffb557094721ca71dcea6aed2651b9fd610 3.2.0 27 | 6b38706d90a9fe182e66ab88477b3dbde34b9f66 3.2.1 28 | 1306d75b4a21891e59ff9bd96678882cf831e39f 3.2.2 29 | 36fd1ba04c120cfdd90f3e4cede47f43b21d19ad 3.2.3 30 | 10219c95fe653d4962aa9db4946f6fbea96dd740 3.2.4 31 | bdd17ee3b1b3a166cd5ec36dcad4fc1f3faf774a 3.2.5 32 | c58038c56923e0fd86de3ded18e03df442e66dfb 3.2.6 33 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SparseCore/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSEREDUX_H 11 | #define EIGEN_SPARSEREDUX_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | typename internal::traits::Scalar 17 | SparseMatrixBase::sum() const 18 | { 19 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 20 | Scalar res(0); 21 | for (Index j=0; j 28 | typename internal::traits >::Scalar 29 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 30 | { 31 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 32 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 33 | } 34 | 35 | template 36 | typename internal::traits >::Scalar 37 | SparseVector<_Scalar,_Options,_Index>::sum() const 38 | { 39 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 40 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 41 | } 42 | 43 | } // end namespace Eigen 44 | 45 | #endif // EIGEN_SPARSEREDUX_H 46 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/IterativeLinearSolvers: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 2 | #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 3 | 4 | #include "SparseCore" 5 | #include "OrderingMethods" 6 | 7 | #include "src/Core/util/DisableStupidWarnings.h" 8 | 9 | /** 10 | * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module 11 | * 12 | * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse. 13 | * Those solvers are accessible via the following classes: 14 | * - ConjugateGradient for selfadjoint (hermitian) matrices, 15 | * - BiCGSTAB for general square matrices. 16 | * 17 | * These iterative solvers are associated with some preconditioners: 18 | * - IdentityPreconditioner - not really useful 19 | * - DiagonalPreconditioner - also called JAcobi preconditioner, work very well on diagonal dominant matrices. 20 | * - IncompleteILUT - incomplete LU factorization with dual thresholding 21 | * 22 | * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | */ 28 | 29 | #include "src/misc/Solve.h" 30 | #include "src/misc/SparseSolve.h" 31 | 32 | #include "src/IterativeLinearSolvers/IterativeSolverBase.h" 33 | #include "src/IterativeLinearSolvers/BasicPreconditioners.h" 34 | #include "src/IterativeLinearSolvers/ConjugateGradient.h" 35 | #include "src/IterativeLinearSolvers/BiCGSTAB.h" 36 | #include "src/IterativeLinearSolvers/IncompleteLUT.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 41 | -------------------------------------------------------------------------------- /bakeryoptix/baked_data.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define VAO_DECODE_POW 2.f 9 | #define VAO_ENCODE_POW (1.f / VAO_DECODE_POW) 10 | 11 | namespace utils 12 | { 13 | class path; 14 | } 15 | 16 | namespace bake 17 | { 18 | struct Mesh; 19 | } 20 | 21 | typedef std::vector baked_data_mesh_set; 22 | 23 | struct baked_data_mesh 24 | { 25 | // And each set consists of primary and secondary AO for smooth transition. 26 | baked_data_mesh_set main_set; 27 | baked_data_mesh_set alternative_set; 28 | }; 29 | 30 | struct save_params 31 | { 32 | float averaging_threshold; 33 | float averaging_cos_threshold; 34 | float brightness; 35 | float gamma; 36 | float opacity; 37 | utils::ini_file extra_config; 38 | bool average_ao_in_same_pos; 39 | }; 40 | 41 | struct baked_data 42 | { 43 | std::map, baked_data_mesh> entries; 44 | std::vector extra_points_ao; 45 | std::map extra_entries; 46 | 47 | void smooth_ao(); 48 | void save(const utils::path& destination, const save_params& params, bool store_secondary_set); 49 | void replace(const baked_data& b); 50 | void replace_primary(const baked_data& b); 51 | void brighten(const baked_data& b, float brighten_k); 52 | void max(const baked_data& b, float mult_b = 1.f, const std::vector>& inverse = {}, bool apply_to_both_sets = false); 53 | void average(const baked_data& b, float mult_b, float mult_base, const std::vector>& inverse = {}, bool apply_to_both_sets = false); 54 | void extend(const baked_data& b); 55 | void set_alternative_set(const baked_data& b); 56 | void fill(const std::shared_ptr& mesh, float x); 57 | }; 58 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/Memory.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_MEMORY_H 11 | #define EIGEN2_MEMORY_H 12 | 13 | namespace Eigen { 14 | 15 | inline void* ei_aligned_malloc(size_t size) { return internal::aligned_malloc(size); } 16 | inline void ei_aligned_free(void *ptr) { internal::aligned_free(ptr); } 17 | inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) { return internal::aligned_realloc(ptr, new_size, old_size); } 18 | inline void* ei_handmade_aligned_malloc(size_t size) { return internal::handmade_aligned_malloc(size); } 19 | inline void ei_handmade_aligned_free(void *ptr) { internal::handmade_aligned_free(ptr); } 20 | 21 | template inline void* ei_conditional_aligned_malloc(size_t size) 22 | { 23 | return internal::conditional_aligned_malloc(size); 24 | } 25 | template inline void ei_conditional_aligned_free(void *ptr) 26 | { 27 | internal::conditional_aligned_free(ptr); 28 | } 29 | template inline void* ei_conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) 30 | { 31 | return internal::conditional_aligned_realloc(ptr, new_size, old_size); 32 | } 33 | 34 | template inline T* ei_aligned_new(size_t size) 35 | { 36 | return internal::aligned_new(size); 37 | } 38 | template inline void ei_aligned_delete(T *ptr, size_t size) 39 | { 40 | return internal::aligned_delete(ptr, size); 41 | } 42 | 43 | } // end namespace Eigen 44 | 45 | #endif // EIGEN2_MACROS_H 46 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/Geometry: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_GEOMETRY_MODULE_H 2 | #define EIGEN_GEOMETRY_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "SVD" 9 | #include "LU" 10 | #include 11 | 12 | #ifndef M_PI 13 | #define M_PI 3.14159265358979323846 14 | #endif 15 | 16 | /** \defgroup Geometry_Module Geometry module 17 | * 18 | * 19 | * 20 | * This module provides support for: 21 | * - fixed-size homogeneous transformations 22 | * - translation, scaling, 2D and 3D rotations 23 | * - quaternions 24 | * - \ref MatrixBase::cross() "cross product" 25 | * - \ref MatrixBase::unitOrthogonal() "orthognal vector generation" 26 | * - some linear components: parametrized-lines and hyperplanes 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #include "src/Geometry/OrthoMethods.h" 34 | #include "src/Geometry/EulerAngles.h" 35 | 36 | #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS 37 | #include "src/Geometry/Homogeneous.h" 38 | #include "src/Geometry/RotationBase.h" 39 | #include "src/Geometry/Rotation2D.h" 40 | #include "src/Geometry/Quaternion.h" 41 | #include "src/Geometry/AngleAxis.h" 42 | #include "src/Geometry/Transform.h" 43 | #include "src/Geometry/Translation.h" 44 | #include "src/Geometry/Scaling.h" 45 | #include "src/Geometry/Hyperplane.h" 46 | #include "src/Geometry/ParametrizedLine.h" 47 | #include "src/Geometry/AlignedBox.h" 48 | #include "src/Geometry/Umeyama.h" 49 | 50 | #if defined EIGEN_VECTORIZE_SSE 51 | #include "src/Geometry/arch/Geometry_SSE.h" 52 | #endif 53 | #endif 54 | 55 | #ifdef EIGEN2_SUPPORT 56 | #include "src/Eigen2Support/Geometry/All.h" 57 | #endif 58 | 59 | #include "src/Core/util/ReenableStupidWarnings.h" 60 | 61 | #endif // EIGEN_GEOMETRY_MODULE_H 62 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 63 | 64 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 2 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup CholmodSupport_Module CholmodSupport module 14 | * 15 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 16 | * It provides the two following main factorization classes: 17 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 18 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 19 | * 20 | * For the sake of completeness, this module also propose the two following classes: 21 | * - class CholmodSimplicialLLT 22 | * - class CholmodSimplicialLDLT 23 | * Note that these classes does not bring any particular advantage compared to the built-in 24 | * SimplicialLLT and SimplicialLDLT factorization classes. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. 31 | * The dependencies depend on how cholmod has been compiled. 32 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/misc/Solve.h" 37 | #include "src/misc/SparseSolve.h" 38 | 39 | #include "src/CholmodSupport/CholmodSupport.h" 40 | 41 | 42 | #include "src/Core/util/ReenableStupidWarnings.h" 43 | 44 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 45 | 46 | -------------------------------------------------------------------------------- /bakeryoptix/utils/alphanum.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | Released under the MIT License - https://opensource.org/licenses/MIT 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the "Software"), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 22 | USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | namespace doj 29 | { 30 | bool alphanum_isdigit(char c); 31 | int alphanum_impl(const char* l, const char* r); 32 | 33 | int alphanum_comp(char* l, char* r); 34 | int alphanum_comp(const char* l, const char* r); 35 | int alphanum_comp(char* l, const char* r); 36 | int alphanum_comp(const char* l, char* r); 37 | int alphanum_comp(const std::string& l, char* r); 38 | int alphanum_comp(char* l, const std::string& r); 39 | int alphanum_comp(const std::string& l, const char* r); 40 | int alphanum_comp(const char* l, const std::string& r); 41 | int alphanum_comp(const std::string& l, const std::string& r); 42 | } 43 | -------------------------------------------------------------------------------- /bakeryoptix/bake_filter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018, NVIDIA CORPORATION. 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 5 | * are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of NVIDIA CORPORATION nor the names of its 12 | * contributors may be used to endorse or promote products derived 13 | * from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #pragma once 29 | #include 30 | 31 | namespace bake 32 | { 33 | void filter( 34 | const Scene& scene, 35 | const size_t* num_samples_per_instance, 36 | const AOSamples& ao_samples, 37 | const float* ao_values, 38 | float** vertex_ao); 39 | } 40 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | 12 | /* All the parameters defined in this file can be specialized in the 13 | * architecture specific files, and/or by the user. 14 | * More to come... */ 15 | 16 | #ifndef EIGEN_DEFAULT_SETTINGS_H 17 | #define EIGEN_DEFAULT_SETTINGS_H 18 | 19 | /** Defines the maximal loop size to enable meta unrolling of loops. 20 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 21 | * it does not correspond to the number of iterations or the number of instructions 22 | */ 23 | #ifndef EIGEN_UNROLLING_LIMIT 24 | #define EIGEN_UNROLLING_LIMIT 100 25 | #endif 26 | 27 | /** Defines the threshold between a "small" and a "large" matrix. 28 | * This threshold is mainly used to select the proper product implementation. 29 | */ 30 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 31 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 32 | #endif 33 | 34 | /** Defines the maximal width of the blocks used in the triangular product and solver 35 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 36 | */ 37 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 38 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 39 | #endif 40 | 41 | 42 | /** Defines the default number of registers available for that architecture. 43 | * Currently it must be 8 or 16. Other values will fail. 44 | */ 45 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 46 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 47 | #endif 48 | 49 | #endif // EIGEN_DEFAULT_SETTINGS_H 50 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/SparseLU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // Copyright (C) 2012 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSELU_MODULE_H 12 | #define EIGEN_SPARSELU_MODULE_H 13 | 14 | #include "SparseCore" 15 | 16 | /** 17 | * \defgroup SparseLU_Module SparseLU module 18 | * This module defines a supernodal factorization of general sparse matrices. 19 | * The code is fully optimized for supernode-panel updates with specialized kernels. 20 | * Please, see the documentation of the SparseLU class for more details. 21 | */ 22 | 23 | #include "src/misc/Solve.h" 24 | #include "src/misc/SparseSolve.h" 25 | 26 | // Ordering interface 27 | #include "OrderingMethods" 28 | 29 | #include "src/SparseLU/SparseLU_gemm_kernel.h" 30 | 31 | #include "src/SparseLU/SparseLU_Structs.h" 32 | #include "src/SparseLU/SparseLU_SupernodalMatrix.h" 33 | #include "src/SparseLU/SparseLUImpl.h" 34 | #include "src/SparseCore/SparseColEtree.h" 35 | #include "src/SparseLU/SparseLU_Memory.h" 36 | #include "src/SparseLU/SparseLU_heap_relax_snode.h" 37 | #include "src/SparseLU/SparseLU_relax_snode.h" 38 | #include "src/SparseLU/SparseLU_pivotL.h" 39 | #include "src/SparseLU/SparseLU_panel_dfs.h" 40 | #include "src/SparseLU/SparseLU_kernel_bmod.h" 41 | #include "src/SparseLU/SparseLU_panel_bmod.h" 42 | #include "src/SparseLU/SparseLU_column_dfs.h" 43 | #include "src/SparseLU/SparseLU_column_bmod.h" 44 | #include "src/SparseLU/SparseLU_copy_to_ucol.h" 45 | #include "src/SparseLU/SparseLU_pruneL.h" 46 | #include "src/SparseLU/SparseLU_Utils.h" 47 | #include "src/SparseLU/SparseLU.h" 48 | 49 | #endif // EIGEN_SPARSELU_MODULE_H 50 | -------------------------------------------------------------------------------- /bakeryoptix/bake_filter_least_squares.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018, NVIDIA CORPORATION. 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 5 | * are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of NVIDIA CORPORATION nor the names of its 12 | * contributors may be used to endorse or promote products derived 13 | * from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #pragma once 29 | #include "bake_api.h" 30 | 31 | namespace bake 32 | { 33 | void filter_least_squares( 34 | const Scene& scene, 35 | const size_t* num_samples_per_instance, 36 | const AOSamples& ao_samples, 37 | const float* ao_values, 38 | const float regularization_weight, 39 | float** vertex_ao); 40 | } 41 | -------------------------------------------------------------------------------- /bakeryoptix/bake_kernels.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018, NVIDIA CORPORATION. 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 5 | * are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of NVIDIA CORPORATION nor the names of its 12 | * contributors may be used to endorse or promote products derived 13 | * from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #pragma once 29 | #include 30 | 31 | namespace bake 32 | { 33 | struct AOSamples; 34 | void generate_rays_device(unsigned int seed, int px, int py, int sqrt_passes, float scene_offset, const AOSamples& ao_samples, Ray* rays); 35 | void update_ao_device(size_t num_samples, float max_distance, const float* hits, float* ao); 36 | } 37 | -------------------------------------------------------------------------------- /bakeryoptix/bake_util.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018, NVIDIA CORPORATION. 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 5 | * are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of NVIDIA CORPORATION nor the names of its 12 | * contributors may be used to endorse or promote products derived 13 | * from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #pragma once 29 | #include 30 | #include 31 | #include 32 | 33 | namespace bake 34 | { 35 | struct Ray 36 | { 37 | static const RTPbufferformat format = RTP_BUFFER_FORMAT_RAY_ORIGIN_DIRECTION; 38 | optix::float3 origin; 39 | optix::float3 direction; 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /bakeryoptix/raymiss.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-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 | #include "ray.h" 30 | 31 | rtDeclareVariable(PerRayData, thePrd, rtPayload, ); 32 | 33 | RT_PROGRAM void raymiss() 34 | { 35 | // thePrd.radiance = make_float3(1.0f); // Constant white emission. 36 | thePrd.radiance = make_float3(1.0f); // Constant white emission. No next event estimation (direct lighting). 37 | thePrd.flags |= FLAG_TERMINATE; // End of path. 38 | } -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/QR.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2011 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN2_QR_H 12 | #define EIGEN2_QR_H 13 | 14 | namespace Eigen { 15 | 16 | template 17 | class QR : public HouseholderQR 18 | { 19 | public: 20 | 21 | typedef HouseholderQR Base; 22 | typedef Block MatrixRBlockType; 23 | 24 | QR() : Base() {} 25 | 26 | template 27 | explicit QR(const T& t) : Base(t) {} 28 | 29 | template 30 | bool solve(const MatrixBase& b, ResultType *result) const 31 | { 32 | *result = static_cast(this)->solve(b); 33 | return true; 34 | } 35 | 36 | MatrixType matrixQ(void) const { 37 | MatrixType ret = MatrixType::Identity(this->rows(), this->cols()); 38 | ret = this->householderQ() * ret; 39 | return ret; 40 | } 41 | 42 | bool isFullRank() const { 43 | return true; 44 | } 45 | 46 | const TriangularView 47 | matrixR(void) const 48 | { 49 | int cols = this->cols(); 50 | return MatrixRBlockType(this->matrixQR(), 0, 0, cols, cols).template triangularView(); 51 | } 52 | }; 53 | 54 | /** \return the QR decomposition of \c *this. 55 | * 56 | * \sa class QR 57 | */ 58 | template 59 | const QR::PlainObject> 60 | MatrixBase::qr() const 61 | { 62 | return QR(eval()); 63 | } 64 | 65 | } // end namespace Eigen 66 | 67 | #endif // EIGEN2_QR_H 68 | -------------------------------------------------------------------------------- /bakeryoptix/utils/dbg_output.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define BOOST_PP_CAT_I(a, b) a ## b 4 | #define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b) 5 | #define BOOST_PP_VARIADIC_SIZE(...) BOOST_PP_CAT(BOOST_PP_VARIADIC_SIZE_I(__VA_ARGS__, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,),) 6 | #define BOOST_PP_VARIADIC_SIZE_I(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63, size, ...) size 7 | #define BOOST_PP_OVERLOAD(prefix, ...) BOOST_PP_CAT(prefix, BOOST_PP_VARIADIC_SIZE(__VA_ARGS__)) 8 | 9 | #define DBG_OUT(V) ", " #V "=" << (V) 10 | #define DBG_1(V) #V "="<< (V) 11 | #define DBG_2(V, V1) #V "="<< (V) << DBG_OUT(V1) 12 | #define DBG_3(V, V1, V2) #V "="<< (V) << DBG_OUT(V1) << DBG_OUT(V2) 13 | #define DBG_4(V, V1, V2, V3) #V "="<< (V) << DBG_OUT(V1) << DBG_OUT(V2) << DBG_OUT(V3) 14 | #define DBG_5(V, V1, V2, V3, V4) #V "="<< (V) << DBG_OUT(V1) << DBG_OUT(V2) << DBG_OUT(V3) << DBG_OUT(V4) 15 | #define DBG_6(V, V1, V2, V3, V4, V5) #V "="<< (V) << DBG_OUT(V1) << DBG_OUT(V2) << DBG_OUT(V3) << DBG_OUT(V4) << DBG_OUT(V5) 16 | #define DBG_7(V, V1, V2, V3, V4, V5, V6) #V "="<< (V) << DBG_OUT(V1) << DBG_OUT(V2) << DBG_OUT(V3) << DBG_OUT(V4) << DBG_OUT(V5) << DBG_OUT(V6) 17 | #define OUTPUT(...) __VA_ARGS__ 18 | #define DBG(...) std::cout << "[" << __func__ << ":" << __LINE__ << "] " << OUTPUT(BOOST_PP_OVERLOAD(DBG_, __VA_ARGS__)(__VA_ARGS__)) << std::endl; 19 | #define DBG_FN(...) std::cout << "[" << __func__ << ":" << __LINE__ << "] " << OUTPUT(BOOST_PP_OVERLOAD(DBG_, __VA_ARGS__)(__VA_ARGS__)) << std::endl; 20 | 21 | // #define DEVELOPMENT_CFG 22 | #ifdef DEVELOPMENT_CFG 23 | #define DEBUGTIME __pragma(optimize("", off)) 24 | #else 25 | #define DEBUGTIME 26 | #endif -------------------------------------------------------------------------------- /bakeryoptix/bake_ao_optix_prime.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018, NVIDIA CORPORATION. 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 5 | * are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of NVIDIA CORPORATION nor the names of its 12 | * contributors may be used to endorse or promote products derived 13 | * from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #pragma once 29 | #include 30 | 31 | namespace bake 32 | { 33 | void ao_optix_prime(const std::vector& blockers, 34 | const AOSamples& ao_samples, int rays_per_sample, float albedo, uint32_t bounce_counts, 35 | float scene_offset_scale_horizontal, float scene_offset_scale_vertical, float trees_light_pass_chance, 36 | uint32_t stack_size, size_t batch_size, bool debug_mode, float* ao_values); 37 | } 38 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/plugins/MatrixCwiseUnaryOps.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | // This file is a base class plugin containing matrix specifics coefficient wise functions. 12 | 13 | /** \returns an expression of the coefficient-wise absolute value of \c *this 14 | * 15 | * Example: \include MatrixBase_cwiseAbs.cpp 16 | * Output: \verbinclude MatrixBase_cwiseAbs.out 17 | * 18 | * \sa cwiseAbs2() 19 | */ 20 | EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> 21 | cwiseAbs() const { return derived(); } 22 | 23 | /** \returns an expression of the coefficient-wise squared absolute value of \c *this 24 | * 25 | * Example: \include MatrixBase_cwiseAbs2.cpp 26 | * Output: \verbinclude MatrixBase_cwiseAbs2.out 27 | * 28 | * \sa cwiseAbs() 29 | */ 30 | EIGEN_STRONG_INLINE const CwiseUnaryOp, const Derived> 31 | cwiseAbs2() const { return derived(); } 32 | 33 | /** \returns an expression of the coefficient-wise square root of *this. 34 | * 35 | * Example: \include MatrixBase_cwiseSqrt.cpp 36 | * Output: \verbinclude MatrixBase_cwiseSqrt.out 37 | * 38 | * \sa cwisePow(), cwiseSquare() 39 | */ 40 | inline const CwiseUnaryOp, const Derived> 41 | cwiseSqrt() const { return derived(); } 42 | 43 | /** \returns an expression of the coefficient-wise inverse of *this. 44 | * 45 | * Example: \include MatrixBase_cwiseInverse.cpp 46 | * Output: \verbinclude MatrixBase_cwiseInverse.out 47 | * 48 | * \sa cwiseProduct() 49 | */ 50 | inline const CwiseUnaryOp, const Derived> 51 | cwiseInverse() const { return derived(); } 52 | 53 | -------------------------------------------------------------------------------- /bakeryoptix/bake_sample.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018, NVIDIA CORPORATION. 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 5 | * are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of NVIDIA CORPORATION nor the names of its 12 | * contributors may be used to endorse or promote products derived 13 | * from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #pragma once 29 | #include "bake_api.h" 30 | 31 | namespace bake 32 | { 33 | size_t distribute_samples(const Scene& scene, size_t min_samples_per_triangle, size_t requested_num_samples, size_t* num_samples_per_instance); 34 | void sample_instances(const Scene& scene, const size_t* num_samples_per_instance, size_t min_samples_per_triangle, 35 | bool disable_normals, bool missing_normals_up, bool fix_incorrect_normals, AOSamples& ao_samples); 36 | } 37 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/SparseCore: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSECORE_MODULE_H 2 | #define EIGEN_SPARSECORE_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | /** 15 | * \defgroup SparseCore_Module SparseCore module 16 | * 17 | * This module provides a sparse matrix representation, and basic associated matrix manipulations 18 | * and operations. 19 | * 20 | * See the \ref TutorialSparse "Sparse tutorial" 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * This module depends on: Core. 27 | */ 28 | 29 | namespace Eigen { 30 | 31 | /** The type used to identify a general sparse storage. */ 32 | struct Sparse {}; 33 | 34 | } 35 | 36 | #include "src/SparseCore/SparseUtil.h" 37 | #include "src/SparseCore/SparseMatrixBase.h" 38 | #include "src/SparseCore/CompressedStorage.h" 39 | #include "src/SparseCore/AmbiVector.h" 40 | #include "src/SparseCore/SparseMatrix.h" 41 | #include "src/SparseCore/MappedSparseMatrix.h" 42 | #include "src/SparseCore/SparseVector.h" 43 | #include "src/SparseCore/SparseBlock.h" 44 | #include "src/SparseCore/SparseTranspose.h" 45 | #include "src/SparseCore/SparseCwiseUnaryOp.h" 46 | #include "src/SparseCore/SparseCwiseBinaryOp.h" 47 | #include "src/SparseCore/SparseDot.h" 48 | #include "src/SparseCore/SparsePermutation.h" 49 | #include "src/SparseCore/SparseRedux.h" 50 | #include "src/SparseCore/SparseFuzzy.h" 51 | #include "src/SparseCore/ConservativeSparseSparseProduct.h" 52 | #include "src/SparseCore/SparseSparseProductWithPruning.h" 53 | #include "src/SparseCore/SparseProduct.h" 54 | #include "src/SparseCore/SparseDenseProduct.h" 55 | #include "src/SparseCore/SparseDiagonalProduct.h" 56 | #include "src/SparseCore/SparseTriangularView.h" 57 | #include "src/SparseCore/SparseSelfAdjointView.h" 58 | #include "src/SparseCore/TriangularSolver.h" 59 | #include "src/SparseCore/SparseView.h" 60 | 61 | #include "src/Core/util/ReenableStupidWarnings.h" 62 | 63 | #endif // EIGEN_SPARSECORE_MODULE_H 64 | 65 | -------------------------------------------------------------------------------- /bakeryoptix/utils/binary_reader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace utils 10 | { 11 | using namespace optix; 12 | 13 | class binary_reader 14 | { 15 | public: 16 | explicit binary_reader(std::basic_istream& stream, uint32_t buffer_size = 8192); 17 | explicit binary_reader(const path& path, uint32_t buffer_size = 8192); 18 | ~binary_reader(); 19 | 20 | void skip(uint32_t count); 21 | void skip_string(); 22 | std::string read_string(); 23 | std::string read_rest(); 24 | std::string read_data(uint size); 25 | bool match(const char* str); 26 | char read_char(); 27 | bool read_bool(); 28 | 29 | int read_int() { return read_ref(); } 30 | uint32_t read_uint() { return read_ref(); } 31 | uint64_t read_uint64() { return read_ref(); } 32 | uint16_t read_ushort() { return read_ref(); } 33 | float read_float() { return read_ref(); } 34 | float2 read_f2() { return read_ref().optix(); } 35 | float3 read_f3() { return read_ref().optix(); } 36 | float4 read_f4() { return read_ref().optix(); } 37 | const bake::NodeTransformation& read_f4x4() { return read_ref(); } 38 | 39 | template 40 | const T& read_ref() 41 | { 42 | return *reinterpret_cast(&buffer_[get_pos_and_move(sizeof(T))]); 43 | } 44 | 45 | private: 46 | struct vec2 47 | { 48 | float x, y; 49 | float2 optix() const { return float2{x, y}; } 50 | }; 51 | 52 | struct vec3 53 | { 54 | float x, y, z; 55 | float3 optix() const { return float3{x, y, z}; } 56 | }; 57 | 58 | struct vec4 59 | { 60 | float x, y, z, w; 61 | float4 optix() const { return float4{x, y, z, w}; } 62 | }; 63 | 64 | std::basic_istream* stream_; 65 | char* buffer_; 66 | uint32_t left_{}, total_{}; 67 | bool own_; 68 | uint32_t buffer_size_; 69 | 70 | char next_char(); 71 | int get_pos_and_move(uint32_t count); 72 | void require(uint32_t count); 73 | }; 74 | } 75 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/plugins/CommonCwiseBinaryOps.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | // This file is a base class plugin containing common coefficient wise functions. 12 | 13 | /** \returns an expression of the difference of \c *this and \a other 14 | * 15 | * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-(). 16 | * 17 | * \sa class CwiseBinaryOp, operator-=() 18 | */ 19 | EIGEN_MAKE_CWISE_BINARY_OP(operator-,internal::scalar_difference_op) 20 | 21 | /** \returns an expression of the sum of \c *this and \a other 22 | * 23 | * \note If you want to add a given scalar to all coefficients, see Cwise::operator+(). 24 | * 25 | * \sa class CwiseBinaryOp, operator+=() 26 | */ 27 | EIGEN_MAKE_CWISE_BINARY_OP(operator+,internal::scalar_sum_op) 28 | 29 | /** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other 30 | * 31 | * The template parameter \a CustomBinaryOp is the type of the functor 32 | * of the custom operator (see class CwiseBinaryOp for an example) 33 | * 34 | * Here is an example illustrating the use of custom functors: 35 | * \include class_CwiseBinaryOp.cpp 36 | * Output: \verbinclude class_CwiseBinaryOp.out 37 | * 38 | * \sa class CwiseBinaryOp, operator+(), operator-(), cwiseProduct() 39 | */ 40 | template 41 | EIGEN_STRONG_INLINE const CwiseBinaryOp 42 | binaryExpr(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other, const CustomBinaryOp& func = CustomBinaryOp()) const 43 | { 44 | return CwiseBinaryOp(derived(), other.derived(), func); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/SuperLUSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SUPERLUSUPPORT_MODULE_H 2 | #define EIGEN_SUPERLUSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #ifdef EMPTY 9 | #define EIGEN_EMPTY_WAS_ALREADY_DEFINED 10 | #endif 11 | 12 | typedef int int_t; 13 | #include 14 | #include 15 | #include 16 | 17 | // slu_util.h defines a preprocessor token named EMPTY which is really polluting, 18 | // so we remove it in favor of a SUPERLU_EMPTY token. 19 | // If EMPTY was already defined then we don't undef it. 20 | 21 | #if defined(EIGEN_EMPTY_WAS_ALREADY_DEFINED) 22 | # undef EIGEN_EMPTY_WAS_ALREADY_DEFINED 23 | #elif defined(EMPTY) 24 | # undef EMPTY 25 | #endif 26 | 27 | #define SUPERLU_EMPTY (-1) 28 | 29 | namespace Eigen { struct SluMatrix; } 30 | 31 | /** \ingroup Support_modules 32 | * \defgroup SuperLUSupport_Module SuperLUSupport module 33 | * 34 | * This module provides an interface to the SuperLU library. 35 | * It provides the following factorization class: 36 | * - class SuperLU: a supernodal sequential LU factorization. 37 | * - class SuperILU: a supernodal sequential incomplete LU factorization (to be used as a preconditioner for iterative methods). 38 | * 39 | * \warning When including this module, you have to use SUPERLU_EMPTY instead of EMPTY which is no longer defined because it is too polluting. 40 | * 41 | * \code 42 | * #include 43 | * \endcode 44 | * 45 | * In order to use this module, the superlu headers must be accessible from the include paths, and your binary must be linked to the superlu library and its dependencies. 46 | * The dependencies depend on how superlu has been compiled. 47 | * For a cmake based project, you can use our FindSuperLU.cmake module to help you in this task. 48 | * 49 | */ 50 | 51 | #include "src/misc/Solve.h" 52 | #include "src/misc/SparseSolve.h" 53 | 54 | #include "src/SuperLUSupport/SuperLUSupport.h" 55 | 56 | 57 | #include "src/Core/util/ReenableStupidWarnings.h" 58 | 59 | #endif // EIGEN_SUPERLUSUPPORT_MODULE_H 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## AO bakery for Assetto Corsa 2 | 3 | This is a CUDA-accelerated ambient occlusion bakery for racing simulator Assetto Corsa with Custom Shaders Patch, supporting tracks and cars. Made possible with NVIDIA OptiX, forked from [this project](https://github.com/nvpro-samples/optix_prime_baking). 4 | 5 | [![Model by Kunos](https://i.imgur.com/pzCpqUV.jpg)](https://i.imgur.com/pzCpqUV.jpg) 6 | 7 | ## Features 8 | 9 | - Tracks: 10 | 11 | - Both KN5 and INI files are supported as inputs; 12 | - Special trees baking (without self-occlusion, with normals facing up); 13 | - Special grass baking (without any shadows from grass, with normals facing up); 14 | - Optional trees transparency factor; 15 | - Skips dynamic objects to shadow them dynamically later on; 16 | - Baking of extra samples along the track for occlusion for dynamic objects; 17 | - Rebaking of overly darken areas with increased number of rays per triangle. 18 | 19 | - Cars: 20 | 21 | - Full LODs support, as well as COCKPIT_HR/COCKPIT_LR; 22 | - Special processing for seatbelts; 23 | - Special processing for rotating objects to keep shadows uniform; 24 | - AO splitting for doors, steering wheel and other animations, allowing to transition between AO values realtime ([demo](https://gfycat.com/felinepassionateangwantibo)); 25 | - Baking shadows for driver; 26 | - Baking shadows from driver in an alternative AO set; 27 | - Raising ambient brightness to compensate for new AO; 28 | - Extra pass for adding a bit of light “bounced” from the ground; 29 | 30 | - Takes into account light bounces to keep AO brighter; 31 | - Alter brightness, opacity and gamma for resulting AO; 32 | - Adjust AO per-object if necessary; 33 | - Adjust sampling offsets per-object to get rid of arifacts in complicated cases. 34 | 35 | ## Tips 36 | 37 | - Various options could be changed in `baked_shadow_params.ini`; 38 | - NVIDIA GPU is required; 39 | - Works much faster on RTX GPUs, but can also use older NVIDIA GPUs with CUDA, although works a lot slower with those (disable light bounces to improve the speed). 40 | 41 | ## Credits 42 | 43 | - Project based on [Optix Prime baking](https://github.com/nvpro-samples/optix_prime_baking); 44 | - Powered by NVIDIA Optix. 45 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/CoreIterators.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_COREITERATORS_H 11 | #define EIGEN_COREITERATORS_H 12 | 13 | namespace Eigen { 14 | 15 | /* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core 16 | */ 17 | 18 | /** \ingroup SparseCore_Module 19 | * \class InnerIterator 20 | * \brief An InnerIterator allows to loop over the element of a sparse (or dense) matrix or expression 21 | * 22 | * todo 23 | */ 24 | 25 | // generic version for dense matrix and expressions 26 | template class DenseBase::InnerIterator 27 | { 28 | protected: 29 | typedef typename Derived::Scalar Scalar; 30 | typedef typename Derived::Index Index; 31 | 32 | enum { IsRowMajor = (Derived::Flags&RowMajorBit)==RowMajorBit }; 33 | public: 34 | EIGEN_STRONG_INLINE InnerIterator(const Derived& expr, Index outer) 35 | : m_expression(expr), m_inner(0), m_outer(outer), m_end(expr.innerSize()) 36 | {} 37 | 38 | EIGEN_STRONG_INLINE Scalar value() const 39 | { 40 | return (IsRowMajor) ? m_expression.coeff(m_outer, m_inner) 41 | : m_expression.coeff(m_inner, m_outer); 42 | } 43 | 44 | EIGEN_STRONG_INLINE InnerIterator& operator++() { m_inner++; return *this; } 45 | 46 | EIGEN_STRONG_INLINE Index index() const { return m_inner; } 47 | inline Index row() const { return IsRowMajor ? m_outer : index(); } 48 | inline Index col() const { return IsRowMajor ? index() : m_outer; } 49 | 50 | EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; } 51 | 52 | protected: 53 | const Derived& m_expression; 54 | Index m_inner; 55 | const Index m_outer; 56 | const Index m_end; 57 | }; 58 | 59 | } // end namespace Eigen 60 | 61 | #endif // EIGEN_COREITERATORS_H 62 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Core/util/DisableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_WARNINGS_DISABLED 2 | #define EIGEN_WARNINGS_DISABLED 3 | 4 | #ifdef _MSC_VER 5 | // 4100 - unreferenced formal parameter (occurred e.g. in aligned_allocator::destroy(pointer p)) 6 | // 4101 - unreferenced local variable 7 | // 4127 - conditional expression is constant 8 | // 4181 - qualifier applied to reference type ignored 9 | // 4211 - nonstandard extension used : redefined extern to static 10 | // 4244 - 'argument' : conversion from 'type1' to 'type2', possible loss of data 11 | // 4273 - QtAlignedMalloc, inconsistent DLL linkage 12 | // 4324 - structure was padded due to declspec(align()) 13 | // 4512 - assignment operator could not be generated 14 | // 4522 - 'class' : multiple assignment operators specified 15 | // 4700 - uninitialized local variable 'xyz' used 16 | // 4717 - 'function' : recursive on all control paths, function will cause runtime stack overflow 17 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 18 | #pragma warning( push ) 19 | #endif 20 | #pragma warning( disable : 4100 4101 4127 4181 4211 4244 4273 4324 4512 4522 4700 4717 ) 21 | #elif defined __INTEL_COMPILER 22 | // 2196 - routine is both "inline" and "noinline" ("noinline" assumed) 23 | // ICC 12 generates this warning even without any inline keyword, when defining class methods 'inline' i.e. inside of class body 24 | // typedef that may be a reference type. 25 | // 279 - controlling expression is constant 26 | // ICC 12 generates this warning on assert(constant_expression_depending_on_template_params) and frankly this is a legitimate use case. 27 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 28 | #pragma warning push 29 | #endif 30 | #pragma warning disable 2196 279 31 | #elif defined __clang__ 32 | // -Wconstant-logical-operand - warning: use of logical && with constant operand; switch to bitwise & or remove constant 33 | // this is really a stupid warning as it warns on compile-time expressions involving enums 34 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 35 | #pragma clang diagnostic push 36 | #endif 37 | #pragma clang diagnostic ignored "-Wconstant-logical-operand" 38 | #endif 39 | 40 | #endif // not EIGEN_WARNINGS_DISABLED 41 | -------------------------------------------------------------------------------- /bakeryoptix/rayexception.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-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 | #include "ray.h" 30 | 31 | rtBuffer sysOutputBuffer; // RGBA32F 32 | rtDeclareVariable(uint2, theLaunchIndex, rtLaunchIndex, ); 33 | 34 | RT_PROGRAM void rayexception() 35 | { 36 | #if USE_DEBUG_EXCEPTIONS 37 | const unsigned int code = rtGetExceptionCode(); 38 | if (RT_EXCEPTION_USER <= code) 39 | { 40 | rtPrintf("User exception %d at (%d, %d)\n", code - RT_EXCEPTION_USER, theLaunchIndex.x, theLaunchIndex.y); 41 | } 42 | else 43 | { 44 | rtPrintf("Exception code 0x%X at (%d, %d)\n", code, theLaunchIndex.x, theLaunchIndex.y); 45 | } 46 | 47 | sysOutputBuffer[theLaunchIndex] = 0.f; 48 | #endif 49 | } 50 | -------------------------------------------------------------------------------- /bakeryoptix/rayanyhit_proctree.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-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 | #include "ray.h" 30 | 31 | #include 32 | #include 33 | 34 | // Attributes. 35 | rtDeclareVariable(optix::float3, varGeoNormal, attribute GEO_NORMAL, ); 36 | //rtDeclareVariable(optix::float3, varTangent, attribute TANGENT, ); 37 | rtDeclareVariable(optix::float3, varNormal, attribute NORMAL, ); 38 | rtDeclareVariable(optix::float3, varTexCoord, attribute TEXCOORD, ); 39 | 40 | RT_FUNCTION float frac(float v) 41 | { 42 | return v - floorf(v); 43 | } 44 | 45 | RT_PROGRAM void rayanyhit_proctree() 46 | { 47 | if (frac(varTexCoord.x * 697.4581 + varTexCoord.y * 246.5266) < 0.5) 48 | { 49 | rtIgnoreIntersection(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SparseLU/SparseLU_Utils.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | 11 | #ifndef EIGEN_SPARSELU_UTILS_H 12 | #define EIGEN_SPARSELU_UTILS_H 13 | 14 | namespace Eigen { 15 | namespace internal { 16 | 17 | /** 18 | * \brief Count Nonzero elements in the factors 19 | */ 20 | template 21 | void SparseLUImpl::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu) 22 | { 23 | nnzL = 0; 24 | nnzU = (glu.xusub)(n); 25 | Index nsuper = (glu.supno)(n); 26 | Index jlen; 27 | Index i, j, fsupc; 28 | if (n <= 0 ) return; 29 | // For each supernode 30 | for (i = 0; i <= nsuper; i++) 31 | { 32 | fsupc = glu.xsup(i); 33 | jlen = glu.xlsub(fsupc+1) - glu.xlsub(fsupc); 34 | 35 | for (j = fsupc; j < glu.xsup(i+1); j++) 36 | { 37 | nnzL += jlen; 38 | nnzU += j - fsupc + 1; 39 | jlen--; 40 | } 41 | } 42 | } 43 | 44 | /** 45 | * \brief Fix up the data storage lsub for L-subscripts. 46 | * 47 | * It removes the subscripts sets for structural pruning, 48 | * and applies permutation to the remaining subscripts 49 | * 50 | */ 51 | template 52 | void SparseLUImpl::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu) 53 | { 54 | Index fsupc, i, j, k, jstart; 55 | 56 | Index nextl = 0; 57 | Index nsuper = (glu.supno)(n); 58 | 59 | // For each supernode 60 | for (i = 0; i <= nsuper; i++) 61 | { 62 | fsupc = glu.xsup(i); 63 | jstart = glu.xlsub(fsupc); 64 | glu.xlsub(fsupc) = nextl; 65 | for (j = jstart; j < glu.xlsub(fsupc + 1); j++) 66 | { 67 | glu.lsub(nextl) = perm_r(glu.lsub(j)); // Now indexed into P*A 68 | nextl++; 69 | } 70 | for (k = fsupc+1; k < glu.xsup(i+1); k++) 71 | glu.xlsub(k) = nextl; // other columns in supernode i 72 | } 73 | 74 | glu.xlsub(n) = nextl; 75 | } 76 | 77 | } // end namespace internal 78 | 79 | } // end namespace Eigen 80 | #endif // EIGEN_SPARSELU_UTILS_H 81 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/COPYING.MINPACK: -------------------------------------------------------------------------------- 1 | Minpack Copyright Notice (1999) University of Chicago. All rights reserved 2 | 3 | Redistribution and use in source and binary forms, with or 4 | without modification, are permitted provided that the 5 | following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above 8 | copyright notice, this list of conditions and the following 9 | disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials 14 | provided with the distribution. 15 | 16 | 3. The end-user documentation included with the 17 | redistribution, if any, must include the following 18 | acknowledgment: 19 | 20 | "This product includes software developed by the 21 | University of Chicago, as Operator of Argonne National 22 | Laboratory. 23 | 24 | Alternately, this acknowledgment may appear in the software 25 | itself, if and wherever such third-party acknowledgments 26 | normally appear. 27 | 28 | 4. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" 29 | WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE 30 | UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND 31 | THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES 33 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE 34 | OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY 35 | OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR 36 | USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF 37 | THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4) 38 | DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION 39 | UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL 40 | BE CORRECTED. 41 | 42 | 5. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT 43 | HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF 44 | ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT, 45 | INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF 46 | ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF 47 | PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER 48 | SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT 49 | (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE, 50 | EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE 51 | POSSIBILITY OF SUCH LOSS OR DAMAGES. 52 | 53 | -------------------------------------------------------------------------------- /bakeryoptix/dx_shaders.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | inline std::string dx_shader_copy_ps(){ 5 | std::string s; 6 | s += "RFhCQ8zBy2pUDJ18Qc/3elWZyxQBAAAApAIAAAUAAAA0AAAA/AAAAFQBAACIAQAACAIAAFJERUbAAAAAAAAAAAAAAAACAAAAPAAAAAAF//8AgQAAlgAAAFJE"; 7 | s += "MTE8AAAAGAAAACAAAAAoAAAAJAAAAAwAAAAAAAAAfAAAAAMAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAEAAACMAAAAAgAAAAUAAAAEAAAA/////wAAAAABAAAA"; 8 | s += "DQAAAHNhbUxpbmVhclNpbXBsZQB0eERpZmZ1c2UATWljcm9zb2Z0IChSKSBITFNMIFNoYWRlciBDb21waWxlciAxMC4xAKurSVNHTlAAAAACAAAACAAAADgA"; 9 | s += "AAAAAAAAAQAAAAMAAAAAAAAADwAAAEQAAAAAAAAAAAAAAAMAAAABAAAAAwMAAFNWX1BPU0lUSU9OAFRFWENPT1JEAKurq09TR04sAAAAAQAAAAgAAAAgAAAA"; 10 | s += "AAAAAAAAAAADAAAAAAAAAA8AAABTVl9UQVJHRVQAq6tTSEVYeAAAAFAAAAAeAAAAaggAAVoAAAMAYBAABQAAAFgYAAQAcBAAAAAAAFVVAABiIAADMhAQAAEA"; 11 | s += "AABlAAAD8iAQAAAAAABIAACNwgAAgENVFQDyIBAAAAAAAEYQEAABAAAARn4QAAAAAAAAYBAABQAAAAFAAAAAAAAAPgAAAVNUQVSUAAAAAgAAAAAAAAAAAAAA"; 12 | s += "AgAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; 13 | s += "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="; 14 | return s; 15 | } 16 | 17 | inline std::string dx_shader_copy_vs(){ 18 | std::string s; 19 | s += "RFhCQ/NetZBsNAVW3prs7M2DgdMBAAAAFAMAAAUAAAA0AAAAoAAAANQAAAAsAQAAeAIAAFJERUZkAAAAAAAAAAAAAAAAAAAAPAAAAAAF/v8AgQAAPAAAAFJE"; 20 | s += "MTE8AAAAGAAAACAAAAAoAAAAJAAAAAwAAAAAAAAATWljcm9zb2Z0IChSKSBITFNMIFNoYWRlciBDb21waWxlciAxMC4xAElTR04sAAAAAQAAAAgAAAAgAAAA"; 21 | s += "AAAAAAYAAAABAAAAAAAAAAEBAABTVl9WZXJ0ZXhJRABPU0dOUAAAAAIAAAAIAAAAOAAAAAAAAAABAAAAAwAAAAAAAAAPAAAARAAAAAAAAAAAAAAAAwAAAAEA"; 22 | s += "AAADDAAAU1ZfUE9TSVRJT04AVEVYQ09PUkQAq6urU0hFWEQBAABQAAEAUQAAAGoIAAFgAAAEEhAQAAAAAAAGAAAAZwAABPIgEAAAAAAAAQAAAGUAAAMyIBAA"; 23 | s += "AQAAAGgAAAIBAAAAAQAABxIAEAAAAAAAChAQAAAAAAABQAAAAQAAAFUAAAdCABAAAAAAAAoQEAAAAAAAAUAAAAEAAABWAAAFMgAQAAAAAACGABAAAAAAADIA"; 24 | s += "AA8yIBAAAAAAAEYAEAAAAAAAAkAAAAAAgEAAAIBAAAAAAAAAAAACQAAAAACAvwAAgL8AAAAAAAAAAAAAAAcSABAAAAAAAAoAEAAAAAAACgAQAAAAAAAyAAAK"; 25 | s += "QgAQAAAAAAAaABCAQQAAAAAAAAABQAAAAAAAQAFAAAAAAIA/NgAABTIgEAABAAAAhgAQAAAAAAA2AAAIwiAQAAAAAAACQAAAAAAAAAAAAAAAAAAAAACAPz4A"; 26 | s += "AAFTVEFUlAAAAAkAAAABAAAAAAAAAAMAAAADAAAAAAAAAAIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAA"; 27 | s += "AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; 28 | return s; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/Lazy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_LAZY_H 11 | #define EIGEN_LAZY_H 12 | 13 | namespace Eigen { 14 | 15 | /** \deprecated it is only used by lazy() which is deprecated 16 | * 17 | * \returns an expression of *this with added flags 18 | * 19 | * Example: \include MatrixBase_marked.cpp 20 | * Output: \verbinclude MatrixBase_marked.out 21 | * 22 | * \sa class Flagged, extract(), part() 23 | */ 24 | template 25 | template 26 | inline const Flagged 27 | MatrixBase::marked() const 28 | { 29 | return derived(); 30 | } 31 | 32 | /** \deprecated use MatrixBase::noalias() 33 | * 34 | * \returns an expression of *this with the EvalBeforeAssigningBit flag removed. 35 | * 36 | * Example: \include MatrixBase_lazy.cpp 37 | * Output: \verbinclude MatrixBase_lazy.out 38 | * 39 | * \sa class Flagged, marked() 40 | */ 41 | template 42 | inline const Flagged 43 | MatrixBase::lazy() const 44 | { 45 | return derived(); 46 | } 47 | 48 | 49 | /** \internal 50 | * Overloaded to perform an efficient C += (A*B).lazy() */ 51 | template 52 | template 53 | Derived& MatrixBase::operator+=(const Flagged, 0, 54 | EvalBeforeAssigningBit>& other) 55 | { 56 | other._expression().derived().addTo(derived()); return derived(); 57 | } 58 | 59 | /** \internal 60 | * Overloaded to perform an efficient C -= (A*B).lazy() */ 61 | template 62 | template 63 | Derived& MatrixBase::operator-=(const Flagged, 0, 64 | EvalBeforeAssigningBit>& other) 65 | { 66 | other._expression().derived().subTo(derived()); return derived(); 67 | } 68 | 69 | } // end namespace Eigen 70 | 71 | #endif // EIGEN_LAZY_H 72 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/OrderingMethods: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ORDERINGMETHODS_MODULE_H 2 | #define EIGEN_ORDERINGMETHODS_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** 9 | * \defgroup OrderingMethods_Module OrderingMethods module 10 | * 11 | * This module is currently for internal use only 12 | * 13 | * It defines various built-in and external ordering methods for sparse matrices. 14 | * They are typically used to reduce the number of elements during 15 | * the sparse matrix decomposition (LLT, LU, QR). 16 | * Precisely, in a preprocessing step, a permutation matrix P is computed using 17 | * those ordering methods and applied to the columns of the matrix. 18 | * Using for instance the sparse Cholesky decomposition, it is expected that 19 | * the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A). 20 | * 21 | * 22 | * Usage : 23 | * \code 24 | * #include 25 | * \endcode 26 | * 27 | * A simple usage is as a template parameter in the sparse decomposition classes : 28 | * 29 | * \code 30 | * SparseLU > solver; 31 | * \endcode 32 | * 33 | * \code 34 | * SparseQR > solver; 35 | * \endcode 36 | * 37 | * It is possible as well to call directly a particular ordering method for your own purpose, 38 | * \code 39 | * AMDOrdering ordering; 40 | * PermutationMatrix perm; 41 | * SparseMatrix A; 42 | * //Fill the matrix ... 43 | * 44 | * ordering(A, perm); // Call AMD 45 | * \endcode 46 | * 47 | * \note Some of these methods (like AMD or METIS), need the sparsity pattern 48 | * of the input matrix to be symmetric. When the matrix is structurally unsymmetric, 49 | * Eigen computes internally the pattern of \f$A^T*A\f$ before calling the method. 50 | * If your matrix is already symmetric (at leat in structure), you can avoid that 51 | * by calling the method with a SelfAdjointView type. 52 | * 53 | * \code 54 | * // Call the ordering on the pattern of the lower triangular matrix A 55 | * ordering(A.selfadjointView(), perm); 56 | * \endcode 57 | */ 58 | 59 | #ifndef EIGEN_MPL2_ONLY 60 | #include "src/OrderingMethods/Amd.h" 61 | #endif 62 | 63 | #include "src/OrderingMethods/Ordering.h" 64 | #include "src/Core/util/ReenableStupidWarnings.h" 65 | 66 | #endif // EIGEN_ORDERINGMETHODS_MODULE_H 67 | -------------------------------------------------------------------------------- /bakeryoptix/raybb.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-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 | #include "ray.h" 30 | #include 31 | #include 32 | 33 | struct vertex 34 | { 35 | float3 pos; 36 | float3 tex; 37 | }; 38 | 39 | rtBuffer attributesBuffer; 40 | rtBuffer indicesBuffer; 41 | 42 | // Axis Aligned Bounding Box routine for indexed interleaved triangle data. 43 | RT_PROGRAM void raybb(int primitiveIndex, float result[6]) 44 | { 45 | const uint3 indices = indicesBuffer[primitiveIndex]; 46 | const float3 v0 = attributesBuffer[indices.x].pos; 47 | const float3 v1 = attributesBuffer[indices.y].pos; 48 | const float3 v2 = attributesBuffer[indices.z].pos; 49 | const float area = optix::length(optix::cross(v1 - v0, v2 - v0)); 50 | 51 | optix::Aabb* aabb = (optix::Aabb*)result; 52 | if (0.0f < area && !isinf(area)) 53 | { 54 | aabb->m_min = fminf(fminf(v0, v1), v2); 55 | aabb->m_max = fmaxf(fmaxf(v0, v1), v2); 56 | } 57 | else 58 | { 59 | aabb->invalidate(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /bakeryoptix/bake_kernels__cpu.cpp: -------------------------------------------------------------------------------- 1 | #include "bake_kernels__cpu.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace bake 9 | { 10 | using optix::float3; 11 | 12 | inline int idiv_ceil(const int x, const int y) 13 | { 14 | return (x + y - 1) / y; 15 | } 16 | 17 | // Ray generation kernel 18 | void generate_rays_kernel( 19 | const size_t idx, 20 | const unsigned int base_seed, 21 | const int px, 22 | const int py, 23 | const int sqrt_passes, 24 | const float scene_offset, 25 | const float3* sample_normals, 26 | const float3* sample_face_normals, 27 | const float3* sample_positions, 28 | bake::Ray* rays) 29 | { 30 | const unsigned int tea_seed = (base_seed << 16) | (px * sqrt_passes + py); 31 | unsigned seed = tea<2>(tea_seed, unsigned(idx)); 32 | 33 | const float3 sample_norm = sample_normals[idx]; 34 | const float3 sample_face_norm = sample_face_normals[idx]; 35 | const float3 sample_pos = sample_positions[idx]; 36 | const float3 ray_origin = sample_pos + scene_offset * sample_norm; 37 | optix::Onb onb(sample_norm); 38 | 39 | float3 ray_dir; 40 | float u0 = (static_cast(px) + rnd(seed)) / static_cast(sqrt_passes); 41 | float u1 = (static_cast(py) + rnd(seed)) / static_cast(sqrt_passes); 42 | int j = 0; 43 | do 44 | { 45 | optix::cosine_sample_hemisphere(u0, u1, ray_dir); 46 | 47 | onb.inverse_transform(ray_dir); 48 | ++j; 49 | u0 = rnd(seed); 50 | u1 = rnd(seed); 51 | } 52 | while (j < 5 && optix::dot(ray_dir, sample_face_norm) <= 0.0f); 53 | 54 | rays[idx].origin = ray_origin; 55 | rays[idx].direction = ray_dir; 56 | } 57 | 58 | void generate_rays_host(unsigned seed, int px, int py, int sqrt_passes, float scene_offset, const AOSamples& ao_samples, Ray* rays) 59 | { 60 | #pragma omp parallel for 61 | for (auto i = 0U; i < ao_samples.num_samples; i++) 62 | { 63 | generate_rays_kernel(i, seed, px, py, sqrt_passes, scene_offset, (float3*)ao_samples.sample_normals, 64 | (float3*)ao_samples.sample_face_normals, (float3*)ao_samples.sample_positions, rays); 65 | } 66 | } 67 | 68 | void update_ao_kernel(size_t idx, float max_distance, const float* hit_data, float* ao_data) 69 | { 70 | ao_data[idx] += hit_data[idx] > 0.0 && hit_data[idx] < max_distance ? 1.0f : 0.0f; 71 | } 72 | 73 | void update_ao_host(size_t num_samples, float max_distance, const float* hits, float* ao) 74 | { 75 | #pragma omp parallel for 76 | for (auto i = 0U; i < num_samples; i++) 77 | { 78 | update_ao_kernel(i, max_distance, hits, ao); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /bakeryoptix/platform.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014-2018, NVIDIA CORPORATION. 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 5 | * are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of NVIDIA CORPORATION nor the names of its 12 | * contributors may be used to endorse or promote products derived 13 | * from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef NVP_PLATFORM_H__ 29 | #define NVP_PLATFORM_H__ 30 | 31 | 32 | #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ >= 3 && __GNUC_MINOR__ >= 4)) 33 | 34 | #define NV_NOOP(...) 35 | #define NV_BARRIER() __sync_synchronize() 36 | 37 | /* 38 | // maybe better than __sync_synchronize? 39 | #if defined(__i386__ ) || defined(__x64__) 40 | #define NVP_BARRIER() __asm__ __volatile__ ("mfence" ::: "memory") 41 | #endif 42 | 43 | #if defined(__arm__) 44 | #define NVP_BARRIER() __asm__ __volatile__ ("dmb" :::"memory") 45 | #endif 46 | */ 47 | 48 | #elif defined(__MSC__) || defined(_MSC_VER) 49 | 50 | #include 51 | 52 | #pragma warning(disable:4142) // redefinition of same type 53 | #if (_MSC_VER >= 1400) // VC8+ 54 | #pragma warning(disable : 4996) // Either disable all deprecation warnings, 55 | #endif // VC8+ 56 | 57 | #define NV_NOOP __noop 58 | #define NV_BARRIER() _mm_mfence() 59 | 60 | #else 61 | #error "compiler unkown" 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /bakeryoptix/rayanyhit.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-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 | #include "ray.h" 30 | 31 | #include 32 | #include 33 | 34 | // Attributes. 35 | rtDeclareVariable(optix::float3, varGeoNormal, attribute GEO_NORMAL, ); 36 | //rtDeclareVariable(optix::float3, varTangent, attribute TANGENT, ); 37 | rtDeclareVariable(optix::float3, varNormal, attribute NORMAL, ); 38 | rtDeclareVariable(optix::float3, varTexCoord, attribute TEXCOORD, ); 39 | 40 | // Material parameter definition. 41 | rtDeclareVariable(float, parMaterialAlphaRef, , ); // Per Material index into the sysMaterialParameters array. 42 | // rtDeclareVariable(int, parMaterialTexture, , ); // Per Material index into the sysMaterialParameters array. 43 | rtTextureSampler parMaterialTexture; 44 | 45 | RT_PROGRAM void rayanyhit() 46 | { 47 | // if (true || tex2D(parMaterialTexture, varTexCoord.x, varTexCoord.y).w <= parMaterialAlphaRef) 48 | if (tex2D(parMaterialTexture, varTexCoord.x, varTexCoord.y).w <= parMaterialAlphaRef) 49 | { 50 | rtIgnoreIntersection(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SparseCore/SparseTranspose.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPARSETRANSPOSE_H 11 | #define EIGEN_SPARSETRANSPOSE_H 12 | 13 | namespace Eigen { 14 | 15 | template class TransposeImpl 16 | : public SparseMatrixBase > 17 | { 18 | typedef typename internal::remove_all::type _MatrixTypeNested; 19 | public: 20 | 21 | EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose ) 22 | 23 | class InnerIterator; 24 | class ReverseInnerIterator; 25 | 26 | inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); } 27 | }; 28 | 29 | // NOTE: VC10 and VC11 trigger an ICE if don't put typename TransposeImpl:: in front of Index, 30 | // a typedef typename TransposeImpl::Index Index; 31 | // does not fix the issue. 32 | // An alternative is to define the nested class in the parent class itself. 33 | template class TransposeImpl::InnerIterator 34 | : public _MatrixTypeNested::InnerIterator 35 | { 36 | typedef typename _MatrixTypeNested::InnerIterator Base; 37 | typedef typename TransposeImpl::Index Index; 38 | public: 39 | 40 | EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, typename TransposeImpl::Index outer) 41 | : Base(trans.derived().nestedExpression(), outer) 42 | {} 43 | typename TransposeImpl::Index row() const { return Base::col(); } 44 | typename TransposeImpl::Index col() const { return Base::row(); } 45 | }; 46 | 47 | template class TransposeImpl::ReverseInnerIterator 48 | : public _MatrixTypeNested::ReverseInnerIterator 49 | { 50 | typedef typename _MatrixTypeNested::ReverseInnerIterator Base; 51 | typedef typename TransposeImpl::Index Index; 52 | public: 53 | 54 | EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, typename TransposeImpl::Index outer) 55 | : Base(xpr.derived().nestedExpression(), outer) 56 | {} 57 | typename TransposeImpl::Index row() const { return Base::col(); } 58 | typename TransposeImpl::Index col() const { return Base::row(); } 59 | }; 60 | 61 | } // end namespace Eigen 62 | 63 | #endif // EIGEN_SPARSETRANSPOSE_H 64 | -------------------------------------------------------------------------------- /bakeryoptix/utils/vector_operations.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | template 7 | std::vector operator+(const std::vector& A, const std::vector& B) 8 | { 9 | std::vector AB; 10 | AB.reserve(A.size() + B.size()); // preallocate memory 11 | AB.insert(AB.end(), A.begin(), A.end()); // add A; 12 | AB.insert(AB.end(), B.begin(), B.end()); // add B; 13 | return AB; 14 | } 15 | 16 | template 17 | std::vector operator&(const std::vector& A, const std::vector& B) 18 | { 19 | std::vector ret; 20 | for (const auto& v : A) 21 | { 22 | if (std::find(B.begin(), B.end(), v) != B.end()) 23 | { 24 | ret.push_back(v); 25 | } 26 | } 27 | return ret; 28 | } 29 | 30 | template 31 | std::vector operator-(const std::vector& A, const std::vector& B) 32 | { 33 | std::vector result; 34 | std::set_difference( 35 | A.begin(), A.end(), 36 | B.begin(), B.end(), 37 | std::back_inserter(result)); 38 | return result; 39 | } 40 | 41 | template 42 | std::vector& operator+=(std::vector& A, const std::vector& B) 43 | { 44 | A.reserve(A.size() + B.size()); // preallocate memory without erase original data 45 | A.insert(A.end(), B.begin(), B.end()); // add B; 46 | return A; // here A could be named AB 47 | } 48 | 49 | template 50 | std::vector& operator|=(std::vector& A, const std::vector& B) 51 | { 52 | for (const auto& v : B) 53 | { 54 | if (std::find(A.begin(), A.end(), v) == A.end()) 55 | { 56 | A.push_back(v); 57 | } 58 | } 59 | return A; 60 | } 61 | 62 | template 63 | std::vector& operator-=(std::vector& A, const std::vector& B) 64 | { 65 | auto it = A.begin(); 66 | while (it != A.end()) 67 | { 68 | if (std::find(B.begin(), B.end(), *it) != B.end()) 69 | { 70 | it = A.erase(it); 71 | } 72 | else 73 | { 74 | ++it; 75 | } 76 | } 77 | return A; 78 | } 79 | 80 | template 81 | auto apply(const Container& cont, Function fun) 82 | { 83 | std::vector::type> ret; 84 | ret.reserve(cont.size()); 85 | for (const auto& v : cont) 86 | { 87 | ret.push_back(fun(v)); 88 | } 89 | return ret; 90 | } 91 | 92 | template 93 | auto where(const Container& cont, Function fun) 94 | { 95 | std::vector ret; 96 | ret.reserve(cont.size()); 97 | for (const auto& v : cont) 98 | { 99 | if (fun(v)) 100 | { 101 | ret.push_back(v); 102 | } 103 | } 104 | return ret; 105 | } 106 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/misc/Solve.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_SOLVE_H 11 | #define EIGEN_MISC_SOLVE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class solve_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix ReturnType; 30 | }; 31 | 32 | template struct solve_retval_base 33 | : public ReturnByValue > 34 | { 35 | typedef typename remove_all::type RhsNestedCleaned; 36 | typedef _DecompositionType DecompositionType; 37 | typedef ReturnByValue Base; 38 | typedef typename Base::Index Index; 39 | 40 | solve_retval_base(const DecompositionType& dec, const Rhs& rhs) 41 | : m_dec(dec), m_rhs(rhs) 42 | {} 43 | 44 | inline Index rows() const { return m_dec.cols(); } 45 | inline Index cols() const { return m_rhs.cols(); } 46 | inline const DecompositionType& dec() const { return m_dec; } 47 | inline const RhsNestedCleaned& rhs() const { return m_rhs; } 48 | 49 | template inline void evalTo(Dest& dst) const 50 | { 51 | static_cast*>(this)->evalTo(dst); 52 | } 53 | 54 | protected: 55 | const DecompositionType& m_dec; 56 | typename Rhs::Nested m_rhs; 57 | }; 58 | 59 | } // end namespace internal 60 | 61 | #define EIGEN_MAKE_SOLVE_HELPERS(DecompositionType,Rhs) \ 62 | typedef typename DecompositionType::MatrixType MatrixType; \ 63 | typedef typename MatrixType::Scalar Scalar; \ 64 | typedef typename MatrixType::RealScalar RealScalar; \ 65 | typedef typename MatrixType::Index Index; \ 66 | typedef Eigen::internal::solve_retval_base Base; \ 67 | using Base::dec; \ 68 | using Base::rhs; \ 69 | using Base::rows; \ 70 | using Base::cols; \ 71 | solve_retval(const DecompositionType& dec, const Rhs& rhs) \ 72 | : Base(dec, rhs) {} 73 | 74 | } // end namespace Eigen 75 | 76 | #endif // EIGEN_MISC_SOLVE_H 77 | -------------------------------------------------------------------------------- /bakeryoptix/utils/filesystem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Patrick Mours. All rights reserved. 3 | * License: https://github.com/crosire/reshade#license 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "string_codecvt.h" 13 | 14 | typedef unsigned char byte; 15 | 16 | namespace utils 17 | { 18 | class path 19 | { 20 | public: 21 | path() {} 22 | 23 | path(const char* data) : data_(data) {} 24 | 25 | path(const wchar_t* data) : data_(utf16_to_utf8(data)) {} 26 | 27 | path(std::string data) : data_(std::move(data)) {} 28 | 29 | path(const std::wstring& data) : data_(utf16_to_utf8(data)) {} 30 | 31 | bool operator==(const path& other) const; 32 | bool operator!=(const path& other) const; 33 | 34 | std::string& string() 35 | { 36 | return data_; 37 | } 38 | 39 | const std::string& string() const 40 | { 41 | return data_; 42 | } 43 | 44 | std::wstring wstring() const; 45 | 46 | friend std::ostream& operator<<(std::ostream& stream, const path& path); 47 | 48 | bool empty() const 49 | { 50 | return data_.empty(); 51 | } 52 | 53 | size_t length() const 54 | { 55 | return data_.length(); 56 | } 57 | 58 | bool is_absolute() const; 59 | 60 | path parent_path() const; 61 | std::string relative_ac() const; 62 | path filename() const; 63 | path filename_without_extension() const; 64 | std::string extension() const; 65 | 66 | path& remove_filename() 67 | { 68 | return operator=(parent_path()); 69 | } 70 | 71 | path operator/(const path& more) const; 72 | 73 | path operator+(char c) const 74 | { 75 | return data_ + c; 76 | } 77 | 78 | path operator+(const path& more) const 79 | { 80 | return data_ + more.data_; 81 | } 82 | 83 | private: 84 | std::string data_; 85 | }; 86 | 87 | bool exists(const path& path); 88 | bool create_dir(const path& path); 89 | long long get_file_size(const path& path); 90 | path resolve(const path& filename, const std::vector& paths); 91 | path absolute(const path& filename, const path& parent_path); 92 | 93 | path get_module_path(void* handle); 94 | 95 | std::vector list_files(const path& path_val, const std::string& mask = "*", bool recursive = false); 96 | bool try_find_file(const path& path_val, const std::string& file_name, path& result); 97 | 98 | struct data_chunk 99 | { 100 | size_t size; 101 | 102 | union 103 | { 104 | const byte* data; 105 | const char* c_str; 106 | }; 107 | 108 | data_chunk(const byte* data, size_t size); 109 | ~data_chunk(); 110 | 111 | static std::shared_ptr read_file(const path& filename); 112 | }; 113 | 114 | std::vector read_file(const path& filename); 115 | } 116 | -------------------------------------------------------------------------------- /bakeryoptix/rayanyhit_tree.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-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 | #include "ray.h" 30 | 31 | #include 32 | #include 33 | 34 | // Attributes. 35 | rtDeclareVariable(optix::float3, varGeoNormal, attribute GEO_NORMAL, ); 36 | //rtDeclareVariable(optix::float3, varTangent, attribute TANGENT, ); 37 | rtDeclareVariable(optix::float3, varNormal, attribute NORMAL, ); 38 | rtDeclareVariable(optix::float3, varTexCoord, attribute TEXCOORD, ); 39 | 40 | // Material parameter definition. 41 | rtDeclareVariable(float, parMaterialAlphaRef, , ); // Per Material index into the sysMaterialParameters array. 42 | rtDeclareVariable(float, parMaterialPassChange, , ); // Per Material index into the sysMaterialParameters array. 43 | // rtDeclareVariable(int, parMaterialTexture, , ); // Per Material index into the sysMaterialParameters array. 44 | rtTextureSampler parMaterialTexture; 45 | 46 | RT_FUNCTION float frac(float v) 47 | { 48 | return v - floorf(v); 49 | } 50 | 51 | RT_PROGRAM void rayanyhit_tree() 52 | { 53 | if (tex2D(parMaterialTexture, varTexCoord.x, varTexCoord.y).w <= parMaterialAlphaRef 54 | && frac(varTexCoord.x * 697.4581 + varTexCoord.y * 246.5266) < parMaterialPassChange) 55 | { 56 | rtIgnoreIntersection(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/MathFunctions.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Gael Guennebaud 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_MATH_FUNCTIONS_H 11 | #define EIGEN2_MATH_FUNCTIONS_H 12 | 13 | namespace Eigen { 14 | 15 | template inline typename NumTraits::Real ei_real(const T& x) { return numext::real(x); } 16 | template inline typename NumTraits::Real ei_imag(const T& x) { return numext::imag(x); } 17 | template inline T ei_conj(const T& x) { return numext::conj(x); } 18 | template inline typename NumTraits::Real ei_abs (const T& x) { using std::abs; return abs(x); } 19 | template inline typename NumTraits::Real ei_abs2(const T& x) { return numext::abs2(x); } 20 | template inline T ei_sqrt(const T& x) { using std::sqrt; return sqrt(x); } 21 | template inline T ei_exp (const T& x) { using std::exp; return exp(x); } 22 | template inline T ei_log (const T& x) { using std::log; return log(x); } 23 | template inline T ei_sin (const T& x) { using std::sin; return sin(x); } 24 | template inline T ei_cos (const T& x) { using std::cos; return cos(x); } 25 | template inline T ei_atan2(const T& x,const T& y) { using std::atan2; return atan2(x,y); } 26 | template inline T ei_pow (const T& x,const T& y) { return numext::pow(x,y); } 27 | template inline T ei_random () { return internal::random(); } 28 | template inline T ei_random (const T& x, const T& y) { return internal::random(x, y); } 29 | 30 | template inline T precision () { return NumTraits::dummy_precision(); } 31 | template inline T machine_epsilon () { return NumTraits::epsilon(); } 32 | 33 | 34 | template 35 | inline bool ei_isMuchSmallerThan(const Scalar& x, const OtherScalar& y, 36 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 37 | { 38 | return internal::isMuchSmallerThan(x, y, precision); 39 | } 40 | 41 | template 42 | inline bool ei_isApprox(const Scalar& x, const Scalar& y, 43 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 44 | { 45 | return internal::isApprox(x, y, precision); 46 | } 47 | 48 | template 49 | inline bool ei_isApproxOrLessThan(const Scalar& x, const Scalar& y, 50 | typename NumTraits::Real precision = NumTraits::dummy_precision()) 51 | { 52 | return internal::isApproxOrLessThan(x, y, precision); 53 | } 54 | 55 | } // end namespace Eigen 56 | 57 | #endif // EIGEN2_MATH_FUNCTIONS_H 58 | -------------------------------------------------------------------------------- /bakeryoptix/utils/blob.cpp: -------------------------------------------------------------------------------- 1 | #include "blob.h" 2 | 3 | #include "string_operations.h" 4 | 5 | namespace utils 6 | { 7 | utils_inner::blob_cursor utils_inner::blob_read_trait::cursor(size_t offset) const 8 | { 9 | return blob_cursor{data_(), size_(), offset}; 10 | } 11 | 12 | blob_view utils_inner::blob_read_trait::slice(size_t start, size_t length) const 13 | { 14 | if (start + length > size_()) 15 | { 16 | throw std::runtime_error(format("Invalid length: start=%zu, length=%zu, size=%zu", start, length, size_())); 17 | } 18 | return blob_view{data_() + start, length}; 19 | } 20 | 21 | uint64_t utils_inner::blob_read_trait::hash_code() const { return utils::hash_code(data_(), size_()); } 22 | blob utils_inner::blob_cursor::at_impl::get() const { return blob(&b[o + sizeof(uint32_t)], *(uint32_t*)&b[o]); } 23 | blob_view utils_inner::blob_cursor::at_impl::get() const { return blob_view{&b[o + sizeof(uint32_t)], *(uint32_t*)&b[o]}; } 24 | std::string utils_inner::blob_read_trait::string() const { return std::string(data_(), size_()); } 25 | 26 | blob_view::blob_view(const std::string& str) noexcept : begin_(&*str.begin()), end_(&*str.end()) {} 27 | blob::blob() noexcept : vector() {} 28 | blob::blob(const blob_view& view) noexcept : vector(view.data(), view.data() + view.size()) {} 29 | blob::blob(size_type count) noexcept : vector(count) {} 30 | blob::blob(const char* data, size_t size) noexcept : vector(data, data + size) {} 31 | blob::blob(const char* begin, const char* end) noexcept : vector(begin, end) {} 32 | blob::blob(const iterator& begin, const iterator& end) noexcept : vector(begin, end) {} 33 | blob::blob(iterator&& begin, iterator&& end) noexcept : vector(begin, end) {} 34 | blob::blob(const std::string& s) noexcept : blob(s.data(), s.size()) {} 35 | 36 | blob& blob::append(const void* data, size_t size) 37 | { 38 | const auto s = std::vector::size(); 39 | resize(s + size); 40 | memcpy(std::vector::data() + s, data, size); 41 | return *this; 42 | } 43 | 44 | blob blob::operator+(const blob_view& b) const 45 | { 46 | blob ret(size() + b.size()); 47 | memcpy(ret.data(), data(), size()); 48 | memcpy(ret.data() + size(), b.data(), b.size()); 49 | return ret; 50 | } 51 | 52 | blob& blob::operator+=(const blob_view& b) 53 | { 54 | return append(b.data(), b.size()); 55 | } 56 | 57 | blob& blob::operator^=(const blob_view& key) 58 | { 59 | uint64_t i, k; 60 | const auto data = this->data(); 61 | const auto td = size() / 8; 62 | const auto tk = key.size() / 8; 63 | const auto ld = (uint64_t*)data, lk = (uint64_t*)key.data(); 64 | for (i = 0, k = 0; i < td; i++, k++) 65 | { 66 | ld[i] ^= lk[k == tk ? (k = 0) : k]; 67 | } 68 | for (i *= 8, k *= 8; i < size(); i++, k++) 69 | { 70 | if (k == key.size()) k = 0; 71 | data[i] ^= key[k]; 72 | } 73 | return *this; 74 | } 75 | 76 | blob blob::operator^(const blob_view& b) const 77 | { 78 | auto r = *this; 79 | r ^= b; 80 | return r; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Householder/BlockHouseholder.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Vincent Lejeune 5 | // Copyright (C) 2010 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_BLOCK_HOUSEHOLDER_H 12 | #define EIGEN_BLOCK_HOUSEHOLDER_H 13 | 14 | // This file contains some helper function to deal with block householder reflectors 15 | 16 | namespace Eigen { 17 | 18 | namespace internal { 19 | 20 | /** \internal */ 21 | template 22 | void make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs) 23 | { 24 | typedef typename TriangularFactorType::Index Index; 25 | typedef typename VectorsType::Scalar Scalar; 26 | const Index nbVecs = vectors.cols(); 27 | eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs); 28 | 29 | for(Index i = 0; i < nbVecs; i++) 30 | { 31 | Index rs = vectors.rows() - i; 32 | Scalar Vii = vectors(i,i); 33 | vectors.const_cast_derived().coeffRef(i,i) = Scalar(1); 34 | triFactor.col(i).head(i).noalias() = -hCoeffs(i) * vectors.block(i, 0, rs, i).adjoint() 35 | * vectors.col(i).tail(rs); 36 | vectors.const_cast_derived().coeffRef(i, i) = Vii; 37 | // FIXME add .noalias() once the triangular product can work inplace 38 | triFactor.col(i).head(i) = triFactor.block(0,0,i,i).template triangularView() 39 | * triFactor.col(i).head(i); 40 | triFactor(i,i) = hCoeffs(i); 41 | } 42 | } 43 | 44 | /** \internal */ 45 | template 46 | void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs) 47 | { 48 | typedef typename MatrixType::Index Index; 49 | enum { TFactorSize = MatrixType::ColsAtCompileTime }; 50 | Index nbVecs = vectors.cols(); 51 | Matrix T(nbVecs,nbVecs); 52 | make_block_householder_triangular_factor(T, vectors, hCoeffs); 53 | 54 | const TriangularView& V(vectors); 55 | 56 | // A -= V T V^* A 57 | Matrix tmp = V.adjoint() * mat; 59 | // FIXME add .noalias() once the triangular product can work inplace 60 | tmp = T.template triangularView().adjoint() * tmp; 61 | mat.noalias() -= V * tmp; 62 | } 63 | 64 | } // end namespace internal 65 | 66 | } // end namespace Eigen 67 | 68 | #endif // EIGEN_BLOCK_HOUSEHOLDER_H 69 | -------------------------------------------------------------------------------- /bakeryoptix/utils/miniz/minizpp.cpp: -------------------------------------------------------------------------------- 1 | #include "minizpp.h" 2 | 3 | #include 4 | #include 5 | 6 | namespace utils 7 | { 8 | std::ostream& operator<<(std::ostream& os, mz_result self) 9 | { 10 | switch (self) 11 | { 12 | case mz_result::ok: return os << "mz::OK"; 13 | case mz_result::stream_end: return os << "mz::stream_end"; 14 | case mz_result::need_dict: return os << "mz::need_dict"; 15 | case mz_result::err_no: return os << "mz::errno"; 16 | case mz_result::stream_error: return os << "mz::stream_error"; 17 | case mz_result::data_error: return os << "mz::data_error"; 18 | case mz_result::mem_error: return os << "mz::mem_error"; 19 | case mz_result::buf_error: return os << "mz::buf_error"; 20 | case mz_result::version_error: return os << "mz::version_error"; 21 | case mz_result::limit_exceed_1: return os << "mz::limit_exceed_1"; 22 | case mz_result::limit_exceed_2: return os << "mz::limit_exceed_2"; 23 | case mz_result::param_error: return os << "mz::param_error"; 24 | default: return os << "mz::?"; 25 | } 26 | } 27 | 28 | mz_result mz_compress_dynamic(std::string& output, const char* data, std::size_t size) 29 | { 30 | auto compressed_size = mz_compressBound(mz_ulong(size)); 31 | output.resize(compressed_size); 32 | const auto result = mz_compress((uint8_t*)&output[0], &compressed_size, reinterpret_cast(data), mz_ulong(size)); 33 | if (result != MZ_OK) 34 | { 35 | output.clear(); 36 | return mz_result(result); 37 | } 38 | output.resize(compressed_size); 39 | return mz_result::ok; 40 | } 41 | 42 | mz_result mz_uncompress_dynamic(std::string& output, const char* data, std::size_t size, std::size_t size_limit) 43 | { 44 | mz_stream stream{}; 45 | stream.next_in = reinterpret_cast(data); 46 | stream.avail_in = mz_uint32(size); 47 | 48 | const auto status = mz_inflateInit(&stream); 49 | if (status != MZ_OK) 50 | { 51 | return mz_result(status); 52 | } 53 | 54 | if (size > size_limit) 55 | { 56 | mz_inflateEnd(&stream); 57 | return mz_result::limit_exceed_1; 58 | } 59 | 60 | std::size_t size_uncompressed = 0; 61 | const auto chunk = uint32_t(2 * size); 62 | 63 | do 64 | { 65 | const auto resize_to = size_uncompressed + chunk; 66 | if (resize_to > size_limit) 67 | { 68 | mz_inflateEnd(&stream); 69 | return mz_result::limit_exceed_2; 70 | } 71 | 72 | output.resize(resize_to); 73 | stream.avail_out = chunk; 74 | stream.next_out = reinterpret_cast(&output[0] + size_uncompressed); 75 | 76 | const auto ret = mz_inflate(&stream, MZ_SYNC_FLUSH); 77 | if (ret != MZ_STREAM_END && ret != MZ_OK && ret != MZ_BUF_ERROR) 78 | { 79 | mz_inflateEnd(&stream); 80 | return mz_result(ret); 81 | } 82 | 83 | const auto got = chunk - stream.avail_out; 84 | size_uncompressed += got; 85 | } 86 | while (stream.avail_out == 0 || stream.avail_in > 0); 87 | 88 | mz_inflateEnd(&stream); 89 | output.resize(size_uncompressed); 90 | return mz_result::ok; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/VectorBlock.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2009 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN2_VECTORBLOCK_H 12 | #define EIGEN2_VECTORBLOCK_H 13 | 14 | namespace Eigen { 15 | 16 | /** \deprecated use DenseMase::head(Index) */ 17 | template 18 | inline VectorBlock 19 | MatrixBase::start(Index size) 20 | { 21 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 22 | return VectorBlock(derived(), 0, size); 23 | } 24 | 25 | /** \deprecated use DenseMase::head(Index) */ 26 | template 27 | inline const VectorBlock 28 | MatrixBase::start(Index size) const 29 | { 30 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 31 | return VectorBlock(derived(), 0, size); 32 | } 33 | 34 | /** \deprecated use DenseMase::tail(Index) */ 35 | template 36 | inline VectorBlock 37 | MatrixBase::end(Index size) 38 | { 39 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 40 | return VectorBlock(derived(), this->size() - size, size); 41 | } 42 | 43 | /** \deprecated use DenseMase::tail(Index) */ 44 | template 45 | inline const VectorBlock 46 | MatrixBase::end(Index size) const 47 | { 48 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 49 | return VectorBlock(derived(), this->size() - size, size); 50 | } 51 | 52 | /** \deprecated use DenseMase::head() */ 53 | template 54 | template 55 | inline VectorBlock 56 | MatrixBase::start() 57 | { 58 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 59 | return VectorBlock(derived(), 0); 60 | } 61 | 62 | /** \deprecated use DenseMase::head() */ 63 | template 64 | template 65 | inline const VectorBlock 66 | MatrixBase::start() const 67 | { 68 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 69 | return VectorBlock(derived(), 0); 70 | } 71 | 72 | /** \deprecated use DenseMase::tail() */ 73 | template 74 | template 75 | inline VectorBlock 76 | MatrixBase::end() 77 | { 78 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 79 | return VectorBlock(derived(), size() - Size); 80 | } 81 | 82 | /** \deprecated use DenseMase::tail() */ 83 | template 84 | template 85 | inline const VectorBlock 86 | MatrixBase::end() const 87 | { 88 | EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) 89 | return VectorBlock(derived(), size() - Size); 90 | } 91 | 92 | } // end namespace Eigen 93 | 94 | #endif // EIGEN2_VECTORBLOCK_H 95 | -------------------------------------------------------------------------------- /bake-cars.jsh: -------------------------------------------------------------------------------- 1 | const $zipMerger = $['C:/Apps/Utils/ZipMerger.exe']; 2 | // const $zipMerger = $['D:/Documents/Visual Studio 2015/Projects/Utils/ZipMerger/bin/Release/ZipMerger.exe']; 3 | const acRoot = `D:/Temporary/Games/AssettoCorsa`; 4 | const kunosCars = $.readText(`${acRoot}/content/sfx/GUIDs.txt`).split('\n') 5 | .map(x => /cars\/(\w+)/.test(x) ? RegExp.$1 : null).unique().filter(x => x); 6 | const carsDir = `${acRoot}/content/cars`; 7 | const extraCars = []; 8 | const destinationDir = `C:/Development/acc-extension-cars-vao`; 9 | const bakery = $[`${__dirname}/x64/Release/bakeryoptix.exe`]; 10 | 11 | async function findMainModelFilename(carID) { 12 | const dir = path.join(carsDir, carID); 13 | if (!fs.existsSync(dir)) { 14 | throw new Error('Car is missing: ' + dir); 15 | } 16 | 17 | const kn5s = fs.readdirSync(dir).filter(x => /\bkn5\b/i.test(x)).map(x => ({ 18 | name: x, 19 | size: fs.statSync(path.join(dir, x)).size 20 | })).filter(x => x.size > 0); 21 | 22 | if (kn5s.length === 0) { 23 | throw new Error('No models here'); 24 | } 25 | 26 | if (kn5s.length !== 5) { 27 | $.cd(dir); 28 | await $.explorer('.', { fail: false }); 29 | throw new Error('Unexpected amount of models: ' + kn5s.map(x => x.name).join(', ')); 30 | } 31 | 32 | const largest = kn5s.reduce((a, b) => a.size > b.size ? a : b, kn5s[0]); 33 | return path.join(dir, largest.name); 34 | } 35 | 36 | function applyVaoPatch(vaoPatch, destination){ 37 | if (fs.existsSync(destination)){ 38 | $zipMerger(destination, destination, vaoPatch); 39 | } else { 40 | fs.copyFileSync(vaoPatch, destination); 41 | } 42 | } 43 | 44 | async function bakeCar(carID, forceRebake) { 45 | console.log(β.yellow(`Baking 🚗 ${carID}…`)); 46 | 47 | const mainModel = await findMainModelFilename(carID); 48 | const vaoPatch = path.join(carsDir, carID, 'main_geometry.vao-patch'); 49 | const destination = path.join(destinationDir, `${carID}.vao-patch`); 50 | 51 | if (!forceRebake && fs.existsSync(vaoPatch) && fs.statSync(vaoPatch).mtime > 1628685545787) { 52 | console.log(β.grey(`💤 Existing VAO patch is new enough`)); 53 | applyVaoPatch(vaoPatch, destination); 54 | return; 55 | } else { 56 | await bakery(mainModel); 57 | } 58 | 59 | if (!fs.existsSync(vaoPatch)) { 60 | throw new Error('VAO patch is missing'); 61 | } 62 | 63 | applyVaoPatch(vaoPatch, destination); 64 | console.log(β.green(`✅ Done, VAO patch “${path.basename(destination)}” is ready`)); 65 | } 66 | 67 | async function bakeCars(...carIDs) { 68 | for (const carID of carIDs) { 69 | try { 70 | await bakeCar(carID, carIDs.length === 1); 71 | } catch (e) { 72 | $.echo(β.red(`❌ ${e}`)); 73 | } 74 | } 75 | } 76 | 77 | $.echo('Script mtime: ' + +fs.statSync(`${__dirname}/bake-cars.jsh`).mtime); 78 | 79 | await bakeCars(...kunosCars); 80 | // await bakeCars(...fs.readdirSync(carsDir).filter(x => /^ks_/.test(x))); 81 | // await bakeCars('ks_ferrari_488_gt3'); 82 | // await bakeCars('ks_porsche_962c_longtail', 'ks_porsche_962c_shorttail'); 83 | // await bakeCars('ks_porsche_962c_longtail'); 84 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/StlSupport/details.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STL_DETAILS_H 12 | #define EIGEN_STL_DETAILS_H 13 | 14 | #ifndef EIGEN_ALIGNED_ALLOCATOR 15 | #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator 16 | #endif 17 | 18 | namespace Eigen { 19 | 20 | // This one is needed to prevent reimplementing the whole std::vector. 21 | template 22 | class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR 23 | { 24 | public: 25 | typedef size_t size_type; 26 | typedef ptrdiff_t difference_type; 27 | typedef T* pointer; 28 | typedef const T* const_pointer; 29 | typedef T& reference; 30 | typedef const T& const_reference; 31 | typedef T value_type; 32 | 33 | template 34 | struct rebind 35 | { 36 | typedef aligned_allocator_indirection other; 37 | }; 38 | 39 | aligned_allocator_indirection() {} 40 | aligned_allocator_indirection(const aligned_allocator_indirection& ) : EIGEN_ALIGNED_ALLOCATOR() {} 41 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 42 | template 43 | aligned_allocator_indirection(const aligned_allocator_indirection& ) {} 44 | template 45 | aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR& ) {} 46 | ~aligned_allocator_indirection() {} 47 | }; 48 | 49 | #ifdef _MSC_VER 50 | 51 | // sometimes, MSVC detects, at compile time, that the argument x 52 | // in std::vector::resize(size_t s,T x) won't be aligned and generate an error 53 | // even if this function is never called. Whence this little wrapper. 54 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \ 55 | typename Eigen::internal::conditional< \ 56 | Eigen::internal::is_arithmetic::value, \ 57 | T, \ 58 | Eigen::internal::workaround_msvc_stl_support \ 59 | >::type 60 | 61 | namespace internal { 62 | template struct workaround_msvc_stl_support : public T 63 | { 64 | inline workaround_msvc_stl_support() : T() {} 65 | inline workaround_msvc_stl_support(const T& other) : T(other) {} 66 | inline operator T& () { return *static_cast(this); } 67 | inline operator const T& () const { return *static_cast(this); } 68 | template 69 | inline T& operator=(const OtherT& other) 70 | { T::operator=(other); return *this; } 71 | inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other) 72 | { T::operator=(other); return *this; } 73 | }; 74 | } 75 | 76 | #else 77 | 78 | #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T 79 | 80 | #endif 81 | 82 | } 83 | 84 | #endif // EIGEN_STL_DETAILS_H 85 | -------------------------------------------------------------------------------- /bakeryoptix/ray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define RT_USE_TEMPLATED_RTCALLABLEPROGRAM 1 4 | #define DENOMINATOR_EPSILON 1.0e-6f 5 | #define USE_DEBUG_EXCEPTIONS 0 6 | 7 | #ifndef RT_FUNCTION 8 | #define RT_FUNCTION __forceinline__ __device__ 9 | #endif 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #define FLAG_FRONTFACE 0x00000010 16 | #define FLAG_TERMINATE 0x80000000 17 | 18 | //using optix::int; 19 | using optix::int2; 20 | using optix::uint; 21 | using optix::uint2; 22 | //using optix::float; 23 | using optix::float3; 24 | using optix::float4; 25 | 26 | struct PerRayData 27 | { 28 | optix::float3 pos; // Current surface hit point, in world space 29 | optix::float3 wo; // Outgoing direction, to observer, in world space. 30 | optix::float3 wi; // Incoming direction, to light, in world space. 31 | 32 | optix::float3 radiance; // Radiance along the current path segment. 33 | int flags; // Bitfield with flags. See FLAG_* defines for its contents. 34 | 35 | optix::float3 f_over_pdf; // BSDF sample throughput, pre-multiplied f_over_pdf = bsdf.f * fabsf(dot(wi, ns) / bsdf.pdf; 36 | float pdf; // The last BSDF sample's pdf, tracked for multiple importance sampling. 37 | 38 | unsigned int seed; // Random number generator input. 39 | }; 40 | 41 | // Tiny Encryption Algorithm (TEA) to calculate a the seed per launch index and iteration. 42 | template 43 | RT_FUNCTION unsigned int tea_custom(const unsigned int val0, const unsigned int val1) 44 | { 45 | unsigned int v0 = val0; 46 | unsigned int v1 = val1; 47 | unsigned int s0 = 0; 48 | 49 | for (unsigned int n = 0; n < N; ++n) 50 | { 51 | s0 += 0x9e3779b9; 52 | v0 += ((v1 << 4) + 0xA341316C) ^ (v1 + s0) ^ ((v1 >> 5) + 0xC8013EA4); 53 | v1 += ((v0 << 4) + 0xAD90777D) ^ (v0 + s0) ^ ((v0 >> 5) + 0x7E95761E); 54 | } 55 | return v0; 56 | } 57 | 58 | // Return a random sample in the range [0, 1) with a simple Linear Congruential Generator. 59 | RT_FUNCTION float rng(unsigned int& previous) 60 | { 61 | previous = previous * 1664525u + 1013904223u; 62 | 63 | return float(previous & 0X00FFFFFF) / float(0x01000000u); // Use the lower 24 bits. 64 | // return float(previous >> 8) / float(0x01000000u); // Use the upper 24 bits 65 | } 66 | 67 | // Convenience function to generate a 2D unit square sample. 68 | RT_FUNCTION float2 rng2(unsigned int& previous) 69 | { 70 | float2 s; 71 | 72 | previous = previous * 1664525u + 1013904223u; 73 | s.x = float(previous & 0X00FFFFFF) / float(0x01000000u); // Use the lower 24 bits. 74 | //s.x = float(previous >> 8) / float(0x01000000u); // Use the upper 24 bits 75 | 76 | previous = previous * 1664525u + 1013904223u; 77 | s.y = float(previous & 0X00FFFFFF) / float(0x01000000u); // Use the lower 24 bits. 78 | //s.y = float(previous >> 8) / float(0x01000000u); // Use the upper 24 bits 79 | 80 | return s; 81 | } 82 | 83 | RT_FUNCTION bool isNull(const optix::float3& v) 84 | { 85 | return (v.x == 0.0f && v.y == 0.0f && v.z == 0.0f); 86 | } -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/misc/Kernel.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_KERNEL_H 11 | #define EIGEN_MISC_KERNEL_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class kernel_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix< 25 | typename MatrixType::Scalar, 26 | MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" 27 | // is the number of cols of the original matrix 28 | // so that the product "matrix * kernel = zero" makes sense 29 | Dynamic, // we don't know at compile-time the dimension of the kernel 30 | MatrixType::Options, 31 | MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter 32 | MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, 33 | // whose dimension is the number of columns of the original matrix 34 | > ReturnType; 35 | }; 36 | 37 | template struct kernel_retval_base 38 | : public ReturnByValue > 39 | { 40 | typedef _DecompositionType DecompositionType; 41 | typedef ReturnByValue Base; 42 | typedef typename Base::Index Index; 43 | 44 | kernel_retval_base(const DecompositionType& dec) 45 | : m_dec(dec), 46 | m_rank(dec.rank()), 47 | m_cols(m_rank==dec.cols() ? 1 : dec.cols() - m_rank) 48 | {} 49 | 50 | inline Index rows() const { return m_dec.cols(); } 51 | inline Index cols() const { return m_cols; } 52 | inline Index rank() const { return m_rank; } 53 | inline const DecompositionType& dec() const { return m_dec; } 54 | 55 | template inline void evalTo(Dest& dst) const 56 | { 57 | static_cast*>(this)->evalTo(dst); 58 | } 59 | 60 | protected: 61 | const DecompositionType& m_dec; 62 | Index m_rank, m_cols; 63 | }; 64 | 65 | } // end namespace internal 66 | 67 | #define EIGEN_MAKE_KERNEL_HELPERS(DecompositionType) \ 68 | typedef typename DecompositionType::MatrixType MatrixType; \ 69 | typedef typename MatrixType::Scalar Scalar; \ 70 | typedef typename MatrixType::RealScalar RealScalar; \ 71 | typedef typename MatrixType::Index Index; \ 72 | typedef Eigen::internal::kernel_retval_base Base; \ 73 | using Base::dec; \ 74 | using Base::rank; \ 75 | using Base::rows; \ 76 | using Base::cols; \ 77 | kernel_retval(const DecompositionType& dec) : Base(dec) {} 78 | 79 | } // end namespace Eigen 80 | 81 | #endif // EIGEN_MISC_KERNEL_H 82 | -------------------------------------------------------------------------------- /bakeryoptix/utils/cout_progress.cpp: -------------------------------------------------------------------------------- 1 | #include "cout_progress.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | cout_progress::cout_progress(const size_t total_steps, bool show_steps, bool use_moment_speed) 8 | : start(std::chrono::high_resolution_clock::now()), total_steps(total_steps), show_steps(show_steps), use_moment_speed(use_moment_speed) { } 9 | 10 | cout_progress::~cout_progress() 11 | { 12 | erase(); 13 | } 14 | 15 | void out_time(std::stringstream& s, double seconds) 16 | { 17 | const auto minutes = floor(seconds / 60.); 18 | seconds = round(seconds - minutes * 60.); 19 | 20 | if (minutes > 0) 21 | { 22 | s << " " << minutes << " min"; 23 | } 24 | 25 | if (seconds > 0 || minutes == 0) 26 | { 27 | s << " " << seconds << " s"; 28 | } 29 | } 30 | 31 | std::string cout_progress::get_msg(const std::string& comment, const std::chrono::steady_clock::time_point& now) 32 | { 33 | #define BRACKET if (!bracket_opened) { s << " ("; bracket_opened = true; } else { s << ", "; } 34 | 35 | const auto progress = float(current_step) / float(total_steps); 36 | 37 | std::stringstream s; 38 | s << std_ext::format(" %.1f%%", 100.f * progress); 39 | 40 | auto bracket_opened = false; 41 | 42 | if (show_steps) 43 | { 44 | BRACKET 45 | s << current_step << "/" << total_steps; 46 | } 47 | 48 | const auto time_passed = double(std::chrono::duration_cast(now - start).count()) / 1000.0; 49 | if (shown_eta || time_passed > 1. + progress && progress > 0.005f) 50 | { 51 | BRACKET 52 | s << "time rem.:"; 53 | if (!use_moment_speed) 54 | { 55 | avg_speed = avg_speed + (double(current_step) / time_passed - avg_speed) / (avg_speed == 0. ? 1. : 2.4); 56 | } 57 | out_time(s, double(total_steps - current_step) / avg_speed); 58 | shown_eta = true; 59 | } 60 | 61 | if (!comment.empty()) 62 | { 63 | BRACKET 64 | s << comment; 65 | } 66 | 67 | if (bracket_opened) 68 | { 69 | s << ")"; 70 | } 71 | 72 | return s.str(); 73 | } 74 | 75 | void cout_progress::erase() 76 | { 77 | if (!last_length) return; 78 | std::cout << std::string(last_length, '\b') << std::string(last_length, ' ') << std::string(last_length, '\b'); 79 | last_length = 0; 80 | } 81 | 82 | void cout_progress::report(const std::string& comment) 83 | { 84 | if (total_steps < 2) return; 85 | 86 | const auto now = std::chrono::high_resolution_clock::now(); 87 | const auto time_passed = double(std::chrono::duration_cast(now - last_report).count()) / 1000.0; 88 | 89 | if (use_moment_speed) 90 | { 91 | const auto moment_speed = double(current_step - last_report_step) / std::max(time_passed, 0.0001); 92 | avg_speed = avg_speed + (moment_speed - avg_speed) / (avg_speed == 0. ? 1. : moment_speed < avg_speed ? 12. : 40.); 93 | } 94 | 95 | if (time_passed > 0.1) 96 | { 97 | erase(); 98 | const auto msg = get_msg(comment, now); 99 | std::cout << msg; 100 | last_length = msg.size(); 101 | last_report = now; 102 | last_report_step = current_step; 103 | } 104 | 105 | current_step++; 106 | } 107 | -------------------------------------------------------------------------------- /bakeryoptix/utils/alphanum.cpp: -------------------------------------------------------------------------------- 1 | #include "alphanum.h" 2 | 3 | namespace doj 4 | { 5 | bool alphanum_isdigit(const char c) 6 | { 7 | return c >= '0' && c <= '9'; 8 | } 9 | 10 | int alphanum_impl(const char* l, const char* r) 11 | { 12 | enum mode_t { STRING, NUMBER } mode = STRING; 13 | 14 | while (*l && *r) 15 | { 16 | if (mode == STRING) 17 | { 18 | char l_char, r_char; 19 | while ((l_char = *l) && (r_char = *r)) 20 | { 21 | // check if this are digit characters 22 | const bool l_digit = alphanum_isdigit(l_char), r_digit = alphanum_isdigit(r_char); 23 | // if both characters are digits, we continue in NUMBER mode 24 | if (l_digit && r_digit) 25 | { 26 | mode = NUMBER; 27 | break; 28 | } 29 | // if only the left character is a digit, we have a result 30 | if (l_digit) return -1; 31 | // if only the right character is a digit, we have a result 32 | if (r_digit) return +1; 33 | // compute the difference of both characters 34 | const int diff = l_char - r_char; 35 | // if they differ we have a result 36 | if (diff != 0) return diff; 37 | // otherwise process the next characters 38 | ++l; 39 | ++r; 40 | } 41 | } 42 | else // mode==NUMBER 43 | { 44 | // get the left number 45 | unsigned long l_int = 0; 46 | while (*l && alphanum_isdigit(*l)) 47 | { 48 | // TODO: this can overflow 49 | l_int = l_int * 10 + *l - '0'; 50 | ++l; 51 | } 52 | 53 | // get the right number 54 | unsigned long r_int = 0; 55 | while (*r && alphanum_isdigit(*r)) 56 | { 57 | // TODO: this can overflow 58 | r_int = r_int * 10 + *r - '0'; 59 | ++r; 60 | } 61 | 62 | // if the difference is not equal to zero, we have a comparison result 63 | const long diff = l_int - r_int; 64 | if (diff != 0) return diff; 65 | 66 | // otherwise we process the next substring in STRING mode 67 | mode = STRING; 68 | } 69 | } 70 | 71 | if (*r) return -1; 72 | if (*l) return +1; 73 | return 0; 74 | } 75 | 76 | int alphanum_comp(char* l, char* r) 77 | { 78 | return alphanum_impl(l, r); 79 | } 80 | 81 | int alphanum_comp(const char* l, const char* r) 82 | { 83 | return alphanum_impl(l, r); 84 | } 85 | 86 | int alphanum_comp(char* l, const char* r) 87 | { 88 | return alphanum_impl(l, r); 89 | } 90 | 91 | int alphanum_comp(const char* l, char* r) 92 | { 93 | return alphanum_impl(l, r); 94 | } 95 | 96 | int alphanum_comp(const std::string& l, char* r) 97 | { 98 | return alphanum_impl(l.c_str(), r); 99 | } 100 | 101 | int alphanum_comp(char* l, const std::string& r) 102 | { 103 | return alphanum_impl(l, r.c_str()); 104 | } 105 | 106 | int alphanum_comp(const std::string& l, const char* r) 107 | { 108 | return alphanum_impl(l.c_str(), r); 109 | } 110 | 111 | int alphanum_comp(const char* l, const std::string& r) 112 | { 113 | return alphanum_impl(l, r.c_str()); 114 | } 115 | 116 | int alphanum_comp(const std::string& l, const std::string& r) 117 | { 118 | return alphanum_impl(l.c_str(), r.c_str()); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/Geometry/All.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN2_GEOMETRY_MODULE_H 2 | #define EIGEN2_GEOMETRY_MODULE_H 3 | 4 | #include 5 | 6 | #ifndef M_PI 7 | #define M_PI 3.14159265358979323846 8 | #endif 9 | 10 | #if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS 11 | #include "RotationBase.h" 12 | #include "Rotation2D.h" 13 | #include "Quaternion.h" 14 | #include "AngleAxis.h" 15 | #include "Transform.h" 16 | #include "Translation.h" 17 | #include "Scaling.h" 18 | #include "AlignedBox.h" 19 | #include "Hyperplane.h" 20 | #include "ParametrizedLine.h" 21 | #endif 22 | 23 | 24 | #define RotationBase eigen2_RotationBase 25 | #define Rotation2D eigen2_Rotation2D 26 | #define Rotation2Df eigen2_Rotation2Df 27 | #define Rotation2Dd eigen2_Rotation2Dd 28 | 29 | #define Quaternion eigen2_Quaternion 30 | #define Quaternionf eigen2_Quaternionf 31 | #define Quaterniond eigen2_Quaterniond 32 | 33 | #define AngleAxis eigen2_AngleAxis 34 | #define AngleAxisf eigen2_AngleAxisf 35 | #define AngleAxisd eigen2_AngleAxisd 36 | 37 | #define Transform eigen2_Transform 38 | #define Transform2f eigen2_Transform2f 39 | #define Transform2d eigen2_Transform2d 40 | #define Transform3f eigen2_Transform3f 41 | #define Transform3d eigen2_Transform3d 42 | 43 | #define Translation eigen2_Translation 44 | #define Translation2f eigen2_Translation2f 45 | #define Translation2d eigen2_Translation2d 46 | #define Translation3f eigen2_Translation3f 47 | #define Translation3d eigen2_Translation3d 48 | 49 | #define Scaling eigen2_Scaling 50 | #define Scaling2f eigen2_Scaling2f 51 | #define Scaling2d eigen2_Scaling2d 52 | #define Scaling3f eigen2_Scaling3f 53 | #define Scaling3d eigen2_Scaling3d 54 | 55 | #define AlignedBox eigen2_AlignedBox 56 | 57 | #define Hyperplane eigen2_Hyperplane 58 | #define ParametrizedLine eigen2_ParametrizedLine 59 | 60 | #define ei_toRotationMatrix eigen2_ei_toRotationMatrix 61 | #define ei_quaternion_assign_impl eigen2_ei_quaternion_assign_impl 62 | #define ei_transform_product_impl eigen2_ei_transform_product_impl 63 | 64 | #include "RotationBase.h" 65 | #include "Rotation2D.h" 66 | #include "Quaternion.h" 67 | #include "AngleAxis.h" 68 | #include "Transform.h" 69 | #include "Translation.h" 70 | #include "Scaling.h" 71 | #include "AlignedBox.h" 72 | #include "Hyperplane.h" 73 | #include "ParametrizedLine.h" 74 | 75 | #undef ei_toRotationMatrix 76 | #undef ei_quaternion_assign_impl 77 | #undef ei_transform_product_impl 78 | 79 | #undef RotationBase 80 | #undef Rotation2D 81 | #undef Rotation2Df 82 | #undef Rotation2Dd 83 | 84 | #undef Quaternion 85 | #undef Quaternionf 86 | #undef Quaterniond 87 | 88 | #undef AngleAxis 89 | #undef AngleAxisf 90 | #undef AngleAxisd 91 | 92 | #undef Transform 93 | #undef Transform2f 94 | #undef Transform2d 95 | #undef Transform3f 96 | #undef Transform3d 97 | 98 | #undef Translation 99 | #undef Translation2f 100 | #undef Translation2d 101 | #undef Translation3f 102 | #undef Translation3d 103 | 104 | #undef Scaling 105 | #undef Scaling2f 106 | #undef Scaling2d 107 | #undef Scaling3f 108 | #undef Scaling3d 109 | 110 | #undef AlignedBox 111 | 112 | #undef Hyperplane 113 | #undef ParametrizedLine 114 | 115 | #endif // EIGEN2_GEOMETRY_MODULE_H 116 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/Eigen2Support/Meta.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN2_META_H 11 | #define EIGEN2_META_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | struct ei_traits : internal::traits 17 | {}; 18 | 19 | struct ei_meta_true { enum { ret = 1 }; }; 20 | struct ei_meta_false { enum { ret = 0 }; }; 21 | 22 | template 23 | struct ei_meta_if { typedef Then ret; }; 24 | 25 | template 26 | struct ei_meta_if { typedef Else ret; }; 27 | 28 | template struct ei_is_same_type { enum { ret = 0 }; }; 29 | template struct ei_is_same_type { enum { ret = 1 }; }; 30 | 31 | template struct ei_unref { typedef T type; }; 32 | template struct ei_unref { typedef T type; }; 33 | 34 | template struct ei_unpointer { typedef T type; }; 35 | template struct ei_unpointer { typedef T type; }; 36 | template struct ei_unpointer { typedef T type; }; 37 | 38 | template struct ei_unconst { typedef T type; }; 39 | template struct ei_unconst { typedef T type; }; 40 | template struct ei_unconst { typedef T & type; }; 41 | template struct ei_unconst { typedef T * type; }; 42 | 43 | template struct ei_cleantype { typedef T type; }; 44 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 45 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 46 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 47 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 48 | template struct ei_cleantype { typedef typename ei_cleantype::type type; }; 49 | 50 | /** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer. 51 | * Usage example: \code ei_meta_sqrt<1023>::ret \endcode 52 | */ 53 | template Y))) > 57 | // use ?: instead of || just to shut up a stupid gcc 4.3 warning 58 | class ei_meta_sqrt 59 | { 60 | enum { 61 | MidX = (InfX+SupX)/2, 62 | TakeInf = MidX*MidX > Y ? 1 : 0, 63 | NewInf = int(TakeInf) ? InfX : int(MidX), 64 | NewSup = int(TakeInf) ? int(MidX) : SupX 65 | }; 66 | public: 67 | enum { ret = ei_meta_sqrt::ret }; 68 | }; 69 | 70 | template 71 | class ei_meta_sqrt { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; }; 72 | 73 | } // end namespace Eigen 74 | 75 | #endif // EIGEN2_META_H 76 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/QR/HouseholderQR_MKL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Intel Corporation. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | * 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 | * Neither the name of Intel Corporation nor the names of its contributors may 13 | be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | ******************************************************************************** 28 | * Content : Eigen bindings to Intel(R) MKL 29 | * Householder QR decomposition of a matrix w/o pivoting based on 30 | * LAPACKE_?geqrf function. 31 | ******************************************************************************** 32 | */ 33 | 34 | #ifndef EIGEN_QR_MKL_H 35 | #define EIGEN_QR_MKL_H 36 | 37 | #include "../Core/util/MKL_support.h" 38 | 39 | namespace Eigen { 40 | 41 | namespace internal { 42 | 43 | /** \internal Specialization for the data types supported by MKL */ 44 | 45 | #define EIGEN_MKL_QR_NOPIV(EIGTYPE, MKLTYPE, MKLPREFIX) \ 46 | template \ 47 | struct householder_qr_inplace_blocked \ 48 | { \ 49 | static void run(MatrixQR& mat, HCoeffs& hCoeffs, \ 50 | typename MatrixQR::Index = 32, \ 51 | typename MatrixQR::Scalar* = 0) \ 52 | { \ 53 | lapack_int m = (lapack_int) mat.rows(); \ 54 | lapack_int n = (lapack_int) mat.cols(); \ 55 | lapack_int lda = (lapack_int) mat.outerStride(); \ 56 | lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ 57 | LAPACKE_##MKLPREFIX##geqrf( matrix_order, m, n, (MKLTYPE*)mat.data(), lda, (MKLTYPE*)hCoeffs.data()); \ 58 | hCoeffs.adjointInPlace(); \ 59 | } \ 60 | }; 61 | 62 | EIGEN_MKL_QR_NOPIV(double, double, d) 63 | EIGEN_MKL_QR_NOPIV(float, float, s) 64 | EIGEN_MKL_QR_NOPIV(dcomplex, MKL_Complex16, z) 65 | EIGEN_MKL_QR_NOPIV(scomplex, MKL_Complex8, c) 66 | 67 | } // end namespace internal 68 | 69 | } // end namespace Eigen 70 | 71 | #endif // EIGEN_QR_MKL_H 72 | -------------------------------------------------------------------------------- /bakeryoptix/utils/binary_reader.cpp: -------------------------------------------------------------------------------- 1 | #include "binary_reader.h" 2 | #include 3 | #include 4 | #include 5 | 6 | namespace utils 7 | { 8 | binary_reader::binary_reader(std::basic_istream& stream, const uint32_t buffer_size) 9 | : stream_(&stream), buffer_(new char[buffer_size]), own_(false), 10 | buffer_size_(buffer_size) { } 11 | 12 | binary_reader::binary_reader(const path& path, const uint32_t buffer_size) 13 | : stream_(new std::ifstream(path.wstring(), std::ios::binary)), buffer_(new char[buffer_size]), own_(true), 14 | buffer_size_(buffer_size) { } 15 | 16 | binary_reader::~binary_reader() 17 | { 18 | if (own_) delete stream_; 19 | delete[] buffer_; 20 | } 21 | 22 | void binary_reader::skip(const uint32_t count) 23 | { 24 | if (left_ >= count) 25 | { 26 | get_pos_and_move(count); 27 | } 28 | else 29 | { 30 | stream_->seekg(size_t(long(stream_->tellg()) - long(left_) + count), SEEK_SET); 31 | left_ = 0; 32 | } 33 | } 34 | 35 | void binary_reader::skip_string() 36 | { 37 | skip(read_uint()); 38 | } 39 | 40 | std::string binary_reader::read_string() 41 | { 42 | const auto length = read_uint(); 43 | return std::string(&buffer_[get_pos_and_move(length)], length); 44 | } 45 | 46 | std::string binary_reader::read_rest() 47 | { 48 | const auto p = size_t(long(stream_->tellg()) - long(left_)); 49 | stream_->seekg(0, std::ios::end); 50 | const auto total = size_t(stream_->tellg()); 51 | std::string ret; 52 | ret.resize(total - size_t(p)); 53 | 54 | stream_->seekg(p, std::ios::beg); 55 | stream_->read(&ret[0], ret.size()); 56 | left_ = 0; 57 | return ret; 58 | } 59 | 60 | std::string binary_reader::read_data(uint size) 61 | { 62 | if (left_ >= size) 63 | { 64 | return std::string(&buffer_[get_pos_and_move(size)], size); 65 | } 66 | 67 | auto r = std::string(); 68 | r.resize(size); 69 | memcpy(&r[0], &buffer_[total_ - left_], left_); 70 | stream_->read(&r[left_], size - left_); 71 | left_ = 0; 72 | return r; 73 | } 74 | 75 | bool binary_reader::match(const char* str) 76 | { 77 | while (*str) 78 | { 79 | if (read_char() != *str) return false; 80 | str++; 81 | } 82 | return true; 83 | } 84 | 85 | char binary_reader::read_char() 86 | { 87 | return buffer_[get_pos_and_move(1)]; 88 | } 89 | 90 | bool binary_reader::read_bool() 91 | { 92 | return read_char() != 0; 93 | } 94 | 95 | char binary_reader::next_char() 96 | { 97 | return buffer_[total_ - left_--]; 98 | } 99 | 100 | void binary_reader::require(const uint32_t count) 101 | { 102 | if (left_ < count) 103 | { 104 | if (left_ > 0) 105 | { 106 | memcpy(buffer_, &buffer_[total_ - left_], left_); 107 | } 108 | 109 | const auto left_to_fill = buffer_size_ - left_; 110 | stream_->read(&buffer_[left_], left_to_fill); 111 | left_ += uint32_t(stream_->gcount()); 112 | total_ = left_; 113 | 114 | if (left_ < count) throw std::runtime_error("Unexpected end"); 115 | } 116 | } 117 | 118 | int binary_reader::get_pos_and_move(const uint32_t count) 119 | { 120 | require(count); 121 | const auto p = total_ - left_; 122 | left_ -= count; 123 | return p; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/SparseCore/SparseView.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Gael Guennebaud 5 | // Copyright (C) 2010 Daniel Lowengrub 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSEVIEW_H 12 | #define EIGEN_SPARSEVIEW_H 13 | 14 | namespace Eigen { 15 | 16 | namespace internal { 17 | 18 | template 19 | struct traits > : traits 20 | { 21 | typedef typename MatrixType::Index Index; 22 | typedef Sparse StorageKind; 23 | enum { 24 | Flags = int(traits::Flags) & (RowMajorBit) 25 | }; 26 | }; 27 | 28 | } // end namespace internal 29 | 30 | template 31 | class SparseView : public SparseMatrixBase > 32 | { 33 | typedef typename MatrixType::Nested MatrixTypeNested; 34 | typedef typename internal::remove_all::type _MatrixTypeNested; 35 | public: 36 | EIGEN_SPARSE_PUBLIC_INTERFACE(SparseView) 37 | 38 | SparseView(const MatrixType& mat, const Scalar& m_reference = Scalar(0), 39 | typename NumTraits::Real m_epsilon = NumTraits::dummy_precision()) : 40 | m_matrix(mat), m_reference(m_reference), m_epsilon(m_epsilon) {} 41 | 42 | class InnerIterator; 43 | 44 | inline Index rows() const { return m_matrix.rows(); } 45 | inline Index cols() const { return m_matrix.cols(); } 46 | 47 | inline Index innerSize() const { return m_matrix.innerSize(); } 48 | inline Index outerSize() const { return m_matrix.outerSize(); } 49 | 50 | protected: 51 | MatrixTypeNested m_matrix; 52 | Scalar m_reference; 53 | typename NumTraits::Real m_epsilon; 54 | }; 55 | 56 | template 57 | class SparseView::InnerIterator : public _MatrixTypeNested::InnerIterator 58 | { 59 | typedef typename SparseView::Index Index; 60 | public: 61 | typedef typename _MatrixTypeNested::InnerIterator IterBase; 62 | InnerIterator(const SparseView& view, Index outer) : 63 | IterBase(view.m_matrix, outer), m_view(view) 64 | { 65 | incrementToNonZero(); 66 | } 67 | 68 | EIGEN_STRONG_INLINE InnerIterator& operator++() 69 | { 70 | IterBase::operator++(); 71 | incrementToNonZero(); 72 | return *this; 73 | } 74 | 75 | using IterBase::value; 76 | 77 | protected: 78 | const SparseView& m_view; 79 | 80 | private: 81 | void incrementToNonZero() 82 | { 83 | while((bool(*this)) && internal::isMuchSmallerThan(value(), m_view.m_reference, m_view.m_epsilon)) 84 | { 85 | IterBase::operator++(); 86 | } 87 | } 88 | }; 89 | 90 | template 91 | const SparseView MatrixBase::sparseView(const Scalar& m_reference, 92 | const typename NumTraits::Real& m_epsilon) const 93 | { 94 | return SparseView(derived(), m_reference, m_epsilon); 95 | } 96 | 97 | } // end namespace Eigen 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/misc/Image.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_MISC_IMAGE_H 11 | #define EIGEN_MISC_IMAGE_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | /** \class image_retval_base 18 | * 19 | */ 20 | template 21 | struct traits > 22 | { 23 | typedef typename DecompositionType::MatrixType MatrixType; 24 | typedef Matrix< 25 | typename MatrixType::Scalar, 26 | MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose 27 | // dimension is the number of rows of the original matrix 28 | Dynamic, // we don't know at compile time the dimension of the image (the rank) 29 | MatrixType::Options, 30 | MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix, 31 | MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns. 32 | > ReturnType; 33 | }; 34 | 35 | template struct image_retval_base 36 | : public ReturnByValue > 37 | { 38 | typedef _DecompositionType DecompositionType; 39 | typedef typename DecompositionType::MatrixType MatrixType; 40 | typedef ReturnByValue Base; 41 | typedef typename Base::Index Index; 42 | 43 | image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix) 44 | : m_dec(dec), m_rank(dec.rank()), 45 | m_cols(m_rank == 0 ? 1 : m_rank), 46 | m_originalMatrix(originalMatrix) 47 | {} 48 | 49 | inline Index rows() const { return m_dec.rows(); } 50 | inline Index cols() const { return m_cols; } 51 | inline Index rank() const { return m_rank; } 52 | inline const DecompositionType& dec() const { return m_dec; } 53 | inline const MatrixType& originalMatrix() const { return m_originalMatrix; } 54 | 55 | template inline void evalTo(Dest& dst) const 56 | { 57 | static_cast*>(this)->evalTo(dst); 58 | } 59 | 60 | protected: 61 | const DecompositionType& m_dec; 62 | Index m_rank, m_cols; 63 | const MatrixType& m_originalMatrix; 64 | }; 65 | 66 | } // end namespace internal 67 | 68 | #define EIGEN_MAKE_IMAGE_HELPERS(DecompositionType) \ 69 | typedef typename DecompositionType::MatrixType MatrixType; \ 70 | typedef typename MatrixType::Scalar Scalar; \ 71 | typedef typename MatrixType::RealScalar RealScalar; \ 72 | typedef typename MatrixType::Index Index; \ 73 | typedef Eigen::internal::image_retval_base Base; \ 74 | using Base::dec; \ 75 | using Base::originalMatrix; \ 76 | using Base::rank; \ 77 | using Base::rows; \ 78 | using Base::cols; \ 79 | image_retval(const DecompositionType& dec, const MatrixType& originalMatrix) \ 80 | : Base(dec, originalMatrix) {} 81 | 82 | } // end namespace Eigen 83 | 84 | #endif // EIGEN_MISC_IMAGE_H 85 | -------------------------------------------------------------------------------- /bakeryoptix/eigen/src/LU/Determinant.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Benoit Jacob 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_DETERMINANT_H 11 | #define EIGEN_DETERMINANT_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | template 18 | inline const typename Derived::Scalar bruteforce_det3_helper 19 | (const MatrixBase& matrix, int a, int b, int c) 20 | { 21 | return matrix.coeff(0,a) 22 | * (matrix.coeff(1,b) * matrix.coeff(2,c) - matrix.coeff(1,c) * matrix.coeff(2,b)); 23 | } 24 | 25 | template 26 | const typename Derived::Scalar bruteforce_det4_helper 27 | (const MatrixBase& matrix, int j, int k, int m, int n) 28 | { 29 | return (matrix.coeff(j,0) * matrix.coeff(k,1) - matrix.coeff(k,0) * matrix.coeff(j,1)) 30 | * (matrix.coeff(m,2) * matrix.coeff(n,3) - matrix.coeff(n,2) * matrix.coeff(m,3)); 31 | } 32 | 33 | template struct determinant_impl 36 | { 37 | static inline typename traits::Scalar run(const Derived& m) 38 | { 39 | if(Derived::ColsAtCompileTime==Dynamic && m.rows()==0) 40 | return typename traits::Scalar(1); 41 | return m.partialPivLu().determinant(); 42 | } 43 | }; 44 | 45 | template struct determinant_impl 46 | { 47 | static inline typename traits::Scalar run(const Derived& m) 48 | { 49 | return m.coeff(0,0); 50 | } 51 | }; 52 | 53 | template struct determinant_impl 54 | { 55 | static inline typename traits::Scalar run(const Derived& m) 56 | { 57 | return m.coeff(0,0) * m.coeff(1,1) - m.coeff(1,0) * m.coeff(0,1); 58 | } 59 | }; 60 | 61 | template struct determinant_impl 62 | { 63 | static inline typename traits::Scalar run(const Derived& m) 64 | { 65 | return bruteforce_det3_helper(m,0,1,2) 66 | - bruteforce_det3_helper(m,1,0,2) 67 | + bruteforce_det3_helper(m,2,0,1); 68 | } 69 | }; 70 | 71 | template struct determinant_impl 72 | { 73 | static typename traits::Scalar run(const Derived& m) 74 | { 75 | // trick by Martin Costabel to compute 4x4 det with only 30 muls 76 | return bruteforce_det4_helper(m,0,1,2,3) 77 | - bruteforce_det4_helper(m,0,2,1,3) 78 | + bruteforce_det4_helper(m,0,3,1,2) 79 | + bruteforce_det4_helper(m,1,2,0,3) 80 | - bruteforce_det4_helper(m,1,3,0,2) 81 | + bruteforce_det4_helper(m,2,3,0,1); 82 | } 83 | }; 84 | 85 | } // end namespace internal 86 | 87 | /** \lu_module 88 | * 89 | * \returns the determinant of this matrix 90 | */ 91 | template 92 | inline typename internal::traits::Scalar MatrixBase::determinant() const 93 | { 94 | eigen_assert(rows() == cols()); 95 | typedef typename internal::nested::type Nested; 96 | return internal::determinant_impl::type>::run(derived()); 97 | } 98 | 99 | } // end namespace Eigen 100 | 101 | #endif // EIGEN_DETERMINANT_H 102 | -------------------------------------------------------------------------------- /bakeryoptix/utils/variant.cpp: -------------------------------------------------------------------------------- 1 | #include "variant.h" 2 | 3 | namespace utils 4 | { 5 | variant::variant(const char* value): values_(1, value) { } 6 | variant::variant(const wchar_t* value): values_(1, utf16_to_utf8(value)) { } 7 | variant::variant(const std::vector&& values): values_(values) { } 8 | std::vector& variant::data() { return values_; } 9 | const std::vector& variant::data() const { return values_; } 10 | 11 | static bool isdigit(const char c) 12 | { 13 | return c >= '0' && c <= '9' || c == '-' || c == '.'; 14 | } 15 | 16 | static float safe_strtof(const char* c) 17 | { 18 | if (!isdigit(c[0])) return 0.f; 19 | return std::strtof(c, nullptr); 20 | } 21 | 22 | variant::variant(const std::vector&& values) 23 | { 24 | for (auto& v : values) 25 | { 26 | values_.push_back(utf16_to_utf8(v)); 27 | } 28 | } 29 | 30 | bool variant::as_bool(size_t i) const 31 | { 32 | return as(i) != 0 || i < values_.size() && (values_[i] == "true" || values_[i] == "True" || values_[i] == "TRUE"); 33 | } 34 | 35 | uint64_t variant::as_uint64_t(size_t i) const 36 | { 37 | if (i >= values_.size()) 38 | { 39 | return 0UL; 40 | } 41 | 42 | auto s = values_[i]; 43 | if (s.size() > 2 && s[0] == '0' && s[1] == 'x') return std::strtoull(s.c_str() + 2, nullptr, 16); 44 | if (s.empty() || !isdigit(s[0])) return 0UL; 45 | return std::stoull(values_[i], nullptr, 10); 46 | } 47 | 48 | int64_t variant::as_int64_t(size_t i) const 49 | { 50 | if (i >= values_.size()) 51 | { 52 | return 0L; 53 | } 54 | 55 | auto s = values_[i]; 56 | if (s.size() > 2 && s[0] == '0' && s[1] == 'x') return std::strtoull(s.c_str() + 2, nullptr, 16); 57 | if (s.empty() || !isdigit(s[0])) return 0L; 58 | return std::stoll(s, nullptr, 10); 59 | } 60 | 61 | double variant::as_double(size_t i) const 62 | { 63 | if (i >= values_.size()) return 0.0; 64 | auto s = values_[i]; 65 | if (s.empty() || !isdigit(s[0])) return 0.0; 66 | return std::strtod(s.c_str(), nullptr); 67 | } 68 | 69 | static std::string _default_string{}; 70 | 71 | const std::string& variant::as_string(size_t i) const 72 | { 73 | if (i >= values_.size()) return _default_string; 74 | return values_[i]; 75 | } 76 | 77 | std::wstring variant::as_wstring(size_t i) const 78 | { 79 | if (i >= values_.size()) return std::wstring(); 80 | return utf8_to_utf16(values_[i]); 81 | } 82 | 83 | float2 variant::as_float2(size_t i) const 84 | { 85 | float2 result; 86 | for (int k = 0; k < 2; k++) 87 | { 88 | ((float*)&result)[k] = i + k >= values_.size() ? 0.0f : safe_strtof(values_[i + k].c_str()); 89 | } 90 | if (values_.size() == 1) 91 | { 92 | result.y = result.x; 93 | } 94 | return result; 95 | } 96 | 97 | float3 variant::as_float3(size_t i) const 98 | { 99 | float3 result; 100 | for (int k = 0; k < 3; k++) 101 | { 102 | ((float*)&result)[k] = i + k >= values_.size() ? 0.0f : safe_strtof(values_[i + k].c_str()); 103 | } 104 | if (values_.size() == 1) 105 | { 106 | result.y = result.z = result.x; 107 | } 108 | return result; 109 | } 110 | 111 | float4 variant::as_float4(size_t i) const 112 | { 113 | float4 result; 114 | for (int k = 0; k < 4; k++) 115 | { 116 | ((float*)&result)[k] = i + k >= values_.size() ? 0.0f : safe_strtof(values_[i + k].c_str()); 117 | } 118 | if (values_.size() == 1) 119 | { 120 | result.y = result.z = result.w = result.x; 121 | } 122 | return result; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /bakeryoptix/rayintersection.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-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 | #include 30 | 31 | #include "ray.h" 32 | 33 | #include 34 | #include 35 | 36 | struct vertex 37 | { 38 | float3 pos; 39 | float3 tex; 40 | }; 41 | 42 | rtBuffer attributesBuffer; 43 | rtBuffer indicesBuffer; 44 | 45 | // Attributes. 46 | rtDeclareVariable(optix::float3, varGeoNormal, attribute GEO_NORMAL, ); 47 | //rtDeclareVariable(optix::float3, varTangent, attribute TANGENT, ); 48 | rtDeclareVariable(optix::float3, varNormal, attribute NORMAL, ); 49 | rtDeclareVariable(optix::float3, varTexCoord, attribute TEXCOORD, ); 50 | 51 | rtDeclareVariable(optix::Ray, theRay, rtCurrentRay, ); 52 | 53 | // Intersection routine for indexed interleaved triangle data. 54 | RT_PROGRAM void rayintersection(int primitiveIndex) 55 | { 56 | const uint3 indices = indicesBuffer[primitiveIndex]; 57 | 58 | vertex const& a0 = attributesBuffer[indices.x]; 59 | vertex const& a1 = attributesBuffer[indices.y]; 60 | vertex const& a2 = attributesBuffer[indices.z]; 61 | 62 | const vertex v0 = a0; 63 | const vertex v1 = a1; 64 | const vertex v2 = a2; 65 | 66 | float3 n; 67 | float t; 68 | float beta; 69 | float gamma; 70 | 71 | if (intersect_triangle(theRay, v0.pos, v1.pos, v2.pos, n, t, beta, gamma)) 72 | { 73 | if (rtPotentialIntersection(t)) 74 | { 75 | // Barycentric interpolation: 76 | const float alpha = 1.0f - beta - gamma; 77 | 78 | // Note: No normalization on the TBN attributes here for performance reasons. 79 | // It's done after the transformation into world space anyway. 80 | varGeoNormal = n; 81 | //varTangent = a0.tangent * alpha + a1.tangent * beta + a2.tangent * gamma; 82 | //varNormal = a0.normal * alpha + a1.normal * beta + a2.normal * gamma; 83 | varNormal = n; 84 | varTexCoord = a0.tex * alpha + a1.tex * beta + a2.tex * gamma; 85 | 86 | rtReportIntersection(0); 87 | } 88 | } 89 | } 90 | --------------------------------------------------------------------------------