├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── Dockerfile ├── LICENSE.txt ├── README.md ├── appveyor.yml ├── cmake ├── FindASan.cmake ├── FindMSan.cmake ├── FindSanitizers.cmake ├── FindTSan.cmake ├── FindUBSan.cmake ├── asan-wrapper └── sanitize-helpers.cmake ├── exporters └── cinema4d │ ├── PBRT Export │ ├── pbrt.pyp │ └── res │ │ ├── c4d_symbols.h │ │ ├── dialogs │ │ └── dlg_pbrt.res │ │ ├── pbrt-env-bake.c4d │ │ └── strings_us │ │ ├── c4d_strings.str │ │ └── dialogs │ │ └── dlg_pbrt.str │ └── readme.md ├── scenes ├── README.md ├── suzanne_glint_rx0p5_ry0p1_lmd21.pbrt ├── suzanne_glint_rx0p5_ry0p1_lmd21.png ├── suzanne_glint_rx0p5_ry0p5_lmd21.pbrt ├── suzanne_glint_rx0p5_ry0p5_lmd21.png ├── suzanne_glint_rx0p6_ry0p6_lmd15_mra0p01.pbrt ├── suzanne_glint_rx0p6_ry0p6_lmd15_mra0p01.png ├── suzanne_mesh.pbrt └── textures │ └── dict_16_192_64_0p5_0p2.exr └── src ├── .clang-format ├── accelerators ├── bvh.cpp ├── bvh.h ├── kdtreeaccel.cpp └── kdtreeaccel.h ├── cameras ├── environment.cpp ├── environment.h ├── orthographic.cpp ├── orthographic.h ├── perspective.cpp ├── perspective.h ├── realistic.cpp └── realistic.h ├── core ├── api.cpp ├── api.h ├── bssrdf.cpp ├── bssrdf.h ├── camera.cpp ├── camera.h ├── efloat.cpp ├── efloat.h ├── error.cpp ├── error.h ├── fileutil.cpp ├── fileutil.h ├── film.cpp ├── film.h ├── filter.cpp ├── filter.h ├── floatfile.cpp ├── floatfile.h ├── geometry.cpp ├── geometry.h ├── imageio.cpp ├── imageio.h ├── integrator.cpp ├── integrator.h ├── interaction.cpp ├── interaction.h ├── interpolation.cpp ├── interpolation.h ├── light.cpp ├── light.h ├── lightdistrib.cpp ├── lightdistrib.h ├── lowdiscrepancy.cpp ├── lowdiscrepancy.h ├── material.cpp ├── material.h ├── medium.cpp ├── medium.h ├── memory.cpp ├── memory.h ├── microfacet.cpp ├── microfacet.h ├── mipmap.h ├── parallel.cpp ├── parallel.h ├── paramset.cpp ├── paramset.h ├── parser.cpp ├── parser.h ├── pbrt.h ├── primitive.cpp ├── primitive.h ├── progressreporter.cpp ├── progressreporter.h ├── quaternion.cpp ├── quaternion.h ├── reflection.cpp ├── reflection.h ├── rng.h ├── sampler.cpp ├── sampler.h ├── sampling.cpp ├── sampling.h ├── scene.cpp ├── scene.h ├── shape.cpp ├── shape.h ├── sobolmatrices.cpp ├── sobolmatrices.h ├── spectrum.cpp ├── spectrum.h ├── stats.cpp ├── stats.h ├── stringprint.h ├── texture.cpp ├── texture.h ├── transform.cpp └── transform.h ├── ext ├── ArHosekSkyModel.c ├── ArHosekSkyModel.h ├── ArHosekSkyModelData_CIEXYZ.h ├── ArHosekSkyModelData_RGB.h ├── ArHosekSkyModelData_Spectral.h ├── lodepng.cpp ├── lodepng.h ├── rply.cpp ├── rply.h ├── targa.cpp └── targa.h ├── filters ├── box.cpp ├── box.h ├── gaussian.cpp ├── gaussian.h ├── mitchell.cpp ├── mitchell.h ├── sinc.cpp ├── sinc.h ├── triangle.cpp └── triangle.h ├── integrators ├── ao.cpp ├── ao.h ├── bdpt.cpp ├── bdpt.h ├── directlighting.cpp ├── directlighting.h ├── mlt.cpp ├── mlt.h ├── path.cpp ├── path.h ├── sppm.cpp ├── sppm.h ├── volpath.cpp ├── volpath.h ├── whitted.cpp └── whitted.h ├── lights ├── diffuse.cpp ├── diffuse.h ├── distant.cpp ├── distant.h ├── goniometric.cpp ├── goniometric.h ├── infinite.cpp ├── infinite.h ├── point.cpp ├── point.h ├── projection.cpp ├── projection.h ├── spot.cpp └── spot.h ├── main └── pbrt.cpp ├── materials ├── disney.cpp ├── disney.h ├── fourier.cpp ├── fourier.h ├── glass.cpp ├── glass.h ├── hair.cpp ├── hair.h ├── kdsubsurface.cpp ├── kdsubsurface.h ├── matte.cpp ├── matte.h ├── metal.cpp ├── metal.h ├── mirror.cpp ├── mirror.h ├── mixmat.cpp ├── mixmat.h ├── plastic.cpp ├── plastic.h ├── sparkling.cpp ├── sparkling.h ├── substrate.cpp ├── substrate.h ├── subsurface.cpp ├── subsurface.h ├── translucent.cpp ├── translucent.h ├── uber.cpp └── uber.h ├── media ├── grid.cpp ├── grid.h ├── homogeneous.cpp └── homogeneous.h ├── samplers ├── halton.cpp ├── halton.h ├── maxmin.cpp ├── maxmin.h ├── random.cpp ├── random.h ├── sobol.cpp ├── sobol.h ├── stratified.cpp ├── stratified.h ├── zerotwosequence.cpp └── zerotwosequence.h ├── shapes ├── cone.cpp ├── cone.h ├── curve.cpp ├── curve.h ├── cylinder.cpp ├── cylinder.h ├── disk.cpp ├── disk.h ├── heightfield.cpp ├── heightfield.h ├── hyperboloid.cpp ├── hyperboloid.h ├── loopsubdiv.cpp ├── loopsubdiv.h ├── nurbs.cpp ├── nurbs.h ├── paraboloid.cpp ├── paraboloid.h ├── plymesh.cpp ├── plymesh.h ├── sphere.cpp ├── sphere.h ├── triangle.cpp └── triangle.h ├── tests ├── analytic_scenes.cpp ├── animatedtransform.cpp ├── bitops.cpp ├── bounds.cpp ├── bsdfs.cpp ├── fileutil.cpp ├── find_interval.cpp ├── fourierbsdf.cpp ├── fp_tests.cpp ├── gtest │ ├── gtest-all.cc │ ├── gtest.h │ └── gtest_main.cc ├── hair.cpp ├── hg.cpp ├── imageio.cpp ├── parallel.cpp ├── parser.cpp ├── print.cpp ├── sampling.cpp ├── shapes.cpp └── spectrum.cpp ├── textures ├── bilerp.cpp ├── bilerp.h ├── checkerboard.cpp ├── checkerboard.h ├── constant.cpp ├── constant.h ├── dots.cpp ├── dots.h ├── fbm.cpp ├── fbm.h ├── imagemap.cpp ├── imagemap.h ├── marble.cpp ├── marble.h ├── mix.cpp ├── mix.h ├── ptex.cpp ├── ptex.h ├── scale.cpp ├── scale.h ├── uv.cpp ├── uv.h ├── windy.cpp ├── windy.h ├── wrinkled.cpp └── wrinkled.h └── tools ├── bsdftest.cpp ├── cyhair2pbrt.cpp ├── imgtool.cpp └── obj2pbrt.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | src/build 3 | src/bin 4 | src/objs 5 | .sconsign.dblite 6 | 7 | build/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/ext/openexr"] 2 | path = src/ext/openexr 3 | url = https://github.com/wjakob/openexr 4 | [submodule "src/ext/zlib"] 5 | path = src/ext/zlib 6 | url = https://github.com/mitsuba-renderer/zlib 7 | [submodule "src/ext/glog"] 8 | path = src/ext/glog 9 | url = https://github.com/google/glog.git 10 | [submodule "src/ext/ptex"] 11 | path = src/ext/ptex 12 | url = https://github.com/wdas/ptex.git 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: gcc 3 | sudo: required 4 | install: 5 | - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test 6 | - sudo apt-get update 7 | - sudo apt-get install -yq build-essential gcc-4.8 g++-4.8 make bison flex libpthread-stubs0-dev 8 | - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 9 | - echo 2 | sudo update-alternatives --config gcc 10 | - | 11 | CMAKE_URL="http://www.cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz" 12 | mkdir ${TRAVIS_BUILD_DIR}/cmake-local && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C ${TRAVIS_BUILD_DIR}/cmake-local 13 | export PATH=${TRAVIS_BUILD_DIR}/cmake-local/bin:${PATH} 14 | after_install: 15 | - g++ --version 16 | script: 17 | - cmake -G 'Unix Makefiles' 18 | - make -j2 19 | - ./pbrt_test 20 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.10 2 | MAINTAINER Amit Bakshi 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | RUN apt-get update -yq && apt-get install -yq \ 6 | build-essential \ 7 | gcc \ 8 | g++ \ 9 | cmake \ 10 | make \ 11 | libpthread-stubs0-dev 12 | ADD . /app 13 | WORKDIR /app/build 14 | RUN cmake -G 'Unix Makefiles' .. 15 | RUN /usr/bin/make -j8 16 | RUN ./pbrt_test 17 | 18 | 19 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 1998-2015, Matt Pharr, Greg Humphreys, and Wenzel Jakob. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | branches: 3 | only: 4 | - master 5 | - book 6 | os: 7 | - Visual Studio 2013 8 | - Visual Studio 2015 9 | - Visual Studio 2017 10 | configuration: Release 11 | platform: x64 12 | clone_folder: c:\pbrt-v3 13 | 14 | install: 15 | # os detection 16 | - ps: if ($env:VS140COMNTOOLS -gt 0) { $env:VS_VER = 14 } else { $env:VS_VER = 12 } 17 | - echo %VS_VER% 18 | - set PATH=C:\Program Files (x86)\MSBuild\%VS_VER%.0\Bin;%PATH% 19 | - echo %PATH% 20 | - git submodule update --init --recursive 21 | before_build: 22 | - md c:\pbrt-v3\build 23 | - cd c:\pbrt-v3\build 24 | - set WIN32=1 25 | - ps: if ($env:VS_VER -eq 14) {cmake -G "Visual Studio 14 2015 Win64" ..} else {cmake -G "Visual Studio 12 2013 Win64" ..} 26 | build: 27 | project: c:\pbrt-v3\build\pbrt-v3.sln 28 | parallel: true 29 | verbosity: normal 30 | build_script: 31 | - msbuild c:\pbrt-v3\build\pbrt-v3.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" 32 | after_build: 33 | - cd c:\pbrt-v3\build\Release 34 | - pbrt_test.exe 35 | -------------------------------------------------------------------------------- /cmake/FindASan.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | option(SANITIZE_ADDRESS "Enable AddressSanitizer for sanitized targets." Off) 26 | 27 | set(FLAG_CANDIDATES 28 | # Clang 3.2+ use this version. The no-omit-frame-pointer option is optional. 29 | "-g -fsanitize=address -fno-omit-frame-pointer" 30 | "-g -fsanitize=address" 31 | 32 | # Older deprecated flag for ASan 33 | "-g -faddress-sanitizer" 34 | ) 35 | 36 | 37 | if (SANITIZE_ADDRESS AND (SANITIZE_THREAD OR SANITIZE_MEMORY)) 38 | message(FATAL_ERROR "AddressSanitizer is not compatible with " 39 | "ThreadSanitizer or MemorySanitizer.") 40 | endif () 41 | 42 | 43 | include(sanitize-helpers) 44 | 45 | if (SANITIZE_ADDRESS) 46 | sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "AddressSanitizer" 47 | "ASan") 48 | 49 | find_program(ASan_WRAPPER "asan-wrapper" PATHS ${CMAKE_MODULE_PATH}) 50 | mark_as_advanced(ASan_WRAPPER) 51 | endif () 52 | 53 | function (add_sanitize_address TARGET) 54 | if (NOT SANITIZE_ADDRESS) 55 | return() 56 | endif () 57 | 58 | saitizer_add_flags(${TARGET} "AddressSanitizer" "ASan") 59 | endfunction () 60 | -------------------------------------------------------------------------------- /cmake/FindMSan.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | option(SANITIZE_MEMORY "Enable MemorySanitizer for sanitized targets." Off) 26 | 27 | set(FLAG_CANDIDATES 28 | "-g -fsanitize=memory" 29 | ) 30 | 31 | 32 | include(sanitize-helpers) 33 | 34 | if (SANITIZE_MEMORY) 35 | if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 36 | message(WARNING "MemorySanitizer disabled for target ${TARGET} because " 37 | "MemorySanitizer is supported for Linux systems only.") 38 | set(SANITIZE_MEMORY Off CACHE BOOL 39 | "Enable MemorySanitizer for sanitized targets." FORCE) 40 | elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8) 41 | message(WARNING "MemorySanitizer disabled for target ${TARGET} because " 42 | "MemorySanitizer is supported for 64bit systems only.") 43 | set(SANITIZE_MEMORY Off CACHE BOOL 44 | "Enable MemorySanitizer for sanitized targets." FORCE) 45 | else () 46 | sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "MemorySanitizer" 47 | "MSan") 48 | endif () 49 | endif () 50 | 51 | function (add_sanitize_memory TARGET) 52 | if (NOT SANITIZE_MEMORY) 53 | return() 54 | endif () 55 | 56 | saitizer_add_flags(${TARGET} "MemorySanitizer" "MSan") 57 | endfunction () 58 | -------------------------------------------------------------------------------- /cmake/FindSanitizers.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | # If any of the used compiler is a GNU compiler, add a second option to static 26 | # link against the sanitizers. 27 | option(SANITIZE_LINK_STATIC "Try to link static against sanitizers." Off) 28 | 29 | 30 | 31 | 32 | set(FIND_QUIETLY_FLAG "") 33 | if (DEFINED Sanitizers_FIND_QUIETLY) 34 | set(FIND_QUIETLY_FLAG "QUIET") 35 | endif () 36 | 37 | find_package(ASan ${FIND_QUIETLY_FLAG}) 38 | find_package(TSan ${FIND_QUIETLY_FLAG}) 39 | find_package(MSan ${FIND_QUIETLY_FLAG}) 40 | find_package(UBSan ${FIND_QUIETLY_FLAG}) 41 | 42 | 43 | 44 | 45 | function(sanitizer_add_blacklist_file FILE) 46 | if(NOT IS_ABSOLUTE ${FILE}) 47 | set(FILE "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}") 48 | endif() 49 | get_filename_component(FILE "${FILE}" REALPATH) 50 | 51 | sanitizer_check_compiler_flags("-fsanitize-blacklist=${FILE}" 52 | "SanitizerBlacklist" "SanBlist") 53 | endfunction() 54 | 55 | function(add_sanitizers ...) 56 | foreach (TARGET ${ARGV}) 57 | add_sanitize_address(${TARGET}) 58 | add_sanitize_thread(${TARGET}) 59 | add_sanitize_memory(${TARGET}) 60 | add_sanitize_undefined(${TARGET}) 61 | endforeach () 62 | endfunction(add_sanitizers) 63 | -------------------------------------------------------------------------------- /cmake/FindTSan.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | option(SANITIZE_THREAD "Enable ThreadSanitizer for sanitized targets." Off) 26 | 27 | set(FLAG_CANDIDATES 28 | "-g -fsanitize=thread" 29 | ) 30 | 31 | 32 | # ThreadSanitizer is not compatible with MemorySanitizer. 33 | if (SANITIZE_THREAD AND SANITIZE_MEMORY) 34 | message(FATAL_ERROR "ThreadSanitizer is not compatible with " 35 | "MemorySanitizer.") 36 | endif () 37 | 38 | 39 | include(sanitize-helpers) 40 | 41 | if (SANITIZE_THREAD) 42 | if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 43 | message(WARNING "ThreadSanitizer disabled for target ${TARGET} because " 44 | "ThreadSanitizer is supported for Linux systems only.") 45 | set(SANITIZE_THREAD Off CACHE BOOL 46 | "Enable ThreadSanitizer for sanitized targets." FORCE) 47 | elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8) 48 | message(WARNING "ThreadSanitizer disabled for target ${TARGET} because " 49 | "ThreadSanitizer is supported for 64bit systems only.") 50 | set(SANITIZE_THREAD Off CACHE BOOL 51 | "Enable ThreadSanitizer for sanitized targets." FORCE) 52 | else () 53 | sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ThreadSanitizer" 54 | "TSan") 55 | endif () 56 | endif () 57 | 58 | function (add_sanitize_thread TARGET) 59 | if (NOT SANITIZE_THREAD) 60 | return() 61 | endif () 62 | 63 | saitizer_add_flags(${TARGET} "ThreadSanitizer" "TSan") 64 | endfunction () 65 | -------------------------------------------------------------------------------- /cmake/FindUBSan.cmake: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # 3 | # Copyright (c) 4 | # 2013 Matthew Arsenault 5 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | option(SANITIZE_UNDEFINED 26 | "Enable UndefinedBehaviorSanitizer for sanitized targets." Off) 27 | 28 | set(FLAG_CANDIDATES 29 | "-g -fsanitize=undefined" 30 | ) 31 | 32 | 33 | include(sanitize-helpers) 34 | 35 | if (SANITIZE_UNDEFINED) 36 | sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" 37 | "UndefinedBehaviorSanitizer" "UBSan") 38 | endif () 39 | 40 | function (add_sanitize_undefined TARGET) 41 | if (NOT SANITIZE_UNDEFINED) 42 | return() 43 | endif () 44 | 45 | saitizer_add_flags(${TARGET} "UndefinedBehaviorSanitizer" "UBSan") 46 | endfunction () 47 | -------------------------------------------------------------------------------- /cmake/asan-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # The MIT License (MIT) 4 | # 5 | # Copyright (c) 6 | # 2013 Matthew Arsenault 7 | # 2015-2016 RWTH Aachen University, Federal Republic of Germany 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | 27 | # This script is a wrapper for AddressSanitizer. In some special cases you need 28 | # to preload AddressSanitizer to avoid error messages - e.g. if you're 29 | # preloading another library to your application. At the moment this script will 30 | # only do something, if we're running on a Linux platform. OSX might not be 31 | # affected. 32 | 33 | 34 | # Exit immediately, if platform is not Linux. 35 | if [ "$(uname)" != "Linux" ] 36 | then 37 | exec $@ 38 | fi 39 | 40 | 41 | # Get the used libasan of the application ($1). If a libasan was found, it will 42 | # be prepended to LD_PRELOAD. 43 | libasan=$(ldd $1 | grep libasan | sed "s/^[[:space:]]//" | cut -d' ' -f1) 44 | if [ -n "$libasan" ] 45 | then 46 | if [ -n "$LD_PRELOAD" ] 47 | then 48 | export LD_PRELOAD="$libasan:$LD_PRELOAD" 49 | else 50 | export LD_PRELOAD="$libasan" 51 | fi 52 | fi 53 | 54 | # Execute the application. 55 | exec $@ 56 | -------------------------------------------------------------------------------- /exporters/cinema4d/PBRT Export/res/c4d_symbols.h: -------------------------------------------------------------------------------- 1 | enum 2 | { 3 | DLG_PBRT = 60000, 4 | IDS_PBRT, 5 | IDC_PBRT_START, 6 | IDC_PBRT_LOG, 7 | IDC_PBRT_EXE, 8 | IDC_PBRT_MODE, 9 | IDC_PBRT_MODE_EXPORT, 10 | IDC_PBRT_MODE_EXPORT_AND_RENDER, 11 | IDC_PBRT_MODE_RENDER, 12 | IDC_PBRT_SAMPLES, 13 | IDC_PBRT_ABORT, 14 | IDC_BUTTON_GROUP, 15 | IDC_PBRT_LOGLEVEL, 16 | IDC_PBRT_LOGLEVEL_DEBUG, 17 | IDC_PBRT_LOGLEVEL_INFO, 18 | IDC_PBRT_LOGLEVEL_WARNING, 19 | IDC_PBRT_LOGLEVEL_ERROR, 20 | IDC_PBRT_INTENSITY, 21 | IDS_PBRT_START = 60100, 22 | IDS_PBRT_ABORT, 23 | }; 24 | -------------------------------------------------------------------------------- /exporters/cinema4d/PBRT Export/res/dialogs/dlg_pbrt.res: -------------------------------------------------------------------------------- 1 | // C4D-DialogResource 2 | DIALOG DLG_PBRT 3 | { 4 | NAME IDS_PBRT; 5 | SCALE_V; SCALE_H; 6 | GROUP 7 | { 8 | SCALE_V; SCALE_H; 9 | COLUMNS 1; 10 | 11 | GROUP 12 | { 13 | SCALE_H; 14 | COLUMNS 2; 15 | BORDERSIZE 4, 4, 4, 4; 16 | 17 | STATICTEXT 0 { NAME IDS_PBRT_MODE; ALIGN_LEFT; } 18 | COMBOBOX IDC_PBRT_MODE 19 | { 20 | //SIZE 100; 21 | SCALE_H; 22 | CHILDS 23 | { 24 | IDC_PBRT_MODE_EXPORT_AND_RENDER, IDS_PBRT_MODE_EXPORT_AND_RENDER; 25 | IDC_PBRT_MODE_EXPORT, IDS_PBRT_MODE_EXPORT; 26 | IDC_PBRT_MODE_RENDER, IDS_PBRT_MODE_RENDER; 27 | } 28 | } 29 | 30 | STATICTEXT 0 { NAME IDS_PBRT_EXE; ALIGN_LEFT; } 31 | FILENAME IDC_PBRT_EXE { SCALE_H; } 32 | 33 | STATICTEXT 0 { NAME IDS_PBRT_SAMPLES; ALIGN_LEFT; } 34 | EDITNUMBERARROWS IDC_PBRT_SAMPLES { SCALE_H; } 35 | 36 | STATICTEXT 0 { NAME IDS_PBRT_INTENSITY; ALIGN_LEFT; } 37 | EDITNUMBERARROWS IDC_PBRT_INTENSITY { SCALE_H; } 38 | 39 | STATICTEXT 0 { NAME IDS_PBRT_LOGLEVEL; ALIGN_LEFT; } 40 | COMBOBOX IDC_PBRT_LOGLEVEL 41 | { 42 | SCALE_H; 43 | CHILDS 44 | { 45 | IDC_PBRT_LOGLEVEL_DEBUG, IDS_PBRT_LOGLEVEL_DEBUG; 46 | IDC_PBRT_LOGLEVEL_INFO, IDS_PBRT_LOGLEVEL_INFO; 47 | IDC_PBRT_LOGLEVEL_WARNING, IDS_PBRT_LOGLEVEL_WARNING; 48 | IDC_PBRT_LOGLEVEL_ERROR, IDS_PBRT_LOGLEVEL_ERROR; 49 | } 50 | } 51 | 52 | STATICTEXT 0 { } 53 | GROUP IDC_BUTTON_GROUP 54 | { 55 | SCALE_H; 56 | COLUMNS 1; 57 | } 58 | } 59 | 60 | TREEVIEW IDC_PBRT_LOG { HAS_HEADER; ALTERNATE_BG; FIXED_LAYOUT; RESIZE_HEADER; SCALE_V; SCALE_H; BORDER; } 61 | } 62 | } -------------------------------------------------------------------------------- /exporters/cinema4d/PBRT Export/res/pbrt-env-bake.c4d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xavierchermain/pbrt-v3-procedural-glint/0e9fc8c91ba43a71f79a7d842b8e7027cbef3b88/exporters/cinema4d/PBRT Export/res/pbrt-env-bake.c4d -------------------------------------------------------------------------------- /exporters/cinema4d/PBRT Export/res/strings_us/c4d_strings.str: -------------------------------------------------------------------------------- 1 | // C4D-StringResource 2 | // Identifier Text 3 | 4 | STRINGTABLE 5 | { 6 | IDS_PBRT_START "Start"; 7 | IDS_PBRT_ABORT "Abort"; 8 | } 9 | -------------------------------------------------------------------------------- /exporters/cinema4d/PBRT Export/res/strings_us/dialogs/dlg_pbrt.str: -------------------------------------------------------------------------------- 1 | // C4D-DialogResource 2 | 3 | DIALOGSTRINGS DLG_PBRT 4 | { 5 | IDS_PBRT "Export to PBRT"; 6 | IDS_PBRT_EXE "Renderer"; 7 | IDS_PBRT_MODE "Mode"; 8 | IDS_PBRT_MODE_EXPORT "Export"; 9 | IDS_PBRT_MODE_EXPORT_AND_RENDER "Export and Render"; 10 | IDS_PBRT_MODE_RENDER "Render"; 11 | IDS_PBRT_SAMPLES "Samples"; 12 | IDS_PBRT_INTENSITY "Light Intensity"; 13 | IDS_PBRT_LOGLEVEL "Logging Level"; 14 | IDS_PBRT_LOGLEVEL_DEBUG "Debug"; 15 | IDS_PBRT_LOGLEVEL_INFO "Info"; 16 | IDS_PBRT_LOGLEVEL_WARNING "Warning"; 17 | IDS_PBRT_LOGLEVEL_ERROR "Error"; 18 | } 19 | -------------------------------------------------------------------------------- /exporters/cinema4d/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # PBRT Exporter for Cinema 4D 3 | 4 | ## Compatibility 5 | 6 | This version of the PBRT Exporter for Cinema 4D has been tested with PBRT v3 and Cinema 4D R16. It will probably also work with earlier and later Cinema 4D versions. It will definitely not work with different versions than PBRT v3. 7 | 8 | ## Installation 9 | 10 | To install the exporter, just copy the 'PBRT Export' folder into the plugins folder of your Cinema 4D Installation. It will then show up in the Plugins menu the next time you start Cinema 4D. 11 | 12 | ## Operation 13 | 14 | Choosing 'Export to PBRT...' from the Plugins menu will open the export dialog. The export mode controls where PBRT files are written and whether the renderer is started. The 'Render' mode will export the scene to a temporary location, start pbrt and open the resulting image in the Picture Viewer once the rendering is done. 'Export' will ask you for a location the pbrt scene should be written to. 'Export and Render' will ask you where the scene should be written and will start a rendering. For 'Render' and 'Export and Render' is important to let the plugin know where your pbrt executable is located. This can be specified using the 'Renderer' input field. 'Samples' allows you to specify the number of Samples per Pixel to be used. 'Light Intensity' lets you globally scale the intensity of all exported light sources in the scene. During export, a detailed log is created. The 'Logging Level' lets you choose how much detail you want to see in the log window at the bottom of the export dialog. 15 | 16 | By default, the 'directlighting' integrator is used. When a Global Illumination effect is added to the regular Cinema 4D render settings, the 'path' integrator is used instead. 17 | 18 | ## Supported Features 19 | 20 | - Omni and Distant Light sources are exported 21 | - The Physical Sky object will have appropriate light sources added and the background is baked into an environment texture and added as infinite light. 22 | - All geometric objects that create polygons are exported. 23 | - The plugin attempts to move basic material attributes (base color, specularity, bump). Furthermore it detects translucency setups using the Backlight shader and attempts to translate those. 24 | 25 | ## Copyright 26 | 27 | This plugin has been created by Burak Kahraman and Timm Dapper of Laubwerk GmbH (www.laubwerk.com). It is distributed under the same license as the rest of the PBRT repository. 28 | -------------------------------------------------------------------------------- /scenes/README.md: -------------------------------------------------------------------------------- 1 | pbrt example scene 2 | ================== 3 | 4 | This folder contains three example scenes which use our procedural glinty BRDF 5 | with different parameters. -------------------------------------------------------------------------------- /scenes/suzanne_glint_rx0p5_ry0p1_lmd21.pbrt: -------------------------------------------------------------------------------- 1 | Film "image" 2 | "integer xresolution" [ 320 ] 3 | "integer yresolution" [ 320 ] 4 | "string filename" [ "suzanne_glint_rx0p5_ry0p1_lmd21.png" ] 5 | 6 | LookAt 0 0 8 7 | 0 0 0 8 | 0 1 0 9 | 10 | Camera "perspective" 11 | "float fov" [ 50 ] 12 | 13 | Sampler "stratified" 14 | "integer xsamples" 1 15 | "integer ysamples" 1 16 | "bool jitter" "false" 17 | PixelFilter "box" 18 | Integrator "directlighting" 19 | #"integer pixelbounds" [160 161 160 161] 20 | 21 | WorldBegin 22 | 23 | AttributeBegin 24 | Translate 0 0 8 25 | LightSource "point" "rgb I" [ 100 100 100 ] 26 | AttributeEnd 27 | 28 | Texture "dictionary" "spectrum" "imagemap" 29 | "string filename" "./textures/dict_16_192_64_0p5_0p2.exr" 30 | "string wrap" "clamp" 31 | "float uscale" [1] "float vscale" [1] 32 | 33 | MakeNamedMaterial "glint" 34 | "string type" ["sparkling"] 35 | "float alpha_x" [0.5] 36 | "float alpha_y" [0.1] 37 | "float logmicrofacetdensity" [21] 38 | "float densityrandomisation" [0.01] 39 | "float microfacetrelativearea" [1.] 40 | "integer N" [192] 41 | "integer nlevels" [16] 42 | "float alpha_dict" [0.5] 43 | "rgb R" [0.3 0.3 0.3] 44 | "texture dictionary" "dictionary" 45 | "bool fresnelnoop" "true" 46 | 47 | MakeNamedMaterial "MatDiffuse" 48 | "string type" ["matte"] 49 | "rgb Kd" [0. 0.8 0.] 50 | 51 | MakeNamedMaterial "MatMix" 52 | "string type" ["mix"] 53 | "string namedmaterial1" "glint" 54 | "string namedmaterial2" "MatDiffuse" 55 | 56 | AttributeBegin 57 | Translate 0 0.25 0 58 | NamedMaterial "MatMix" 59 | Include "suzanne_mesh.pbrt" 60 | AttributeEnd 61 | 62 | WorldEnd 63 | -------------------------------------------------------------------------------- /scenes/suzanne_glint_rx0p5_ry0p1_lmd21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xavierchermain/pbrt-v3-procedural-glint/0e9fc8c91ba43a71f79a7d842b8e7027cbef3b88/scenes/suzanne_glint_rx0p5_ry0p1_lmd21.png -------------------------------------------------------------------------------- /scenes/suzanne_glint_rx0p5_ry0p5_lmd21.pbrt: -------------------------------------------------------------------------------- 1 | Film "image" 2 | "integer xresolution" [ 320 ] 3 | "integer yresolution" [ 320 ] 4 | "string filename" [ "suzanne_glint_rx0p5_ry0p5_lmd21.png" ] 5 | 6 | LookAt 0 0 8 7 | 0 0 0 8 | 0 1 0 9 | 10 | Camera "perspective" 11 | "float fov" [ 50 ] 12 | 13 | Sampler "stratified" 14 | "integer xsamples" 1 15 | "integer ysamples" 1 16 | "bool jitter" "false" 17 | PixelFilter "box" 18 | Integrator "directlighting" 19 | #"integer pixelbounds" [160 161 160 161] 20 | 21 | WorldBegin 22 | 23 | AttributeBegin 24 | Translate 0 0 8 25 | LightSource "point" "rgb I" [ 100 100 100 ] 26 | AttributeEnd 27 | 28 | Texture "dictionary" "spectrum" "imagemap" 29 | "string filename" "./textures/dict_16_192_64_0p5_0p2.exr" 30 | "string wrap" "clamp" 31 | "float uscale" [1] "float vscale" [1] 32 | 33 | MakeNamedMaterial "glint" 34 | "string type" ["sparkling"] 35 | "float alpha_x" [0.5] 36 | "float alpha_y" [0.5] 37 | "float logmicrofacetdensity" [21] 38 | "float densityrandomisation" [0.01] 39 | "float microfacetrelativearea" [1.] 40 | "integer N" [192] 41 | "integer nlevels" [16] 42 | "float alpha_dict" [0.5] 43 | #"rgb R" [0.3 0.3 0.3] 44 | "texture dictionary" "dictionary" 45 | "bool fresnelnoop" "true" 46 | 47 | MakeNamedMaterial "MatDiffuse" 48 | "string type" ["matte"] 49 | "rgb Kd" [0. 0.8 0.] 50 | 51 | MakeNamedMaterial "MatMix" 52 | "string type" ["mix"] 53 | "string namedmaterial1" "glint" 54 | "string namedmaterial2" "MatDiffuse" 55 | 56 | AttributeBegin 57 | Translate 0 0.25 0 58 | NamedMaterial "MatMix" 59 | Include "suzanne_mesh.pbrt" 60 | AttributeEnd 61 | 62 | WorldEnd 63 | -------------------------------------------------------------------------------- /scenes/suzanne_glint_rx0p5_ry0p5_lmd21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xavierchermain/pbrt-v3-procedural-glint/0e9fc8c91ba43a71f79a7d842b8e7027cbef3b88/scenes/suzanne_glint_rx0p5_ry0p5_lmd21.png -------------------------------------------------------------------------------- /scenes/suzanne_glint_rx0p6_ry0p6_lmd15_mra0p01.pbrt: -------------------------------------------------------------------------------- 1 | Film "image" 2 | "integer xresolution" [ 320 ] 3 | "integer yresolution" [ 320 ] 4 | "string filename" [ "suzanne_glint_rx0p6_ry0p6_lmd15_mra0p01.png" ] 5 | 6 | LookAt 0 0 8 7 | 0 0 0 8 | 0 1 0 9 | 10 | Camera "perspective" 11 | "float fov" [ 50 ] 12 | 13 | Sampler "stratified" 14 | "integer xsamples" 1 15 | "integer ysamples" 1 16 | "bool jitter" "false" 17 | PixelFilter "box" 18 | Integrator "directlighting" 19 | #"integer pixelbounds" [160 161 160 161] 20 | 21 | WorldBegin 22 | 23 | AttributeBegin 24 | Translate 0 0 8 25 | LightSource "point" "rgb I" [ 100 100 100 ] 26 | AttributeEnd 27 | 28 | Texture "dictionary" "spectrum" "imagemap" 29 | "string filename" "./textures/dict_16_192_64_0p5_0p2.exr" 30 | "string wrap" "clamp" 31 | "float uscale" [1] "float vscale" [1] 32 | 33 | MakeNamedMaterial "glint" 34 | "string type" ["sparkling"] 35 | "float alpha_x" [0.6] 36 | "float alpha_y" [0.6] 37 | "float logmicrofacetdensity" [15] 38 | "float densityrandomisation" [2.] 39 | "float microfacetrelativearea" [0.01] 40 | "integer N" [192] 41 | "integer nlevels" [16] 42 | "float alpha_dict" [0.5] 43 | #"rgb R" [0.3 0.3 0.3] 44 | "texture dictionary" "dictionary" 45 | "bool fresnelnoop" "true" 46 | 47 | MakeNamedMaterial "MatDiffuse" 48 | "string type" ["matte"] 49 | "rgb Kd" [0. 0.8 0.] 50 | 51 | MakeNamedMaterial "MatMix" 52 | "string type" ["mix"] 53 | "string namedmaterial1" "glint" 54 | "string namedmaterial2" "MatDiffuse" 55 | 56 | AttributeBegin 57 | Translate 0 0.25 0 58 | NamedMaterial "MatMix" 59 | Include "suzanne_mesh.pbrt" 60 | AttributeEnd 61 | 62 | WorldEnd 63 | -------------------------------------------------------------------------------- /scenes/suzanne_glint_rx0p6_ry0p6_lmd15_mra0p01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xavierchermain/pbrt-v3-procedural-glint/0e9fc8c91ba43a71f79a7d842b8e7027cbef3b88/scenes/suzanne_glint_rx0p6_ry0p6_lmd15_mra0p01.png -------------------------------------------------------------------------------- /scenes/textures/dict_16_192_64_0p5_0p2.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xavierchermain/pbrt-v3-procedural-glint/0e9fc8c91ba43a71f79a7d842b8e7027cbef3b88/scenes/textures/dict_16_192_64_0p5_0p2.exr -------------------------------------------------------------------------------- /src/.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | AccessModifierOffset: -2 3 | IndentCaseLabels: false 4 | PointerBindsToType: false 5 | Standard: Cpp11 6 | IndentWidth: 4 7 | 8 | -------------------------------------------------------------------------------- /src/cameras/environment.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_CAMERAS_ENVIRONMENT_H 39 | #define PBRT_CAMERAS_ENVIRONMENT_H 40 | 41 | // cameras/environment.h* 42 | #include "camera.h" 43 | #include "film.h" 44 | 45 | namespace pbrt { 46 | 47 | // EnvironmentCamera Declarations 48 | class EnvironmentCamera : public Camera { 49 | public: 50 | // EnvironmentCamera Public Methods 51 | EnvironmentCamera(const AnimatedTransform &CameraToWorld, Float shutterOpen, 52 | Float shutterClose, Film *film, const Medium *medium) 53 | : Camera(CameraToWorld, shutterOpen, shutterClose, film, medium) {} 54 | Float GenerateRay(const CameraSample &sample, Ray *) const; 55 | }; 56 | 57 | EnvironmentCamera *CreateEnvironmentCamera(const ParamSet ¶ms, 58 | const AnimatedTransform &cam2world, 59 | Film *film, const Medium *medium); 60 | 61 | } // namespace pbrt 62 | 63 | #endif // PBRT_CAMERAS_ENVIRONMENT_H 64 | -------------------------------------------------------------------------------- /src/core/efloat.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // core/efloat.cpp* 35 | #include "efloat.h" 36 | 37 | namespace pbrt { 38 | 39 | } // namespace pbrt 40 | -------------------------------------------------------------------------------- /src/core/error.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_CORE_ERROR_H 39 | #define PBRT_CORE_ERROR_H 40 | 41 | // core/error.h* 42 | #include "pbrt.h" 43 | 44 | namespace pbrt { 45 | 46 | // Error Reporting Declarations 47 | 48 | // Setup printf format 49 | #ifdef __GNUG__ 50 | #define PRINTF_FUNC __attribute__((__format__(__printf__, 1, 2))) 51 | #else 52 | #define PRINTF_FUNC 53 | #endif // __GNUG__ 54 | void Warning(const char *, ...) PRINTF_FUNC; 55 | void Error(const char *, ...) PRINTF_FUNC; 56 | 57 | } // namespace pbrt 58 | 59 | #endif // PBRT_CORE_ERROR_H 60 | -------------------------------------------------------------------------------- /src/core/fileutil.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_CORE_FILEUTIL_H 39 | #define PBRT_CORE_FILEUTIL_H 40 | 41 | // core/fileutil.h* 42 | #include "pbrt.h" 43 | #include 44 | #include 45 | #include 46 | 47 | namespace pbrt { 48 | 49 | // Platform independent filename-handling functions. 50 | bool IsAbsolutePath(const std::string &filename); 51 | std::string AbsolutePath(const std::string &filename); 52 | std::string ResolveFilename(const std::string &filename); 53 | std::string DirectoryContaining(const std::string &filename); 54 | void SetSearchDirectory(const std::string &dirname); 55 | 56 | inline bool HasExtension(const std::string &value, const std::string &ending) { 57 | if (ending.size() > value.size()) return false; 58 | return std::equal( 59 | ending.rbegin(), ending.rend(), value.rbegin(), 60 | [](char a, char b) { return std::tolower(a) == std::tolower(b); }); 61 | } 62 | 63 | } // namespace pbrt 64 | 65 | #endif // PBRT_CORE_FILEUTIL_H 66 | -------------------------------------------------------------------------------- /src/core/filter.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // core/filter.cpp* 35 | #include "filter.h" 36 | 37 | namespace pbrt { 38 | 39 | // Filter Method Definitions 40 | Filter::~Filter() {} 41 | 42 | } // namespace pbrt 43 | -------------------------------------------------------------------------------- /src/core/filter.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_CORE_FILTER_H 39 | #define PBRT_CORE_FILTER_H 40 | 41 | // core/filter.h* 42 | #include "pbrt.h" 43 | #include "geometry.h" 44 | 45 | namespace pbrt { 46 | 47 | // Filter Declarations 48 | class Filter { 49 | public: 50 | // Filter Interface 51 | virtual ~Filter(); 52 | Filter(const Vector2f &radius) 53 | : radius(radius), invRadius(Vector2f(1 / radius.x, 1 / radius.y)) {} 54 | virtual Float Evaluate(const Point2f &p) const = 0; 55 | 56 | // Filter Public Data 57 | const Vector2f radius, invRadius; 58 | }; 59 | 60 | } // namespace pbrt 61 | 62 | #endif // PBRT_CORE_FILTER_H 63 | -------------------------------------------------------------------------------- /src/core/floatfile.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_CORE_FLOATFILE_H 39 | #define PBRT_CORE_FLOATFILE_H 40 | 41 | // core/floatfile.h* 42 | #include "pbrt.h" 43 | 44 | namespace pbrt { 45 | 46 | bool ReadFloatFile(const char *filename, std::vector *values); 47 | 48 | } // namespace pbrt 49 | 50 | #endif // PBRT_CORE_FLOATFILE_H 51 | -------------------------------------------------------------------------------- /src/core/geometry.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // core/geometry.cpp* 35 | #include "geometry.h" 36 | 37 | namespace pbrt { 38 | 39 | } // namespace pbrt 40 | -------------------------------------------------------------------------------- /src/core/imageio.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_CORE_IMAGEIO_H 39 | #define PBRT_CORE_IMAGEIO_H 40 | 41 | // core/imageio.h* 42 | #include "pbrt.h" 43 | #include "geometry.h" 44 | #include 45 | 46 | namespace pbrt { 47 | 48 | // ImageIO Declarations 49 | std::unique_ptr ReadImage(const std::string &name, 50 | Point2i *resolution); 51 | RGBSpectrum *ReadImageEXR(const std::string &name, int *width, 52 | int *height, Bounds2i *dataWindow = nullptr, 53 | Bounds2i *displayWindow = nullptr); 54 | 55 | void WriteImage(const std::string &name, const Float *rgb, 56 | const Bounds2i &outputBounds, const Point2i &totalResolution); 57 | 58 | } // namespace pbrt 59 | 60 | #endif // PBRT_CORE_IMAGEIO_H 61 | -------------------------------------------------------------------------------- /src/core/interpolation.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_CORE_INTERPOLATION_H 39 | #define PBRT_CORE_INTERPOLATION_H 40 | 41 | // core/interpolation.h* 42 | #include "pbrt.h" 43 | 44 | namespace pbrt { 45 | 46 | // Spline Interpolation Declarations 47 | Float CatmullRom(int size, const Float *nodes, const Float *values, Float x); 48 | bool CatmullRomWeights(int size, const Float *nodes, Float x, int *offset, 49 | Float *weights); 50 | Float SampleCatmullRom(int size, const Float *nodes, const Float *f, 51 | const Float *cdf, Float sample, Float *fval = nullptr, 52 | Float *pdf = nullptr); 53 | Float SampleCatmullRom2D(int size1, int size2, const Float *nodes1, 54 | const Float *nodes2, const Float *values, 55 | const Float *cdf, Float alpha, Float sample, 56 | Float *fval = nullptr, Float *pdf = nullptr); 57 | Float IntegrateCatmullRom(int n, const Float *nodes, const Float *values, 58 | Float *cdf); 59 | Float InvertCatmullRom(int n, const Float *x, const Float *values, Float u); 60 | 61 | // Fourier Interpolation Declarations 62 | Float Fourier(const Float *a, int m, double cosPhi); 63 | Float SampleFourier(const Float *ak, const Float *recip, int m, Float u, 64 | Float *pdf, Float *phiPtr); 65 | 66 | } // namespace pbrt 67 | 68 | #endif // PBRT_CORE_INTERPOLATION_H 69 | -------------------------------------------------------------------------------- /src/core/material.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_CORE_MATERIAL_H 39 | #define PBRT_CORE_MATERIAL_H 40 | 41 | // core/material.h* 42 | #include "pbrt.h" 43 | #include "memory.h" 44 | 45 | namespace pbrt { 46 | 47 | // TransportMode Declarations 48 | enum class TransportMode { Radiance, Importance }; 49 | 50 | // Material Declarations 51 | class Material { 52 | public: 53 | // Material Interface 54 | virtual void ComputeScatteringFunctions(SurfaceInteraction *si, 55 | MemoryArena &arena, 56 | TransportMode mode, 57 | bool allowMultipleLobes) const = 0; 58 | virtual ~Material(); 59 | static void Bump(const std::shared_ptr> &d, 60 | SurfaceInteraction *si); 61 | }; 62 | 63 | } // namespace pbrt 64 | 65 | #endif // PBRT_CORE_MATERIAL_H 66 | -------------------------------------------------------------------------------- /src/core/memory.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // core/memory.cpp* 35 | #include "memory.h" 36 | 37 | namespace pbrt { 38 | 39 | // Memory Allocation Functions 40 | void *AllocAligned(size_t size) { 41 | #if defined(PBRT_HAVE__ALIGNED_MALLOC) 42 | return _aligned_malloc(size, PBRT_L1_CACHE_LINE_SIZE); 43 | #elif defined(PBRT_HAVE_POSIX_MEMALIGN) 44 | void *ptr; 45 | if (posix_memalign(&ptr, PBRT_L1_CACHE_LINE_SIZE, size) != 0) ptr = nullptr; 46 | return ptr; 47 | #else 48 | return memalign(PBRT_L1_CACHE_LINE_SIZE, size); 49 | #endif 50 | } 51 | 52 | void FreeAligned(void *ptr) { 53 | if (!ptr) return; 54 | #if defined(PBRT_HAVE__ALIGNED_MALLOC) 55 | _aligned_free(ptr); 56 | #else 57 | free(ptr); 58 | #endif 59 | } 60 | 61 | } // namespace pbrt 62 | -------------------------------------------------------------------------------- /src/core/progressreporter.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_CORE_PROGRESSREPORTER_H 39 | #define PBRT_CORE_PROGRESSREPORTER_H 40 | 41 | // core/progressreporter.h* 42 | #include "pbrt.h" 43 | #include 44 | #include 45 | #include 46 | 47 | namespace pbrt { 48 | 49 | // ProgressReporter Declarations 50 | class ProgressReporter { 51 | public: 52 | // ProgressReporter Public Methods 53 | ProgressReporter(int64_t totalWork, const std::string &title); 54 | ~ProgressReporter(); 55 | void Update(int64_t num = 1) { 56 | if (num == 0 || PbrtOptions.quiet) return; 57 | workDone += num; 58 | } 59 | Float ElapsedMS() const { 60 | std::chrono::system_clock::time_point now = 61 | std::chrono::system_clock::now(); 62 | int64_t elapsedMS = 63 | std::chrono::duration_cast(now - 64 | startTime) 65 | .count(); 66 | return (Float)elapsedMS; 67 | } 68 | void Done(); 69 | 70 | private: 71 | // ProgressReporter Private Methods 72 | void PrintBar(); 73 | 74 | // ProgressReporter Private Data 75 | const int64_t totalWork; 76 | const std::string title; 77 | const std::chrono::system_clock::time_point startTime; 78 | std::atomic workDone; 79 | std::atomic exitThread; 80 | std::thread updateThread; 81 | }; 82 | 83 | } // namespace pbrt 84 | 85 | #endif // PBRT_CORE_PROGRESSREPORTER_H 86 | -------------------------------------------------------------------------------- /src/core/scene.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // core/scene.cpp* 35 | #include "scene.h" 36 | #include "stats.h" 37 | 38 | namespace pbrt { 39 | 40 | STAT_COUNTER("Intersections/Regular ray intersection tests", 41 | nIntersectionTests); 42 | STAT_COUNTER("Intersections/Shadow ray intersection tests", nShadowTests); 43 | 44 | // Scene Method Definitions 45 | bool Scene::Intersect(const Ray &ray, SurfaceInteraction *isect) const { 46 | ++nIntersectionTests; 47 | DCHECK_NE(ray.d, Vector3f(0,0,0)); 48 | return aggregate->Intersect(ray, isect); 49 | } 50 | 51 | bool Scene::IntersectP(const Ray &ray) const { 52 | ++nShadowTests; 53 | DCHECK_NE(ray.d, Vector3f(0,0,0)); 54 | return aggregate->IntersectP(ray); 55 | } 56 | 57 | bool Scene::IntersectTr(Ray ray, Sampler &sampler, SurfaceInteraction *isect, 58 | Spectrum *Tr) const { 59 | *Tr = Spectrum(1.f); 60 | while (true) { 61 | bool hitSurface = Intersect(ray, isect); 62 | // Accumulate beam transmittance for ray segment 63 | if (ray.medium) *Tr *= ray.medium->Tr(ray, sampler); 64 | 65 | // Initialize next ray segment or terminate transmittance computation 66 | if (!hitSurface) return false; 67 | if (isect->primitive->GetMaterial() != nullptr) return true; 68 | ray = isect->SpawnRay(ray.d); 69 | } 70 | } 71 | 72 | } // namespace pbrt 73 | -------------------------------------------------------------------------------- /src/core/sobolmatrices.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_CORE_SOBOLMATRICES_H 39 | #define PBRT_CORE_SOBOLMATRICES_H 40 | 41 | // core/sobolmatrices.h* 42 | #include "pbrt.h" 43 | 44 | namespace pbrt { 45 | 46 | // Sobol Matrix Declarations 47 | static PBRT_CONSTEXPR int NumSobolDimensions = 1024; 48 | static PBRT_CONSTEXPR int SobolMatrixSize = 52; 49 | extern const uint32_t SobolMatrices32[NumSobolDimensions * SobolMatrixSize]; 50 | extern const uint64_t SobolMatrices64[NumSobolDimensions * SobolMatrixSize]; 51 | extern const uint64_t VdCSobolMatrices[][SobolMatrixSize]; 52 | extern const uint64_t VdCSobolMatricesInv[][SobolMatrixSize]; 53 | 54 | } // namespace pbrt 55 | 56 | #endif // PBRT_CORE_SOBOLMATRICES_H 57 | -------------------------------------------------------------------------------- /src/filters/box.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // filters/box.cpp* 35 | #include "filters/box.h" 36 | #include "paramset.h" 37 | 38 | namespace pbrt { 39 | 40 | // Box Filter Method Definitions 41 | Float BoxFilter::Evaluate(const Point2f &p) const { return 1.; } 42 | 43 | BoxFilter *CreateBoxFilter(const ParamSet &ps) { 44 | Float xw = ps.FindOneFloat("xwidth", 0.5f); 45 | Float yw = ps.FindOneFloat("ywidth", 0.5f); 46 | return new BoxFilter(Vector2f(xw, yw)); 47 | } 48 | 49 | } // namespace pbrt 50 | -------------------------------------------------------------------------------- /src/filters/box.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_FILTERS_BOX_H 39 | #define PBRT_FILTERS_BOX_H 40 | 41 | // filters/box.h* 42 | #include "filter.h" 43 | 44 | namespace pbrt { 45 | 46 | // Box Filter Declarations 47 | class BoxFilter : public Filter { 48 | public: 49 | BoxFilter(const Vector2f &radius) : Filter(radius) {} 50 | Float Evaluate(const Point2f &p) const; 51 | }; 52 | 53 | BoxFilter *CreateBoxFilter(const ParamSet &ps); 54 | 55 | } // namespace pbrt 56 | 57 | #endif // PBRT_FILTERS_BOX_H 58 | -------------------------------------------------------------------------------- /src/filters/gaussian.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // filters/gaussian.cpp* 35 | #include "filters/gaussian.h" 36 | #include "paramset.h" 37 | 38 | namespace pbrt { 39 | 40 | // Gaussian Filter Method Definitions 41 | Float GaussianFilter::Evaluate(const Point2f &p) const { 42 | return Gaussian(p.x, expX) * Gaussian(p.y, expY); 43 | } 44 | 45 | GaussianFilter *CreateGaussianFilter(const ParamSet &ps) { 46 | // Find common filter parameters 47 | Float xw = ps.FindOneFloat("xwidth", 2.f); 48 | Float yw = ps.FindOneFloat("ywidth", 2.f); 49 | Float alpha = ps.FindOneFloat("alpha", 2.f); 50 | return new GaussianFilter(Vector2f(xw, yw), alpha); 51 | } 52 | 53 | } // namespace pbrt 54 | -------------------------------------------------------------------------------- /src/filters/gaussian.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_FILTERS_GAUSSIAN_H 39 | #define PBRT_FILTERS_GAUSSIAN_H 40 | 41 | // filters/gaussian.h* 42 | #include "filter.h" 43 | 44 | namespace pbrt { 45 | 46 | // Gaussian Filter Declarations 47 | class GaussianFilter : public Filter { 48 | public: 49 | // GaussianFilter Public Methods 50 | GaussianFilter(const Vector2f &radius, Float alpha) 51 | : Filter(radius), 52 | alpha(alpha), 53 | expX(std::exp(-alpha * radius.x * radius.x)), 54 | expY(std::exp(-alpha * radius.y * radius.y)) {} 55 | Float Evaluate(const Point2f &p) const; 56 | 57 | private: 58 | // GaussianFilter Private Data 59 | const Float alpha; 60 | const Float expX, expY; 61 | 62 | // GaussianFilter Utility Functions 63 | Float Gaussian(Float d, Float expv) const { 64 | return std::max((Float)0, Float(std::exp(-alpha * d * d) - expv)); 65 | } 66 | }; 67 | 68 | GaussianFilter *CreateGaussianFilter(const ParamSet &ps); 69 | 70 | } // namespace pbrt 71 | 72 | #endif // PBRT_FILTERS_GAUSSIAN_H 73 | -------------------------------------------------------------------------------- /src/filters/mitchell.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // filters/mitchell.cpp* 35 | #include "filters/mitchell.h" 36 | #include "paramset.h" 37 | 38 | namespace pbrt { 39 | 40 | // Mitchell Filter Method Definitions 41 | Float MitchellFilter::Evaluate(const Point2f &p) const { 42 | return Mitchell1D(p.x * invRadius.x) * Mitchell1D(p.y * invRadius.y); 43 | } 44 | 45 | MitchellFilter *CreateMitchellFilter(const ParamSet &ps) { 46 | // Find common filter parameters 47 | Float xw = ps.FindOneFloat("xwidth", 2.f); 48 | Float yw = ps.FindOneFloat("ywidth", 2.f); 49 | Float B = ps.FindOneFloat("B", 1.f / 3.f); 50 | Float C = ps.FindOneFloat("C", 1.f / 3.f); 51 | return new MitchellFilter(Vector2f(xw, yw), B, C); 52 | } 53 | 54 | } // namespace pbrt 55 | -------------------------------------------------------------------------------- /src/filters/mitchell.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_FILTERS_MITCHELL_H 39 | #define PBRT_FILTERS_MITCHELL_H 40 | 41 | // filters/mitchell.h* 42 | #include "filter.h" 43 | 44 | namespace pbrt { 45 | 46 | // Mitchell Filter Declarations 47 | class MitchellFilter : public Filter { 48 | public: 49 | // MitchellFilter Public Methods 50 | MitchellFilter(const Vector2f &radius, Float B, Float C) 51 | : Filter(radius), B(B), C(C) {} 52 | Float Evaluate(const Point2f &p) const; 53 | Float Mitchell1D(Float x) const { 54 | x = std::abs(2 * x); 55 | if (x > 1) 56 | return ((-B - 6 * C) * x * x * x + (6 * B + 30 * C) * x * x + 57 | (-12 * B - 48 * C) * x + (8 * B + 24 * C)) * 58 | (1.f / 6.f); 59 | else 60 | return ((12 - 9 * B - 6 * C) * x * x * x + 61 | (-18 + 12 * B + 6 * C) * x * x + (6 - 2 * B)) * 62 | (1.f / 6.f); 63 | } 64 | 65 | private: 66 | const Float B, C; 67 | }; 68 | 69 | MitchellFilter *CreateMitchellFilter(const ParamSet &ps); 70 | 71 | } // namespace pbrt 72 | 73 | #endif // PBRT_FILTERS_MITCHELL_H 74 | -------------------------------------------------------------------------------- /src/filters/sinc.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // filters/sinc.cpp* 35 | #include "filters/sinc.h" 36 | #include "paramset.h" 37 | 38 | namespace pbrt { 39 | 40 | // Sinc Filter Method Definitions 41 | Float LanczosSincFilter::Evaluate(const Point2f &p) const { 42 | return WindowedSinc(p.x, radius.x) * WindowedSinc(p.y, radius.y); 43 | } 44 | 45 | LanczosSincFilter *CreateSincFilter(const ParamSet &ps) { 46 | Float xw = ps.FindOneFloat("xwidth", 4.); 47 | Float yw = ps.FindOneFloat("ywidth", 4.); 48 | Float tau = ps.FindOneFloat("tau", 3.f); 49 | return new LanczosSincFilter(Vector2f(xw, yw), tau); 50 | } 51 | 52 | } // namespace pbrt 53 | -------------------------------------------------------------------------------- /src/filters/sinc.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_FILTERS_SINC_H 39 | #define PBRT_FILTERS_SINC_H 40 | 41 | // filters/sinc.h* 42 | #include "filter.h" 43 | 44 | namespace pbrt { 45 | 46 | // Sinc Filter Declarations 47 | class LanczosSincFilter : public Filter { 48 | public: 49 | // LanczosSincFilter Public Methods 50 | LanczosSincFilter(const Vector2f &radius, Float tau) 51 | : Filter(radius), tau(tau) {} 52 | Float Evaluate(const Point2f &p) const; 53 | Float Sinc(Float x) const { 54 | x = std::abs(x); 55 | if (x < 1e-5) return 1; 56 | return std::sin(Pi * x) / (Pi * x); 57 | } 58 | Float WindowedSinc(Float x, Float radius) const { 59 | x = std::abs(x); 60 | if (x > radius) return 0; 61 | Float lanczos = Sinc(x / tau); 62 | return Sinc(x) * lanczos; 63 | } 64 | 65 | private: 66 | const Float tau; 67 | }; 68 | 69 | LanczosSincFilter *CreateSincFilter(const ParamSet &ps); 70 | 71 | } // namespace pbrt 72 | 73 | #endif // PBRT_FILTERS_SINC_H 74 | -------------------------------------------------------------------------------- /src/filters/triangle.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // filters/triangle.cpp* 35 | #include "filters/triangle.h" 36 | #include "paramset.h" 37 | 38 | namespace pbrt { 39 | 40 | // Triangle Filter Method Definitions 41 | Float TriangleFilter::Evaluate(const Point2f &p) const { 42 | return std::max((Float)0, radius.x - std::abs(p.x)) * 43 | std::max((Float)0, radius.y - std::abs(p.y)); 44 | } 45 | 46 | TriangleFilter *CreateTriangleFilter(const ParamSet &ps) { 47 | // Find common filter parameters 48 | Float xw = ps.FindOneFloat("xwidth", 2.f); 49 | Float yw = ps.FindOneFloat("ywidth", 2.f); 50 | return new TriangleFilter(Vector2f(xw, yw)); 51 | } 52 | 53 | } // namespace pbrt 54 | -------------------------------------------------------------------------------- /src/filters/triangle.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_FILTERS_TRIANGLE_H 39 | #define PBRT_FILTERS_TRIANGLE_H 40 | 41 | // filters/triangle.h* 42 | #include "filter.h" 43 | 44 | namespace pbrt { 45 | 46 | // Triangle Filter Declarations 47 | class TriangleFilter : public Filter { 48 | public: 49 | TriangleFilter(const Vector2f &radius) : Filter(radius) {} 50 | Float Evaluate(const Point2f &p) const; 51 | }; 52 | 53 | TriangleFilter *CreateTriangleFilter(const ParamSet &ps); 54 | 55 | } // namespace pbrt 56 | 57 | #endif // PBRT_FILTERS_TRIANGLE_H 58 | -------------------------------------------------------------------------------- /src/integrators/ao.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_INTEGRATORS_AO_H 39 | #define PBRT_INTEGRATORS_AO_H 40 | 41 | // integrators/ao.h* 42 | #include "pbrt.h" 43 | #include "integrator.h" 44 | 45 | namespace pbrt { 46 | 47 | // AOIntegrator Declarations 48 | class AOIntegrator : public SamplerIntegrator { 49 | public: 50 | // AOIntegrator Public Methods 51 | AOIntegrator(bool cosSample, int nSamples, 52 | std::shared_ptr camera, 53 | std::shared_ptr sampler, 54 | const Bounds2i &pixelBounds); 55 | Spectrum Li(const RayDifferential &ray, const Scene &scene, 56 | Sampler &sampler, MemoryArena &arena, int depth) const; 57 | private: 58 | bool cosSample; 59 | int nSamples; 60 | }; 61 | 62 | AOIntegrator *CreateAOIntegrator(const ParamSet ¶ms, 63 | std::shared_ptr sampler, 64 | std::shared_ptr camera); 65 | 66 | } // namespace pbrt 67 | 68 | #endif // PBRT_INTEGRATORS_PATH_H 69 | -------------------------------------------------------------------------------- /src/integrators/path.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_INTEGRATORS_PATH_H 39 | #define PBRT_INTEGRATORS_PATH_H 40 | 41 | // integrators/path.h* 42 | #include "pbrt.h" 43 | #include "integrator.h" 44 | #include "lightdistrib.h" 45 | 46 | namespace pbrt { 47 | 48 | // PathIntegrator Declarations 49 | class PathIntegrator : public SamplerIntegrator { 50 | public: 51 | // PathIntegrator Public Methods 52 | PathIntegrator(int maxDepth, std::shared_ptr camera, 53 | std::shared_ptr sampler, 54 | const Bounds2i &pixelBounds, Float rrThreshold = 1, 55 | const std::string &lightSampleStrategy = "spatial"); 56 | 57 | void Preprocess(const Scene &scene, Sampler &sampler); 58 | Spectrum Li(const RayDifferential &ray, const Scene &scene, 59 | Sampler &sampler, MemoryArena &arena, int depth) const; 60 | 61 | private: 62 | // PathIntegrator Private Data 63 | const int maxDepth; 64 | const Float rrThreshold; 65 | const std::string lightSampleStrategy; 66 | std::unique_ptr lightDistribution; 67 | }; 68 | 69 | PathIntegrator *CreatePathIntegrator(const ParamSet ¶ms, 70 | std::shared_ptr sampler, 71 | std::shared_ptr camera); 72 | 73 | } // namespace pbrt 74 | 75 | #endif // PBRT_INTEGRATORS_PATH_H 76 | -------------------------------------------------------------------------------- /src/integrators/whitted.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_INTEGRATORS_WHITTED_H 39 | #define PBRT_INTEGRATORS_WHITTED_H 40 | 41 | // integrators/whitted.h* 42 | #include "pbrt.h" 43 | #include "integrator.h" 44 | #include "scene.h" 45 | 46 | namespace pbrt { 47 | 48 | // WhittedIntegrator Declarations 49 | class WhittedIntegrator : public SamplerIntegrator { 50 | public: 51 | // WhittedIntegrator Public Methods 52 | WhittedIntegrator(int maxDepth, std::shared_ptr camera, 53 | std::shared_ptr sampler, 54 | const Bounds2i &pixelBounds) 55 | : SamplerIntegrator(camera, sampler, pixelBounds), maxDepth(maxDepth) {} 56 | Spectrum Li(const RayDifferential &ray, const Scene &scene, 57 | Sampler &sampler, MemoryArena &arena, int depth) const; 58 | 59 | private: 60 | // WhittedIntegrator Private Data 61 | const int maxDepth; 62 | }; 63 | 64 | WhittedIntegrator *CreateWhittedIntegrator( 65 | const ParamSet ¶ms, std::shared_ptr sampler, 66 | std::shared_ptr camera); 67 | 68 | } // namespace pbrt 69 | 70 | #endif // PBRT_INTEGRATORS_WHITTED_H 71 | -------------------------------------------------------------------------------- /src/lights/spot.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_LIGHTS_SPOT_H 39 | #define PBRT_LIGHTS_SPOT_H 40 | 41 | // lights/spot.h* 42 | #include "pbrt.h" 43 | #include "light.h" 44 | #include "shape.h" 45 | 46 | namespace pbrt { 47 | 48 | // SpotLight Declarations 49 | class SpotLight : public Light { 50 | public: 51 | // SpotLight Public Methods 52 | SpotLight(const Transform &LightToWorld, const MediumInterface &m, 53 | const Spectrum &I, Float totalWidth, Float falloffStart); 54 | Spectrum Sample_Li(const Interaction &ref, const Point2f &u, Vector3f *wi, 55 | Float *pdf, VisibilityTester *vis) const; 56 | Float Falloff(const Vector3f &w) const; 57 | Spectrum Power() const; 58 | Float Pdf_Li(const Interaction &, const Vector3f &) const; 59 | Spectrum Sample_Le(const Point2f &u1, const Point2f &u2, Float time, 60 | Ray *ray, Normal3f *nLight, Float *pdfPos, 61 | Float *pdfDir) const; 62 | void Pdf_Le(const Ray &, const Normal3f &, Float *pdfPos, 63 | Float *pdfDir) const; 64 | 65 | private: 66 | // SpotLight Private Data 67 | const Point3f pLight; 68 | const Spectrum I; 69 | const Float cosTotalWidth, cosFalloffStart; 70 | }; 71 | 72 | std::shared_ptr CreateSpotLight(const Transform &l2w, 73 | const Medium *medium, 74 | const ParamSet ¶mSet); 75 | 76 | } // namespace pbrt 77 | 78 | #endif // PBRT_LIGHTS_SPOT_H 79 | -------------------------------------------------------------------------------- /src/materials/fourier.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_MATERIALS_FOURIER_H 39 | #define PBRT_MATERIALS_FOURIER_H 40 | 41 | // materials/fourier.h* 42 | #include "pbrt.h" 43 | #include "material.h" 44 | #include "reflection.h" 45 | #include "interpolation.h" 46 | #include 47 | 48 | namespace pbrt { 49 | 50 | // FourierMaterial Declarations 51 | class FourierMaterial : public Material { 52 | public: 53 | // FourierMaterial Public Methods 54 | FourierMaterial(const std::string &filename, 55 | const std::shared_ptr> &bump); 56 | void ComputeScatteringFunctions(SurfaceInteraction *si, MemoryArena &arena, 57 | TransportMode mode, 58 | bool allowMultipleLobes) const; 59 | 60 | private: 61 | // FourierMaterial Private Data 62 | FourierBSDFTable *bsdfTable; 63 | std::shared_ptr> bumpMap; 64 | static std::map> loadedBSDFs; 65 | }; 66 | 67 | FourierMaterial *CreateFourierMaterial(const TextureParams &mp); 68 | 69 | } // namespace pbrt 70 | 71 | #endif // PBRT_MATERIALS_FOURIER_H 72 | -------------------------------------------------------------------------------- /src/materials/matte.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // materials/matte.cpp* 35 | #include "materials/matte.h" 36 | #include "paramset.h" 37 | #include "reflection.h" 38 | #include "interaction.h" 39 | #include "texture.h" 40 | #include "interaction.h" 41 | 42 | namespace pbrt { 43 | 44 | // MatteMaterial Method Definitions 45 | void MatteMaterial::ComputeScatteringFunctions(SurfaceInteraction *si, 46 | MemoryArena &arena, 47 | TransportMode mode, 48 | bool allowMultipleLobes) const { 49 | // Perform bump mapping with _bumpMap_, if present 50 | if (bumpMap) Bump(bumpMap, si); 51 | 52 | // Evaluate textures for _MatteMaterial_ material and allocate BRDF 53 | si->bsdf = ARENA_ALLOC(arena, BSDF)(*si); 54 | Spectrum r = Kd->Evaluate(*si).Clamp(); 55 | Float sig = Clamp(sigma->Evaluate(*si), 0, 90); 56 | if (!r.IsBlack()) { 57 | if (sig == 0) 58 | si->bsdf->Add(ARENA_ALLOC(arena, LambertianReflection)(r)); 59 | else 60 | si->bsdf->Add(ARENA_ALLOC(arena, OrenNayar)(r, sig)); 61 | } 62 | } 63 | 64 | MatteMaterial *CreateMatteMaterial(const TextureParams &mp) { 65 | std::shared_ptr> Kd = 66 | mp.GetSpectrumTexture("Kd", Spectrum(0.5f)); 67 | std::shared_ptr> sigma = mp.GetFloatTexture("sigma", 0.f); 68 | std::shared_ptr> bumpMap = 69 | mp.GetFloatTextureOrNull("bumpmap"); 70 | return new MatteMaterial(Kd, sigma, bumpMap); 71 | } 72 | 73 | } // namespace pbrt 74 | -------------------------------------------------------------------------------- /src/materials/matte.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_MATERIALS_MATTE_H 39 | #define PBRT_MATERIALS_MATTE_H 40 | 41 | // materials/matte.h* 42 | #include "pbrt.h" 43 | #include "material.h" 44 | 45 | namespace pbrt { 46 | 47 | // MatteMaterial Declarations 48 | class MatteMaterial : public Material { 49 | public: 50 | // MatteMaterial Public Methods 51 | MatteMaterial(const std::shared_ptr> &Kd, 52 | const std::shared_ptr> &sigma, 53 | const std::shared_ptr> &bumpMap) 54 | : Kd(Kd), sigma(sigma), bumpMap(bumpMap) {} 55 | void ComputeScatteringFunctions(SurfaceInteraction *si, MemoryArena &arena, 56 | TransportMode mode, 57 | bool allowMultipleLobes) const; 58 | 59 | private: 60 | // MatteMaterial Private Data 61 | std::shared_ptr> Kd; 62 | std::shared_ptr> sigma, bumpMap; 63 | }; 64 | 65 | MatteMaterial *CreateMatteMaterial(const TextureParams &mp); 66 | 67 | } // namespace pbrt 68 | 69 | #endif // PBRT_MATERIALS_MATTE_H 70 | -------------------------------------------------------------------------------- /src/materials/metal.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_MATERIALS_METAL_H 39 | #define PBRT_MATERIALS_METAL_H 40 | 41 | // materials/metal.h* 42 | #include "pbrt.h" 43 | #include "material.h" 44 | #include "spectrum.h" 45 | 46 | namespace pbrt { 47 | 48 | // MetalMaterial Declarations 49 | class MetalMaterial : public Material { 50 | public: 51 | // MetalMaterial Public Methods 52 | MetalMaterial(const std::shared_ptr> &eta, 53 | const std::shared_ptr> &k, 54 | const std::shared_ptr> &rough, 55 | const std::shared_ptr> &urough, 56 | const std::shared_ptr> &vrough, 57 | const std::shared_ptr> &bump, 58 | bool remapRoughness); 59 | void ComputeScatteringFunctions(SurfaceInteraction *si, MemoryArena &arena, 60 | TransportMode mode, 61 | bool allowMultipleLobes) const; 62 | 63 | private: 64 | // MetalMaterial Private Data 65 | std::shared_ptr> eta, k; 66 | std::shared_ptr> roughness, uRoughness, vRoughness; 67 | std::shared_ptr> bumpMap; 68 | bool remapRoughness; 69 | }; 70 | 71 | MetalMaterial *CreateMetalMaterial(const TextureParams &mp); 72 | 73 | } // namespace pbrt 74 | 75 | #endif // PBRT_MATERIALS_METAL_H 76 | -------------------------------------------------------------------------------- /src/materials/mirror.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // materials/mirror.cpp* 35 | #include "materials/mirror.h" 36 | #include "spectrum.h" 37 | #include "reflection.h" 38 | #include "paramset.h" 39 | #include "texture.h" 40 | #include "interaction.h" 41 | 42 | namespace pbrt { 43 | 44 | // MirrorMaterial Method Definitions 45 | void MirrorMaterial::ComputeScatteringFunctions(SurfaceInteraction *si, 46 | MemoryArena &arena, 47 | TransportMode mode, 48 | bool allowMultipleLobes) const { 49 | // Perform bump mapping with _bumpMap_, if present 50 | if (bumpMap) Bump(bumpMap, si); 51 | si->bsdf = ARENA_ALLOC(arena, BSDF)(*si); 52 | Spectrum R = Kr->Evaluate(*si).Clamp(); 53 | if (!R.IsBlack()) 54 | si->bsdf->Add(ARENA_ALLOC(arena, SpecularReflection)( 55 | R, ARENA_ALLOC(arena, FresnelNoOp)())); 56 | } 57 | 58 | MirrorMaterial *CreateMirrorMaterial(const TextureParams &mp) { 59 | std::shared_ptr> Kr = 60 | mp.GetSpectrumTexture("Kr", Spectrum(0.9f)); 61 | std::shared_ptr> bumpMap = 62 | mp.GetFloatTextureOrNull("bumpmap"); 63 | return new MirrorMaterial(Kr, bumpMap); 64 | } 65 | 66 | } // namespace pbrt 67 | -------------------------------------------------------------------------------- /src/materials/mirror.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_MATERIALS_MIRROR_H 39 | #define PBRT_MATERIALS_MIRROR_H 40 | 41 | // materials/mirror.h* 42 | #include "pbrt.h" 43 | #include "material.h" 44 | 45 | namespace pbrt { 46 | 47 | // MirrorMaterial Declarations 48 | class MirrorMaterial : public Material { 49 | public: 50 | // MirrorMaterial Public Methods 51 | MirrorMaterial(const std::shared_ptr> &r, 52 | const std::shared_ptr> &bump) { 53 | Kr = r; 54 | bumpMap = bump; 55 | } 56 | void ComputeScatteringFunctions(SurfaceInteraction *si, MemoryArena &arena, 57 | TransportMode mode, 58 | bool allowMultipleLobes) const; 59 | 60 | private: 61 | // MirrorMaterial Private Data 62 | std::shared_ptr> Kr; 63 | std::shared_ptr> bumpMap; 64 | }; 65 | 66 | MirrorMaterial *CreateMirrorMaterial(const TextureParams &mp); 67 | 68 | } // namespace pbrt 69 | 70 | #endif // PBRT_MATERIALS_MIRROR_H 71 | -------------------------------------------------------------------------------- /src/materials/mixmat.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_MATERIALS_MIXMAT_H 39 | #define PBRT_MATERIALS_MIXMAT_H 40 | 41 | // materials/mixmat.h* 42 | #include "pbrt.h" 43 | #include "material.h" 44 | 45 | namespace pbrt { 46 | 47 | // MixMaterial Declarations 48 | class MixMaterial : public Material { 49 | public: 50 | // MixMaterial Public Methods 51 | MixMaterial(const std::shared_ptr &m1, 52 | const std::shared_ptr &m2, 53 | const std::shared_ptr> &scale) 54 | : m1(m1), m2(m2), scale(scale) {} 55 | void ComputeScatteringFunctions(SurfaceInteraction *si, MemoryArena &arena, 56 | TransportMode mode, 57 | bool allowMultipleLobes) const; 58 | 59 | private: 60 | // MixMaterial Private Data 61 | std::shared_ptr m1, m2; 62 | std::shared_ptr> scale; 63 | }; 64 | 65 | MixMaterial *CreateMixMaterial(const TextureParams &mp, 66 | const std::shared_ptr &m1, 67 | const std::shared_ptr &m2); 68 | 69 | } // namespace pbrt 70 | 71 | #endif // PBRT_MATERIALS_MIXMAT_H 72 | -------------------------------------------------------------------------------- /src/materials/plastic.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_MATERIALS_PLASTIC_H 39 | #define PBRT_MATERIALS_PLASTIC_H 40 | 41 | // materials/plastic.h* 42 | #include "pbrt.h" 43 | #include "material.h" 44 | 45 | namespace pbrt { 46 | 47 | // PlasticMaterial Declarations 48 | class PlasticMaterial : public Material { 49 | public: 50 | // PlasticMaterial Public Methods 51 | PlasticMaterial(const std::shared_ptr> &Kd, 52 | const std::shared_ptr> &Ks, 53 | const std::shared_ptr> &roughness, 54 | const std::shared_ptr> &bumpMap, 55 | bool remapRoughness) 56 | : Kd(Kd), 57 | Ks(Ks), 58 | roughness(roughness), 59 | bumpMap(bumpMap), 60 | remapRoughness(remapRoughness) {} 61 | void ComputeScatteringFunctions(SurfaceInteraction *si, MemoryArena &arena, 62 | TransportMode mode, 63 | bool allowMultipleLobes) const; 64 | 65 | private: 66 | // PlasticMaterial Private Data 67 | std::shared_ptr> Kd, Ks; 68 | std::shared_ptr> roughness, bumpMap; 69 | const bool remapRoughness; 70 | }; 71 | 72 | PlasticMaterial *CreatePlasticMaterial(const TextureParams &mp); 73 | 74 | } // namespace pbrt 75 | 76 | #endif // PBRT_MATERIALS_PLASTIC_H 77 | -------------------------------------------------------------------------------- /src/materials/sparkling.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xavierchermain/pbrt-v3-procedural-glint/0e9fc8c91ba43a71f79a7d842b8e7027cbef3b88/src/materials/sparkling.cpp -------------------------------------------------------------------------------- /src/materials/sparkling.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xavierchermain/pbrt-v3-procedural-glint/0e9fc8c91ba43a71f79a7d842b8e7027cbef3b88/src/materials/sparkling.h -------------------------------------------------------------------------------- /src/media/homogeneous.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_MEDIA_HOMOGENEOUS_H 39 | #define PBRT_MEDIA_HOMOGENEOUS_H 40 | 41 | // media/homogeneous.h* 42 | #include "medium.h" 43 | 44 | namespace pbrt { 45 | 46 | // HomogeneousMedium Declarations 47 | class HomogeneousMedium : public Medium { 48 | public: 49 | // HomogeneousMedium Public Methods 50 | HomogeneousMedium(const Spectrum &sigma_a, const Spectrum &sigma_s, Float g) 51 | : sigma_a(sigma_a), 52 | sigma_s(sigma_s), 53 | sigma_t(sigma_s + sigma_a), 54 | g(g) {} 55 | Spectrum Tr(const Ray &ray, Sampler &sampler) const; 56 | Spectrum Sample(const Ray &ray, Sampler &sampler, MemoryArena &arena, 57 | MediumInteraction *mi) const; 58 | 59 | private: 60 | // HomogeneousMedium Private Data 61 | const Spectrum sigma_a, sigma_s, sigma_t; 62 | const Float g; 63 | }; 64 | 65 | } // namespace pbrt 66 | 67 | #endif // PBRT_MEDIA_HOMOGENEOUS_H 68 | -------------------------------------------------------------------------------- /src/samplers/random.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // samplers/random.cpp* 35 | #include "samplers/random.h" 36 | #include "paramset.h" 37 | #include "sampling.h" 38 | #include "stats.h" 39 | 40 | namespace pbrt { 41 | 42 | RandomSampler::RandomSampler(int ns, int seed) : Sampler(ns), rng(seed) {} 43 | 44 | Float RandomSampler::Get1D() { 45 | ProfilePhase _(Prof::GetSample); 46 | CHECK_LT(currentPixelSampleIndex, samplesPerPixel); 47 | return rng.UniformFloat(); 48 | } 49 | 50 | Point2f RandomSampler::Get2D() { 51 | ProfilePhase _(Prof::GetSample); 52 | CHECK_LT(currentPixelSampleIndex, samplesPerPixel); 53 | return {rng.UniformFloat(), rng.UniformFloat()}; 54 | } 55 | 56 | std::unique_ptr RandomSampler::Clone(int seed) { 57 | RandomSampler *rs = new RandomSampler(*this); 58 | rs->rng.SetSequence(seed); 59 | return std::unique_ptr(rs); 60 | } 61 | 62 | void RandomSampler::StartPixel(const Point2i &p) { 63 | ProfilePhase _(Prof::StartPixel); 64 | for (size_t i = 0; i < sampleArray1D.size(); ++i) 65 | for (size_t j = 0; j < sampleArray1D[i].size(); ++j) 66 | sampleArray1D[i][j] = rng.UniformFloat(); 67 | 68 | for (size_t i = 0; i < sampleArray2D.size(); ++i) 69 | for (size_t j = 0; j < sampleArray2D[i].size(); ++j) 70 | sampleArray2D[i][j] = {rng.UniformFloat(), rng.UniformFloat()}; 71 | Sampler::StartPixel(p); 72 | } 73 | 74 | Sampler *CreateRandomSampler(const ParamSet ¶ms) { 75 | int ns = params.FindOneInt("pixelsamples", 4); 76 | return new RandomSampler(ns); 77 | } 78 | 79 | } // namespace pbrt 80 | -------------------------------------------------------------------------------- /src/samplers/random.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SAMPLERS_RANDOM_H 39 | #define PBRT_SAMPLERS_RANDOM_H 40 | 41 | // samplers/random.h* 42 | #include "sampler.h" 43 | #include "rng.h" 44 | 45 | namespace pbrt { 46 | 47 | class RandomSampler : public Sampler { 48 | public: 49 | RandomSampler(int ns, int seed = 0); 50 | void StartPixel(const Point2i &); 51 | Float Get1D(); 52 | Point2f Get2D(); 53 | std::unique_ptr Clone(int seed); 54 | 55 | private: 56 | RNG rng; 57 | }; 58 | 59 | Sampler *CreateRandomSampler(const ParamSet ¶ms); 60 | 61 | } // namespace pbrt 62 | 63 | #endif // PBRT_SAMPLERS_RANDOM_H 64 | -------------------------------------------------------------------------------- /src/samplers/sobol.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // samplers/sobol.cpp* 35 | #include "samplers/sobol.h" 36 | #include "lowdiscrepancy.h" 37 | #include "paramset.h" 38 | 39 | namespace pbrt { 40 | 41 | // SobolSampler Method Definitions 42 | int64_t SobolSampler::GetIndexForSample(int64_t sampleNum) const { 43 | return SobolIntervalToIndex(log2Resolution, sampleNum, 44 | Point2i(currentPixel - sampleBounds.pMin)); 45 | } 46 | 47 | Float SobolSampler::SampleDimension(int64_t index, int dim) const { 48 | if (dim >= NumSobolDimensions) 49 | LOG(FATAL) << StringPrintf("SobolSampler can only sample up to %d " 50 | "dimensions! Exiting.", 51 | NumSobolDimensions); 52 | Float s = SobolSample(index, dim); 53 | // Remap Sobol$'$ dimensions used for pixel samples 54 | if (dim == 0 || dim == 1) { 55 | s = s * resolution + sampleBounds.pMin[dim]; 56 | s = Clamp(s - currentPixel[dim], (Float)0, OneMinusEpsilon); 57 | } 58 | return s; 59 | } 60 | 61 | std::unique_ptr SobolSampler::Clone(int seed) { 62 | return std::unique_ptr(new SobolSampler(*this)); 63 | } 64 | 65 | SobolSampler *CreateSobolSampler(const ParamSet ¶ms, 66 | const Bounds2i &sampleBounds) { 67 | int nsamp = params.FindOneInt("pixelsamples", 16); 68 | if (PbrtOptions.quickRender) nsamp = 1; 69 | return new SobolSampler(nsamp, sampleBounds); 70 | } 71 | 72 | } // namespace pbrt 73 | -------------------------------------------------------------------------------- /src/samplers/sobol.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SAMPLERS_SOBOL_H 39 | #define PBRT_SAMPLERS_SOBOL_H 40 | 41 | // samplers/sobol.h* 42 | #include "sampler.h" 43 | 44 | namespace pbrt { 45 | 46 | // SobolSampler Declarations 47 | class SobolSampler : public GlobalSampler { 48 | public: 49 | // SobolSampler Public Methods 50 | std::unique_ptr Clone(int seed); 51 | SobolSampler(int64_t samplesPerPixel, const Bounds2i &sampleBounds) 52 | : GlobalSampler(RoundUpPow2(samplesPerPixel)), 53 | sampleBounds(sampleBounds) { 54 | if (!IsPowerOf2(samplesPerPixel)) 55 | Warning("Non power-of-two sample count rounded up to %" PRId64 56 | " for SobolSampler.", 57 | this->samplesPerPixel); 58 | resolution = RoundUpPow2( 59 | std::max(sampleBounds.Diagonal().x, sampleBounds.Diagonal().y)); 60 | log2Resolution = Log2Int(resolution); 61 | if (resolution > 0) CHECK_EQ(1 << log2Resolution, resolution); 62 | } 63 | int64_t GetIndexForSample(int64_t sampleNum) const; 64 | Float SampleDimension(int64_t index, int dimension) const; 65 | 66 | private: 67 | // SobolSampler Private Data 68 | const Bounds2i sampleBounds; 69 | int resolution, log2Resolution; 70 | }; 71 | 72 | SobolSampler *CreateSobolSampler(const ParamSet ¶ms, 73 | const Bounds2i &sampleBounds); 74 | 75 | } // namespace pbrt 76 | 77 | #endif // PBRT_SAMPLERS_SOBOL_H 78 | -------------------------------------------------------------------------------- /src/samplers/stratified.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SAMPLERS_STRATIFIED_H 39 | #define PBRT_SAMPLERS_STRATIFIED_H 40 | 41 | // samplers/stratified.h* 42 | #include "sampler.h" 43 | #include "rng.h" 44 | 45 | namespace pbrt { 46 | 47 | // StratifiedSampler Declarations 48 | class StratifiedSampler : public PixelSampler { 49 | public: 50 | // StratifiedSampler Public Methods 51 | StratifiedSampler(int xPixelSamples, int yPixelSamples, bool jitterSamples, 52 | int nSampledDimensions) 53 | : PixelSampler(xPixelSamples * yPixelSamples, nSampledDimensions), 54 | xPixelSamples(xPixelSamples), 55 | yPixelSamples(yPixelSamples), 56 | jitterSamples(jitterSamples) {} 57 | void StartPixel(const Point2i &); 58 | std::unique_ptr Clone(int seed); 59 | 60 | private: 61 | // StratifiedSampler Private Data 62 | const int xPixelSamples, yPixelSamples; 63 | const bool jitterSamples; 64 | }; 65 | 66 | StratifiedSampler *CreateStratifiedSampler(const ParamSet ¶ms); 67 | 68 | } // namespace pbrt 69 | 70 | #endif // PBRT_SAMPLERS_STRATIFIED_H 71 | -------------------------------------------------------------------------------- /src/samplers/zerotwosequence.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SAMPLERS_ZEROTWOSEQUENCE_H 39 | #define PBRT_SAMPLERS_ZEROTWOSEQUENCE_H 40 | 41 | // samplers/zerotwosequence.h* 42 | #include "sampler.h" 43 | 44 | namespace pbrt { 45 | 46 | // ZeroTwoSequenceSampler Declarations 47 | class ZeroTwoSequenceSampler : public PixelSampler { 48 | public: 49 | // ZeroTwoSequenceSampler Public Methods 50 | ZeroTwoSequenceSampler(int64_t samplesPerPixel, int nSampledDimensions = 4); 51 | void StartPixel(const Point2i &); 52 | std::unique_ptr Clone(int seed); 53 | int RoundCount(int count) const { return RoundUpPow2(count); } 54 | }; 55 | 56 | ZeroTwoSequenceSampler *CreateZeroTwoSequenceSampler(const ParamSet ¶ms); 57 | 58 | } // namespace pbrt 59 | 60 | #endif // PBRT_SAMPLERS_ZEROTWOSEQUENCE_H 61 | -------------------------------------------------------------------------------- /src/shapes/cone.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SHAPES_CONE_H 39 | #define PBRT_SHAPES_CONE_H 40 | 41 | // shapes/cone.h* 42 | #include "shape.h" 43 | 44 | namespace pbrt { 45 | 46 | // Cone Declarations 47 | class Cone : public Shape { 48 | public: 49 | // Cone Public Methods 50 | Cone(const Transform *o2w, const Transform *w2o, bool reverseOrientation, 51 | Float height, Float radius, Float phiMax); 52 | Bounds3f ObjectBound() const; 53 | bool Intersect(const Ray &ray, Float *tHit, SurfaceInteraction *isect, 54 | bool testAlphaTexture) const; 55 | bool IntersectP(const Ray &ray, bool testAlphaTexture) const; 56 | Float Area() const; 57 | Interaction Sample(const Point2f &u, Float *pdf) const; 58 | 59 | protected: 60 | // Cone Private Data 61 | const Float radius, height, phiMax; 62 | }; 63 | 64 | std::shared_ptr CreateConeShape(const Transform *o2w, 65 | const Transform *w2o, 66 | bool reverseOrientation, 67 | const ParamSet ¶ms); 68 | 69 | } // namespace pbrt 70 | 71 | #endif // PBRT_SHAPES_CONE_H 72 | -------------------------------------------------------------------------------- /src/shapes/disk.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SHAPES_DISK_H 39 | #define PBRT_SHAPES_DISK_H 40 | 41 | // shapes/disk.h* 42 | #include "shape.h" 43 | 44 | namespace pbrt { 45 | 46 | // Disk Declarations 47 | class Disk : public Shape { 48 | public: 49 | // Disk Public Methods 50 | Disk(const Transform *ObjectToWorld, const Transform *WorldToObject, 51 | bool reverseOrientation, Float height, Float radius, Float innerRadius, 52 | Float phiMax) 53 | : Shape(ObjectToWorld, WorldToObject, reverseOrientation), 54 | height(height), 55 | radius(radius), 56 | innerRadius(innerRadius), 57 | phiMax(Radians(Clamp(phiMax, 0, 360))) {} 58 | Bounds3f ObjectBound() const; 59 | bool Intersect(const Ray &ray, Float *tHit, SurfaceInteraction *isect, 60 | bool testAlphaTexture) const; 61 | bool IntersectP(const Ray &ray, bool testAlphaTexture) const; 62 | Float Area() const; 63 | Interaction Sample(const Point2f &u, Float *pdf) const; 64 | 65 | private: 66 | // Disk Private Data 67 | const Float height, radius, innerRadius, phiMax; 68 | }; 69 | 70 | std::shared_ptr CreateDiskShape(const Transform *o2w, 71 | const Transform *w2o, 72 | bool reverseOrientation, 73 | const ParamSet ¶ms); 74 | 75 | } // namespace pbrt 76 | 77 | #endif // PBRT_SHAPES_DISK_H 78 | -------------------------------------------------------------------------------- /src/shapes/heightfield.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SHAPES_HEIGHTFIELD_H 39 | #define PBRT_SHAPES_HEIGHTFIELD_H 40 | 41 | // shapes/heightfield.h* 42 | #include "shape.h" 43 | 44 | namespace pbrt { 45 | 46 | // Heightfield Declarations 47 | std::vector> CreateHeightfield(const Transform *o2w, 48 | const Transform *w2o, 49 | bool ro, 50 | const ParamSet ¶ms); 51 | 52 | } // namespace pbrt 53 | 54 | #endif // PBRT_SHAPES_HEIGHTFIELD_H 55 | -------------------------------------------------------------------------------- /src/shapes/hyperboloid.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SHAPES_HYPERBOLOID_H 39 | #define PBRT_SHAPES_HYPERBOLOID_H 40 | 41 | // shapes/hyperboloid.h* 42 | #include "shape.h" 43 | 44 | namespace pbrt { 45 | 46 | // Hyperboloid Declarations 47 | class Hyperboloid : public Shape { 48 | public: 49 | // Hyperboloid Public Methods 50 | Hyperboloid(const Transform *o2w, const Transform *w2o, bool ro, 51 | const Point3f &point1, const Point3f &point2, Float tm); 52 | Bounds3f ObjectBound() const; 53 | bool Intersect(const Ray &ray, Float *tHit, SurfaceInteraction *isect, 54 | bool testAlphaTexture) const; 55 | bool IntersectP(const Ray &ray, bool testAlphaTexture) const; 56 | Float Area() const; 57 | Interaction Sample(const Point2f &u, Float *pdf) const; 58 | 59 | protected: 60 | // Hyperboloid Private Data 61 | Point3f p1, p2; 62 | Float zMin, zMax; 63 | Float phiMax; 64 | Float rMax; 65 | Float ah, ch; 66 | }; 67 | 68 | std::shared_ptr CreateHyperboloidShape(const Transform *o2w, 69 | const Transform *w2o, 70 | bool reverseOrientation, 71 | const ParamSet ¶ms); 72 | 73 | } // namespace pbrt 74 | 75 | #endif // PBRT_SHAPES_HYPERBOLOID_H 76 | -------------------------------------------------------------------------------- /src/shapes/loopsubdiv.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SHAPES_LOOPSUBDIV_H 39 | #define PBRT_SHAPES_LOOPSUBDIV_H 40 | 41 | // shapes/loopsubdiv.h* 42 | #include "shape.h" 43 | 44 | namespace pbrt { 45 | 46 | // LoopSubdiv Declarations 47 | std::vector> CreateLoopSubdiv(const Transform *o2w, 48 | const Transform *w2o, 49 | bool reverseOrientation, 50 | const ParamSet ¶ms); 51 | 52 | } // namespace pbrt 53 | 54 | #endif // PBRT_SHAPES_LOOPSUBDIV_H 55 | -------------------------------------------------------------------------------- /src/shapes/nurbs.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SHAPES_NURBS_H 39 | #define PBRT_SHAPES_NURBS_H 40 | 41 | // shapes/nurbs.h* 42 | #include "pbrt.h" 43 | #include "shape.h" 44 | #include "geometry.h" 45 | 46 | namespace pbrt { 47 | 48 | std::vector> CreateNURBS(const Transform *o2w, 49 | const Transform *w2o, 50 | bool reverseOrientation, 51 | const ParamSet ¶ms); 52 | 53 | } // namespace pbrt 54 | 55 | #endif // PBRT_SHAPES_NURBS_H 56 | -------------------------------------------------------------------------------- /src/shapes/paraboloid.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SHAPES_PARABOLOID_H 39 | #define PBRT_SHAPES_PARABOLOID_H 40 | 41 | // shapes/paraboloid.h* 42 | #include "shape.h" 43 | 44 | namespace pbrt { 45 | 46 | // Paraboloid Declarations 47 | class Paraboloid : public Shape { 48 | public: 49 | // Paraboloid Public Methods 50 | Paraboloid(const Transform *o2w, const Transform *w2o, 51 | bool reverseOrientation, Float radius, Float z0, Float z1, 52 | Float phiMax); 53 | Bounds3f ObjectBound() const; 54 | bool Intersect(const Ray &ray, Float *tHit, SurfaceInteraction *isect, 55 | bool testAlphaTexture) const; 56 | bool IntersectP(const Ray &ray, bool testAlphaTexture) const; 57 | Float Area() const; 58 | Interaction Sample(const Point2f &u, Float *pdf) const; 59 | 60 | protected: 61 | // Paraboloid Private Data 62 | const Float radius, zMin, zMax, phiMax; 63 | }; 64 | 65 | std::shared_ptr CreateParaboloidShape(const Transform *o2w, 66 | const Transform *w2o, 67 | bool reverseOrientation, 68 | const ParamSet ¶ms); 69 | 70 | } // namespace pbrt 71 | 72 | #endif // PBRT_SHAPES_PARABOLOID_H 73 | -------------------------------------------------------------------------------- /src/shapes/plymesh.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_SHAPES_PLYMESH_H 39 | #define PBRT_SHAPES_PLYMESH_H 40 | 41 | // shapes/plymesh.h* 42 | #include "shapes/triangle.h" 43 | 44 | namespace pbrt { 45 | 46 | std::vector> CreatePLYMesh( 47 | const Transform *o2w, const Transform *w2o, bool reverseOrientation, 48 | const ParamSet ¶ms, 49 | std::map>> *floatTextures = 50 | nullptr); 51 | 52 | } // namespace pbrt 53 | 54 | #endif // PBRT_SHAPES_PLYMESH_H 55 | -------------------------------------------------------------------------------- /src/tests/animatedtransform.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "tests/gtest/gtest.h" 3 | #include "pbrt.h" 4 | #include "rng.h" 5 | #include "sampling.h" 6 | #include "transform.h" 7 | 8 | using namespace pbrt; 9 | 10 | static Transform RandomTransform(RNG &rng) { 11 | Transform t; 12 | auto r = [&rng]() { return -10. + 20. * rng.UniformFloat(); }; 13 | for (int i = 0; i < 10; ++i) { 14 | switch (rng.UniformUInt32(3)) { 15 | case 0: 16 | t = t * Scale(std::abs(r()), std::abs(r()), std::abs(r())); 17 | break; 18 | case 1: 19 | t = t * Translate(Vector3f(r(), r(), r())); 20 | break; 21 | case 2: 22 | t = t * 23 | Rotate(r() * 20., UniformSampleSphere(Point2f( 24 | rng.UniformFloat(), rng.UniformFloat()))); 25 | break; 26 | } 27 | } 28 | return t; 29 | } 30 | 31 | TEST(AnimatedTransform, Randoms) { 32 | RNG rng; 33 | auto r = [&rng]() { return -10. + 20. * rng.UniformFloat(); }; 34 | 35 | for (int i = 0; i < 200; ++i) { 36 | // Generate a pair of random transformation matrices. 37 | Transform t0 = RandomTransform(rng); 38 | Transform t1 = RandomTransform(rng); 39 | AnimatedTransform at(&t0, 0., &t1, 1.); 40 | 41 | for (int j = 0; j < 5; ++j) { 42 | // Generate a random bounding box and find the bounds of its motion. 43 | Bounds3f bounds(Point3f(r(), r(), r()), Point3f(r(), r(), r())); 44 | Bounds3f motionBounds = at.MotionBounds(bounds); 45 | 46 | for (Float t = 0.; t <= 1.; t += 1e-3 * rng.UniformFloat()) { 47 | // Now, interpolate the transformations at a bunch of times 48 | // along the time range and then transform the bounding box 49 | // with the result. 50 | Transform tr; 51 | at.Interpolate(t, &tr); 52 | Bounds3f tb = tr(bounds); 53 | 54 | // Add a little slop to allow for floating-point round-off 55 | // error in computing the motion extrema times. 56 | tb.pMin += (Float)1e-4 * tb.Diagonal(); 57 | tb.pMax -= (Float)1e-4 * tb.Diagonal(); 58 | 59 | // Now, the transformed bounds should be inside the motion 60 | // bounds. 61 | EXPECT_GE(tb.pMin.x, motionBounds.pMin.x); 62 | EXPECT_LE(tb.pMax.x, motionBounds.pMax.x); 63 | EXPECT_GE(tb.pMin.y, motionBounds.pMin.y); 64 | EXPECT_LE(tb.pMax.y, motionBounds.pMax.y); 65 | EXPECT_GE(tb.pMin.z, motionBounds.pMin.z); 66 | EXPECT_LE(tb.pMax.z, motionBounds.pMax.z); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/tests/bitops.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "tests/gtest/gtest.h" 3 | #include 4 | #include "pbrt.h" 5 | 6 | using namespace pbrt; 7 | 8 | TEST(Log2, Basics) { 9 | for (int i = 0; i < 32; ++i) { 10 | uint32_t ui = 1u << i; 11 | EXPECT_EQ(i, Log2Int(ui)); 12 | EXPECT_EQ(i, Log2Int((uint64_t)ui)); 13 | } 14 | 15 | for (int i = 1; i < 31; ++i) { 16 | uint32_t ui = 1u << i; 17 | EXPECT_EQ(i, Log2Int(ui + 1)); 18 | EXPECT_EQ(i, Log2Int((uint64_t)(ui + 1))); 19 | } 20 | 21 | for (int i = 0; i < 64; ++i) { 22 | uint64_t ui = 1ull << i; 23 | EXPECT_EQ(i, Log2Int(ui)); 24 | } 25 | 26 | for (int i = 1; i < 64; ++i) { 27 | uint64_t ui = 1ull << i; 28 | EXPECT_EQ(i, Log2Int(ui + 1)); 29 | } 30 | } 31 | 32 | TEST(Pow2, Basics) { 33 | for (int i = 0; i < 32; ++i) { 34 | uint32_t ui = 1u << i; 35 | EXPECT_EQ(true, IsPowerOf2(ui)); 36 | if (ui > 1) { 37 | EXPECT_EQ(false, IsPowerOf2(ui + 1)); 38 | } 39 | if (ui > 2) { 40 | EXPECT_EQ(false, IsPowerOf2(ui - 1)); 41 | } 42 | } 43 | } 44 | 45 | TEST(CountTrailing, Basics) { 46 | for (int i = 0; i < 32; ++i) { 47 | uint32_t ui = 1u << i; 48 | EXPECT_EQ(i, CountTrailingZeros(ui)); 49 | } 50 | } 51 | 52 | TEST(RoundUpPow2, Basics) { 53 | EXPECT_EQ(RoundUpPow2(7), 8); 54 | for (int i = 1; i < (1 << 24); ++i) 55 | if (IsPowerOf2(i)) 56 | EXPECT_EQ(RoundUpPow2(i), i); 57 | else 58 | EXPECT_EQ(RoundUpPow2(i), 1 << (Log2Int(i) + 1)); 59 | 60 | for (int64_t i = 1; i < (1 << 24); ++i) 61 | if (IsPowerOf2(i)) 62 | EXPECT_EQ(RoundUpPow2(i), i); 63 | else 64 | EXPECT_EQ(RoundUpPow2(i), 1 << (Log2Int(i) + 1)); 65 | 66 | for (int i = 0; i < 30; ++i) { 67 | int v = 1 << i; 68 | EXPECT_EQ(RoundUpPow2(v), v); 69 | if (v > 2) EXPECT_EQ(RoundUpPow2(v - 1), v); 70 | EXPECT_EQ(RoundUpPow2(v + 1), 2 * v); 71 | } 72 | 73 | for (int i = 0; i < 62; ++i) { 74 | int64_t v = 1ll << i; 75 | EXPECT_EQ(RoundUpPow2(v), v); 76 | if (v > 2) EXPECT_EQ(RoundUpPow2(v - 1), v); 77 | EXPECT_EQ(RoundUpPow2(v + 1), 2 * v); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/tests/fileutil.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "tests/gtest/gtest.h" 3 | #include "fileutil.h" 4 | 5 | using namespace pbrt; 6 | 7 | TEST(FileUtil, HasExtension) { 8 | EXPECT_TRUE(HasExtension("foo.exr", "exr")); 9 | EXPECT_TRUE(HasExtension("foo.Exr", "exr")); 10 | EXPECT_TRUE(HasExtension("foo.Exr", "exR")); 11 | EXPECT_TRUE(HasExtension("foo.EXR", "exr")); 12 | EXPECT_FALSE(HasExtension("foo.xr", "exr")); 13 | EXPECT_FALSE(HasExtension("/foo/png", "ppm")); 14 | } 15 | 16 | 17 | TEST(FileUtil, AbsolutePath) { 18 | #ifdef PBRT_IS_WINDOWS 19 | EXPECT_TRUE(IsAbsolutePath("\\\\foo\\bar.exe")); 20 | EXPECT_TRUE(IsAbsolutePath("c:\\foo\\bar.exe")); 21 | EXPECT_FALSE(IsAbsolutePath("foo\\bar")); 22 | #endif // PBRT_IS_WINDOWS 23 | EXPECT_TRUE(IsAbsolutePath("/foo/bar")); 24 | EXPECT_FALSE(IsAbsolutePath("foo/bar")); 25 | } 26 | -------------------------------------------------------------------------------- /src/tests/find_interval.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "tests/gtest/gtest.h" 3 | #include "pbrt.h" 4 | #include 5 | 6 | using namespace pbrt; 7 | 8 | TEST(FindInterval, Basics) { 9 | std::vector a{0,1,2,3,4,5,6,7,8,9}; 10 | 11 | // Check clamping for out of range 12 | EXPECT_EQ(0, FindInterval(a.size(), 13 | [&](int index) { return a[index] <= -1; })); 14 | EXPECT_EQ(a.size() - 2, 15 | FindInterval(a.size(), 16 | [&](int index) { return a[index] <= 100; })); 17 | 18 | for (size_t i = 0; i < a.size() - 1; ++i) { 19 | EXPECT_EQ(i, FindInterval(a.size(), 20 | [&](int index) { return a[index] <= i; })); 21 | EXPECT_EQ(i, FindInterval(a.size(), 22 | [&](int index) { return a[index] <= i + 0.5; })); 23 | if (i > 0) 24 | EXPECT_EQ(i - 1, 25 | FindInterval(a.size(), 26 | [&](int index) { return a[index] <= i - 0.5; })); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/tests/gtest/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // 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 are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "tests/gtest/gtest.h" 33 | #include 34 | 35 | GTEST_API_ int main(int argc, char **argv) { 36 | google::InitGoogleLogging(argv[0]); 37 | FLAGS_stderrthreshold = 1; // Warning and above. 38 | printf("Running main() from gtest_main.cc\n"); 39 | testing::InitGoogleTest(&argc, argv); 40 | return RUN_ALL_TESTS(); 41 | } 42 | -------------------------------------------------------------------------------- /src/tests/hg.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "tests/gtest/gtest.h" 3 | #include "pbrt.h" 4 | #include "rng.h" 5 | #include "sampling.h" 6 | #include "medium.h" 7 | 8 | using namespace pbrt; 9 | 10 | TEST(HenyeyGreenstein, SamplingMatch) { 11 | RNG rng; 12 | for (float g = -.75; g <= 0.75; g += 0.25) { 13 | HenyeyGreenstein hg(g); 14 | for (int i = 0; i < 100; ++i) { 15 | Vector3f wo = 16 | UniformSampleSphere({rng.UniformFloat(), rng.UniformFloat()}); 17 | Vector3f wi; 18 | Point2f u {rng.UniformFloat(), rng.UniformFloat()}; 19 | Float p0 = hg.Sample_p(wo, &wi, u); 20 | // Phase function is normalized, and the sampling method should be 21 | // exact. 22 | EXPECT_NEAR(p0, hg.p(wo, wi), 1e-4f) << "Failure with g = " << g; 23 | } 24 | } 25 | } 26 | 27 | TEST(HenyeyGreenstein, SamplingOrientationForward) { 28 | RNG rng; 29 | 30 | HenyeyGreenstein hg(0.95); 31 | Vector3f wo(-1, 0, 0); 32 | int nForward = 0, nBackward = 0; 33 | for (int i = 0; i < 100; ++i) { 34 | Point2f u {rng.UniformFloat(), rng.UniformFloat()}; 35 | Vector3f wi; 36 | hg.Sample_p(wo, &wi, u); 37 | if (wi.x > 0) 38 | ++nForward; 39 | else 40 | ++nBackward; 41 | } 42 | // With g = 0.95, almost all of the samples should have wi.x > 0. 43 | EXPECT_GE(nForward, 10 * nBackward); 44 | } 45 | 46 | TEST(HenyeyGreenstein, SamplingOrientationBackward) { 47 | RNG rng; 48 | 49 | HenyeyGreenstein hg(-0.95); 50 | Vector3f wo(-1, 0, 0); 51 | int nForward = 0, nBackward = 0; 52 | for (int i = 0; i < 100; ++i) { 53 | Point2f u {rng.UniformFloat(), rng.UniformFloat()}; 54 | Vector3f wi; 55 | hg.Sample_p(wo, &wi, u); 56 | if (wi.x > 0) 57 | ++nForward; 58 | else 59 | ++nBackward; 60 | } 61 | // With g = -0.95, almost all of the samples should have wi.x < 0. 62 | EXPECT_GE(nBackward, 10 * nForward); 63 | } 64 | 65 | TEST(HenyeyGreenstein, Normalized) { 66 | RNG rng; 67 | for (float g = -.75; g <= 0.75; g += 0.25) { 68 | HenyeyGreenstein hg(g); 69 | Vector3f wo = 70 | UniformSampleSphere({rng.UniformFloat(), rng.UniformFloat()}); 71 | Float sum = 0; 72 | int nSamples = 100000; 73 | for (int i = 0; i < nSamples; ++i) { 74 | Vector3f wi = 75 | UniformSampleSphere({rng.UniformFloat(), rng.UniformFloat()}); 76 | sum += hg.p(wo, wi); 77 | } 78 | // Phase function should integrate to 1/4pi. 79 | EXPECT_NEAR(sum / nSamples, 1. / (4. * Pi), 1e-3f); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/tests/parallel.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "tests/gtest/gtest.h" 3 | #include "pbrt.h" 4 | #include "parallel.h" 5 | #include 6 | 7 | using namespace pbrt; 8 | 9 | TEST(Parallel, Basics) { 10 | ParallelInit(); 11 | 12 | std::atomic counter{0}; 13 | ParallelFor([&](int64_t) { ++counter; }, 1000, 1); 14 | EXPECT_EQ(1000, counter); 15 | 16 | counter = 0; 17 | ParallelFor([&](int64_t) { ++counter; }, 1000, 19); 18 | EXPECT_EQ(1000, counter); 19 | 20 | counter = 0; 21 | ParallelFor2D([&](Point2i p) { ++counter; }, Point2i(15, 14)); 22 | EXPECT_EQ(15*14, counter); 23 | 24 | ParallelCleanup(); 25 | } 26 | 27 | TEST(Parallel, DoNothing) { 28 | ParallelInit(); 29 | 30 | std::atomic counter{0}; 31 | ParallelFor([&](int64_t) { ++counter; }, 0); 32 | EXPECT_EQ(0, counter); 33 | 34 | counter = 0; 35 | ParallelFor2D([&](Point2i p) { ++counter; }, Point2i(0, 0)); 36 | EXPECT_EQ(0, counter); 37 | 38 | ParallelCleanup(); 39 | } 40 | -------------------------------------------------------------------------------- /src/textures/bilerp.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_TEXTURES_BILERP_H 39 | #define PBRT_TEXTURES_BILERP_H 40 | 41 | // textures/bilerp.h* 42 | #include "pbrt.h" 43 | #include "texture.h" 44 | #include "paramset.h" 45 | 46 | namespace pbrt { 47 | 48 | // BilerpTexture Declarations 49 | template 50 | class BilerpTexture : public Texture { 51 | public: 52 | // BilerpTexture Public Methods 53 | BilerpTexture(std::unique_ptr mapping, const T &v00, 54 | const T &v01, const T &v10, const T &v11) 55 | : mapping(std::move(mapping)), v00(v00), v01(v01), v10(v10), v11(v11) {} 56 | T Evaluate(const SurfaceInteraction &si) const { 57 | Vector2f dstdx, dstdy; 58 | Point2f st = mapping->Map(si, &dstdx, &dstdy); 59 | return (1 - st[0]) * (1 - st[1]) * v00 + (1 - st[0]) * (st[1]) * v01 + 60 | (st[0]) * (1 - st[1]) * v10 + (st[0]) * (st[1]) * v11; 61 | } 62 | 63 | private: 64 | // BilerpTexture Private Data 65 | std::unique_ptr mapping; 66 | const T v00, v01, v10, v11; 67 | }; 68 | 69 | BilerpTexture *CreateBilerpFloatTexture(const Transform &tex2world, 70 | const TextureParams &tp); 71 | BilerpTexture *CreateBilerpSpectrumTexture(const Transform &tex2world, 72 | const TextureParams &tp); 73 | 74 | } // namespace pbrt 75 | 76 | #endif // PBRT_TEXTURES_BILERP_H 77 | -------------------------------------------------------------------------------- /src/textures/constant.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // textures/constant.cpp* 35 | #include "textures/constant.h" 36 | 37 | namespace pbrt { 38 | 39 | // ConstantTexture Method Definitions 40 | ConstantTexture *CreateConstantFloatTexture(const Transform &tex2world, 41 | const TextureParams &tp) { 42 | return new ConstantTexture(tp.FindFloat("value", 1.f)); 43 | } 44 | 45 | ConstantTexture *CreateConstantSpectrumTexture( 46 | const Transform &tex2world, const TextureParams &tp) { 47 | return new ConstantTexture( 48 | tp.FindSpectrum("value", Spectrum(1.f))); 49 | } 50 | 51 | } // namespace pbrt 52 | -------------------------------------------------------------------------------- /src/textures/constant.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_TEXTURES_CONSTANT_H 39 | #define PBRT_TEXTURES_CONSTANT_H 40 | 41 | // textures/constant.h* 42 | #include "pbrt.h" 43 | #include "texture.h" 44 | #include "paramset.h" 45 | 46 | namespace pbrt { 47 | 48 | // ConstantTexture Declarations 49 | template 50 | class ConstantTexture : public Texture { 51 | public: 52 | // ConstantTexture Public Methods 53 | ConstantTexture(const T &value) : value(value) {} 54 | T Evaluate(const SurfaceInteraction &) const { return value; } 55 | 56 | private: 57 | T value; 58 | }; 59 | 60 | ConstantTexture *CreateConstantFloatTexture(const Transform &tex2world, 61 | const TextureParams &tp); 62 | ConstantTexture *CreateConstantSpectrumTexture( 63 | const Transform &tex2world, const TextureParams &tp); 64 | 65 | } // namespace pbrt 66 | 67 | #endif // PBRT_TEXTURES_CONSTANT_H 68 | -------------------------------------------------------------------------------- /src/textures/fbm.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // textures/fbm.cpp* 35 | #include "textures/fbm.h" 36 | 37 | namespace pbrt { 38 | 39 | // FBmTexture Method Definitions 40 | FBmTexture *CreateFBmFloatTexture(const Transform &tex2world, 41 | const TextureParams &tp) { 42 | // Initialize 3D texture mapping _map_ from _tp_ 43 | std::unique_ptr map(new IdentityMapping3D(tex2world)); 44 | return new FBmTexture(std::move(map), tp.FindInt("octaves", 8), 45 | tp.FindFloat("roughness", .5f)); 46 | } 47 | 48 | FBmTexture *CreateFBmSpectrumTexture(const Transform &tex2world, 49 | const TextureParams &tp) { 50 | // Initialize 3D texture mapping _map_ from _tp_ 51 | std::unique_ptr map(new IdentityMapping3D(tex2world)); 52 | return new FBmTexture(std::move(map), tp.FindInt("octaves", 8), 53 | tp.FindFloat("roughness", .5f)); 54 | } 55 | 56 | } // namespace pbrt 57 | -------------------------------------------------------------------------------- /src/textures/fbm.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_TEXTURES_FBM_H 39 | #define PBRT_TEXTURES_FBM_H 40 | 41 | // textures/fbm.h* 42 | #include "pbrt.h" 43 | #include "texture.h" 44 | #include "paramset.h" 45 | 46 | namespace pbrt { 47 | 48 | // FBmTexture Declarations 49 | template 50 | class FBmTexture : public Texture { 51 | public: 52 | // FBmTexture Public Methods 53 | FBmTexture(std::unique_ptr mapping, int octaves, 54 | Float omega) 55 | : mapping(std::move(mapping)), omega(omega), octaves(octaves) {} 56 | T Evaluate(const SurfaceInteraction &si) const { 57 | Vector3f dpdx, dpdy; 58 | Point3f P = mapping->Map(si, &dpdx, &dpdy); 59 | return FBm(P, dpdx, dpdy, omega, octaves); 60 | } 61 | 62 | private: 63 | std::unique_ptr mapping; 64 | const Float omega; 65 | const int octaves; 66 | }; 67 | 68 | FBmTexture *CreateFBmFloatTexture(const Transform &tex2world, 69 | const TextureParams &tp); 70 | FBmTexture *CreateFBmSpectrumTexture(const Transform &tex2world, 71 | const TextureParams &tp); 72 | 73 | } // namespace pbrt 74 | 75 | #endif // PBRT_TEXTURES_FBM_H 76 | -------------------------------------------------------------------------------- /src/textures/marble.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // textures/marble.cpp* 35 | #include "textures/marble.h" 36 | 37 | namespace pbrt { 38 | 39 | // MarbleTexture Method Definitions 40 | Texture *CreateMarbleFloatTexture(const Transform &tex2world, 41 | const TextureParams &tp) { 42 | return nullptr; 43 | } 44 | 45 | MarbleTexture *CreateMarbleSpectrumTexture(const Transform &tex2world, 46 | const TextureParams &tp) { 47 | // Initialize 3D texture mapping _map_ from _tp_ 48 | std::unique_ptr map(new IdentityMapping3D(tex2world)); 49 | return new MarbleTexture(std::move(map), tp.FindInt("octaves", 8), 50 | tp.FindFloat("roughness", .5f), 51 | tp.FindFloat("scale", 1.f), 52 | tp.FindFloat("variation", .2f)); 53 | } 54 | 55 | } // namespace pbrt 56 | -------------------------------------------------------------------------------- /src/textures/mix.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // textures/mix.cpp* 35 | #include "textures/mix.h" 36 | 37 | namespace pbrt { 38 | 39 | // MixTexture Method Definitions 40 | MixTexture *CreateMixFloatTexture(const Transform &tex2world, 41 | const TextureParams &tp) { 42 | return new MixTexture(tp.GetFloatTexture("tex1", 0.f), 43 | tp.GetFloatTexture("tex2", 1.f), 44 | tp.GetFloatTexture("amount", 0.5f)); 45 | } 46 | 47 | MixTexture *CreateMixSpectrumTexture(const Transform &tex2world, 48 | const TextureParams &tp) { 49 | return new MixTexture(tp.GetSpectrumTexture("tex1", 0.f), 50 | tp.GetSpectrumTexture("tex2", 1.f), 51 | tp.GetFloatTexture("amount", 0.5f)); 52 | } 53 | 54 | } // namespace pbrt 55 | -------------------------------------------------------------------------------- /src/textures/mix.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_TEXTURES_MIX_H 39 | #define PBRT_TEXTURES_MIX_H 40 | 41 | // textures/mix.h* 42 | #include "pbrt.h" 43 | #include "texture.h" 44 | #include "paramset.h" 45 | 46 | namespace pbrt { 47 | 48 | // MixTexture Declarations 49 | template 50 | class MixTexture : public Texture { 51 | public: 52 | // MixTexture Public Methods 53 | MixTexture(const std::shared_ptr> &tex1, 54 | const std::shared_ptr> &tex2, 55 | const std::shared_ptr> &amount) 56 | : tex1(tex1), tex2(tex2), amount(amount) {} 57 | T Evaluate(const SurfaceInteraction &si) const { 58 | T t1 = tex1->Evaluate(si), t2 = tex2->Evaluate(si); 59 | Float amt = amount->Evaluate(si); 60 | return (1 - amt) * t1 + amt * t2; 61 | } 62 | 63 | private: 64 | std::shared_ptr> tex1, tex2; 65 | std::shared_ptr> amount; 66 | }; 67 | 68 | MixTexture *CreateMixFloatTexture(const Transform &tex2world, 69 | const TextureParams &tp); 70 | MixTexture *CreateMixSpectrumTexture(const Transform &tex2world, 71 | const TextureParams &tp); 72 | 73 | } // namespace pbrt 74 | 75 | #endif // PBRT_TEXTURES_MIX_H 76 | -------------------------------------------------------------------------------- /src/textures/ptex.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_TEXTURES_PTEX_H 39 | #define PBRT_TEXTURES_PTEX_H 40 | 41 | // textures/ptex.h* 42 | #include "pbrt.h" 43 | #include "texture.h" 44 | 45 | #include 46 | 47 | namespace pbrt { 48 | 49 | // PtexTexture Declarations 50 | template 51 | class PtexTexture : public Texture { 52 | public: 53 | // PtexTexture Public Methods 54 | PtexTexture(const std::string &filename, Float gamma); 55 | ~PtexTexture(); 56 | T Evaluate(const SurfaceInteraction &) const; 57 | 58 | private: 59 | bool valid; 60 | const std::string filename; 61 | const Float gamma; 62 | }; 63 | 64 | PtexTexture *CreatePtexFloatTexture(const Transform &tex2world, 65 | const TextureParams &tp); 66 | PtexTexture *CreatePtexSpectrumTexture(const Transform &tex2world, 67 | const TextureParams &tp); 68 | 69 | } // namespace pbrt 70 | 71 | #endif // PBRT_TEXTURES_PTEX_H 72 | -------------------------------------------------------------------------------- /src/textures/scale.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // textures/scale.cpp* 35 | #include "textures/scale.h" 36 | 37 | namespace pbrt { 38 | 39 | // ScaleTexture Method Definitions 40 | ScaleTexture *CreateScaleFloatTexture(const Transform &tex2world, 41 | const TextureParams &tp) { 42 | return new ScaleTexture(tp.GetFloatTexture("tex1", 1.f), 43 | tp.GetFloatTexture("tex2", 1.f)); 44 | } 45 | 46 | ScaleTexture *CreateScaleSpectrumTexture( 47 | const Transform &tex2world, const TextureParams &tp) { 48 | return new ScaleTexture( 49 | tp.GetSpectrumTexture("tex1", Spectrum(1.f)), 50 | tp.GetSpectrumTexture("tex2", Spectrum(1.f))); 51 | } 52 | 53 | } // namespace pbrt 54 | -------------------------------------------------------------------------------- /src/textures/scale.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_TEXTURES_SCALE_H 39 | #define PBRT_TEXTURES_SCALE_H 40 | 41 | // textures/scale.h* 42 | #include "pbrt.h" 43 | #include "texture.h" 44 | #include "paramset.h" 45 | 46 | namespace pbrt { 47 | 48 | // ScaleTexture Declarations 49 | template 50 | class ScaleTexture : public Texture { 51 | public: 52 | // ScaleTexture Public Methods 53 | ScaleTexture(const std::shared_ptr> &tex1, 54 | const std::shared_ptr> &tex2) 55 | : tex1(tex1), tex2(tex2) {} 56 | T2 Evaluate(const SurfaceInteraction &si) const { 57 | return tex1->Evaluate(si) * tex2->Evaluate(si); 58 | } 59 | 60 | private: 61 | // ScaleTexture Private Data 62 | std::shared_ptr> tex1; 63 | std::shared_ptr> tex2; 64 | }; 65 | 66 | ScaleTexture *CreateScaleFloatTexture(const Transform &tex2world, 67 | const TextureParams &tp); 68 | ScaleTexture *CreateScaleSpectrumTexture( 69 | const Transform &tex2world, const TextureParams &tp); 70 | 71 | } // namespace pbrt 72 | 73 | #endif // PBRT_TEXTURES_SCALE_H 74 | -------------------------------------------------------------------------------- /src/textures/uv.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_TEXTURES_UV_H 39 | #define PBRT_TEXTURES_UV_H 40 | 41 | // textures/uv.h* 42 | #include "pbrt.h" 43 | #include "texture.h" 44 | #include "paramset.h" 45 | 46 | namespace pbrt { 47 | 48 | // UVTexture Declarations 49 | class UVTexture : public Texture { 50 | public: 51 | // UVTexture Public Methods 52 | UVTexture(std::unique_ptr mapping) 53 | : mapping(std::move(mapping)) {} 54 | Spectrum Evaluate(const SurfaceInteraction &si) const { 55 | Vector2f dstdx, dstdy; 56 | Point2f st = mapping->Map(si, &dstdx, &dstdy); 57 | Float rgb[3] = {st[0] - std::floor(st[0]), st[1] - std::floor(st[1]), 58 | 0}; 59 | return Spectrum::FromRGB(rgb); 60 | } 61 | 62 | private: 63 | std::unique_ptr mapping; 64 | }; 65 | 66 | Texture *CreateUVFloatTexture(const Transform &tex2world, 67 | const TextureParams &tp); 68 | UVTexture *CreateUVSpectrumTexture(const Transform &tex2world, 69 | const TextureParams &tp); 70 | 71 | } // namespace pbrt 72 | 73 | #endif // PBRT_TEXTURES_UV_H 74 | -------------------------------------------------------------------------------- /src/textures/windy.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // textures/windy.cpp* 35 | #include "textures/windy.h" 36 | 37 | namespace pbrt { 38 | 39 | // WindyTexture Method Definitions 40 | WindyTexture *CreateWindyFloatTexture(const Transform &tex2world, 41 | const TextureParams &tp) { 42 | // Initialize 3D texture mapping _map_ from _tp_ 43 | std::unique_ptr map(new IdentityMapping3D(tex2world)); 44 | return new WindyTexture(std::move(map)); 45 | } 46 | 47 | WindyTexture *CreateWindySpectrumTexture(const Transform &tex2world, 48 | const TextureParams &tp) { 49 | // Initialize 3D texture mapping _map_ from _tp_ 50 | std::unique_ptr map(new IdentityMapping3D(tex2world)); 51 | return new WindyTexture(std::move(map)); 52 | } 53 | 54 | } // namespace pbrt 55 | -------------------------------------------------------------------------------- /src/textures/windy.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_TEXTURES_WINDY_H 39 | #define PBRT_TEXTURES_WINDY_H 40 | 41 | // textures/windy.h* 42 | #include "pbrt.h" 43 | #include "texture.h" 44 | #include "paramset.h" 45 | 46 | namespace pbrt { 47 | 48 | // WindyTexture Declarations 49 | template 50 | class WindyTexture : public Texture { 51 | public: 52 | // WindyTexture Public Methods 53 | WindyTexture(std::unique_ptr mapping) 54 | : mapping(std::move(mapping)) {} 55 | T Evaluate(const SurfaceInteraction &si) const { 56 | Vector3f dpdx, dpdy; 57 | Point3f P = mapping->Map(si, &dpdx, &dpdy); 58 | Float windStrength = FBm(.1f * P, .1f * dpdx, .1f * dpdy, .5, 3); 59 | Float waveHeight = FBm(P, dpdx, dpdy, .5, 6); 60 | return std::abs(windStrength) * waveHeight; 61 | } 62 | 63 | private: 64 | std::unique_ptr mapping; 65 | }; 66 | 67 | WindyTexture *CreateWindyFloatTexture(const Transform &tex2world, 68 | const TextureParams &tp); 69 | WindyTexture *CreateWindySpectrumTexture(const Transform &tex2world, 70 | const TextureParams &tp); 71 | 72 | } // namespace pbrt 73 | 74 | #endif // PBRT_TEXTURES_WINDY_H 75 | -------------------------------------------------------------------------------- /src/textures/wrinkled.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | 34 | // textures/wrinkled.cpp* 35 | #include "textures/wrinkled.h" 36 | 37 | namespace pbrt { 38 | 39 | // WrinkledTexture Method Definitions 40 | WrinkledTexture *CreateWrinkledFloatTexture(const Transform &tex2world, 41 | const TextureParams &tp) { 42 | // Initialize 3D texture mapping _map_ from _tp_ 43 | std::unique_ptr map(new IdentityMapping3D(tex2world)); 44 | return new WrinkledTexture(std::move(map), tp.FindInt("octaves", 8), 45 | tp.FindFloat("roughness", .5f)); 46 | } 47 | 48 | WrinkledTexture *CreateWrinkledSpectrumTexture( 49 | const Transform &tex2world, const TextureParams &tp) { 50 | // Initialize 3D texture mapping _map_ from _tp_ 51 | std::unique_ptr map(new IdentityMapping3D(tex2world)); 52 | return new WrinkledTexture(std::move(map), 53 | tp.FindInt("octaves", 8), 54 | tp.FindFloat("roughness", .5f)); 55 | } 56 | 57 | } // namespace pbrt 58 | -------------------------------------------------------------------------------- /src/textures/wrinkled.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | pbrt source code is Copyright(c) 1998-2016 4 | Matt Pharr, Greg Humphreys, and Wenzel Jakob. 5 | 6 | This file is part of pbrt. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #if defined(_MSC_VER) 34 | #define NOMINMAX 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PBRT_TEXTURES_WRINKLED_H 39 | #define PBRT_TEXTURES_WRINKLED_H 40 | 41 | // textures/wrinkled.h* 42 | #include "pbrt.h" 43 | #include "texture.h" 44 | #include "paramset.h" 45 | 46 | namespace pbrt { 47 | 48 | // WrinkledTexture Declarations 49 | template 50 | class WrinkledTexture : public Texture { 51 | public: 52 | // WrinkledTexture Public Methods 53 | WrinkledTexture(std::unique_ptr mapping, int octaves, 54 | Float omega) 55 | : mapping(std::move(mapping)), octaves(octaves), omega(omega) {} 56 | T Evaluate(const SurfaceInteraction &si) const { 57 | Vector3f dpdx, dpdy; 58 | Point3f p = mapping->Map(si, &dpdx, &dpdy); 59 | return Turbulence(p, dpdx, dpdy, omega, octaves); 60 | } 61 | 62 | private: 63 | // WrinkledTexture Private Data 64 | std::unique_ptr mapping; 65 | int octaves; 66 | Float omega; 67 | }; 68 | 69 | WrinkledTexture *CreateWrinkledFloatTexture(const Transform &tex2world, 70 | const TextureParams &tp); 71 | WrinkledTexture *CreateWrinkledSpectrumTexture( 72 | const Transform &tex2world, const TextureParams &tp); 73 | 74 | } // namespace pbrt 75 | 76 | #endif // PBRT_TEXTURES_WRINKLED_H 77 | --------------------------------------------------------------------------------