├── .clang-format ├── .cmake-format ├── .cmake-format.json ├── .github └── workflows │ ├── mac-linux.yml │ └── windows.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── SHARING_SOLUTIONS_ONLINE_IS_FORBIDDEN.txt ├── build-discovery.sh ├── cmake ├── CPM.cmake ├── DartsConfig.cmake └── tools.cmake ├── configure-discovery.sh ├── documentation ├── CMakeLists.txt ├── Doxyfile-mcss ├── Doxyfile.in ├── assignment0.md ├── assignment1.md ├── assignment2.md ├── assignment3.md ├── assignment4.md ├── assignment5.md ├── assignment6.md ├── assignments.md ├── conf.py ├── credits.md ├── darts-overview.md ├── discovery-tutorial.md ├── getting-started.md ├── images │ ├── RTNextWeek.jpg │ ├── RTOneWeekend.jpg │ ├── RTRestOfYourLife.jpg │ ├── accept-assignment.png │ ├── assignment-accepted.png │ ├── benedikt_bitterli_2014.png │ ├── build-dialog.png │ ├── build-directory.png │ ├── build-mode.png │ ├── c++-plugin.png │ ├── classroom.png │ ├── cmake-plugin.png │ ├── configure.png │ ├── cs87-banner-f21.jpg │ ├── dario_seyb_2019.png │ ├── darts-logo.svg │ ├── darts-wordmark.svg │ ├── download-code.png │ ├── edit-readme1.png │ ├── edit-readme2.png │ ├── favicon.png │ ├── github-actions1.png │ ├── github-actions2.png │ ├── github-actions3.png │ ├── integrator-li.png │ ├── jensen_box.png │ ├── kit-selection.png │ ├── loewenfeld.png │ ├── mode-selection.png │ ├── nefertiti.png │ ├── open-dialog.png │ ├── pbrt-bookcover.png │ ├── phong-pdf.png │ ├── phong-sampled.png │ ├── plugins.png │ ├── points-in-sphere.png │ ├── points-on-cosine-hemisphere.png │ ├── points-on-cosine-power-hemisphere.png │ ├── points-on-hemisphere.png │ ├── points-on-sphere.png │ ├── run-darts.png │ ├── run-output.png │ ├── shoe.png │ ├── shruti_agarwal_2018.png │ ├── simon_kallweit_2015.png │ ├── spherical-cap-points.png │ ├── submit-assignment.gif │ ├── tizian_zeltner_2015.png │ └── triangle-points.png ├── m-theme-dark.css ├── modules.md ├── schedule.md └── syllabus.md ├── include └── darts │ ├── array2d.h │ ├── box.h │ ├── camera.h │ ├── common.h │ ├── factory.h │ ├── fwd.h │ ├── image.h │ ├── json.h │ ├── material.h │ ├── mesh.h │ ├── parallel_for.h │ ├── progress.h │ ├── ray.h │ ├── sampler.h │ ├── sampling.h │ ├── scene.h │ ├── sphere.h │ ├── surface.h │ ├── surface_group.h │ ├── test.h │ ├── transform.h │ ├── triangle.h │ └── vec.h ├── io_darts.py ├── plot_csv.ipynb ├── reports ├── assignment0 │ ├── report.html │ ├── task1-mine.png │ ├── task1-reference.png │ ├── task2-mine.png │ └── task2-reference.png ├── assignment1 │ └── report.html ├── assignment2 │ └── report.html ├── assignment3 │ └── report.html ├── assignment4 │ └── report.html ├── assignment5 │ └── report.html ├── final_project_proposal │ └── report.html └── resources │ ├── common.css │ ├── jquery.event.move.js │ ├── jquery.twentytwenty.js │ ├── markdeep.min.js │ └── twentytwenty.css ├── scenes ├── assignment0 │ ├── cornell_grayscale-ref.png │ ├── cornellbox.png │ └── gradient-ref.png ├── assignment1 │ ├── 01_camera_ray_image-ref.png │ ├── 01_manual_ray_image-ref.png │ ├── 01_plane-ref.png │ ├── 01_plane.json │ ├── 01_recursive_raytracing-ref.png │ ├── 01_xformed_camera_ray_image-ref.png │ ├── 01_xformed_camera_sphere_image-ref.png │ ├── 02_balls-ref.png │ ├── 02_balls.json │ ├── 03_refl-ref.png │ ├── 03_refl.json │ ├── 04_refr-ref.png │ ├── 04_refr.json │ ├── 05_quad-light-ref.png │ ├── 05_quad-light.json │ ├── 06_jensen_box-ref.png │ ├── 06_jensen_box.json │ ├── example_scene0-ref.png │ ├── example_scene1-1spp.png │ ├── example_scene1-ref.png │ ├── example_scene2-1spp.png │ ├── example_scene2-ref.png │ ├── example_scene3-1spp.png │ └── example_scene3-ref.png ├── assignment2 │ ├── ajax-white-1spp.png │ ├── ajax-white-ref.png │ ├── ajax-white.json │ ├── buddha-box-1spp.png │ ├── buddha-box-ref.png │ ├── buddha-box.json │ ├── bunny-dragons-1spp.png │ ├── bunny-dragons-ref.png │ ├── bunny-dragons.json │ ├── loewenfeld-in-box-1spp.png │ ├── loewenfeld-in-box-ref.png │ ├── loewenfeld-in-box.json │ ├── loewenfeld-white-1spp.png │ ├── loewenfeld-white-ref.png │ ├── loewenfeld-white.json │ ├── nefertiti-white-1spp.png │ ├── nefertiti-white-ref.png │ ├── nefertiti-white.json │ ├── simple-geometry-50spp.png │ ├── simple-geometry-ref.png │ ├── simple-geometry.json │ ├── sponza-buddha-1spp.png │ ├── sponza-buddha-ref.png │ ├── sponza-buddha.json │ └── test_intersection.json ├── assignment3 │ ├── ajax-textured-16spp.png │ ├── ajax-textured-1spp.png │ ├── ajax-textured-ref.png │ ├── ajax-textured.json │ ├── blend-ref.png │ ├── blend.json │ ├── checker-ref.png │ ├── checker.json │ ├── constant-cornell-box-ref.png │ ├── constant-cornell-box.json │ ├── earth-ref.png │ ├── earth.json │ ├── fresnel_blend-ref.png │ ├── fresnel_blend.json │ ├── loewenfeld-textured-16spp.png │ ├── loewenfeld-textured-1spp.png │ ├── loewenfeld-textured-ref.png │ ├── loewenfeld-textured.json │ ├── marble-128spp.png │ ├── marble.json │ ├── nefertiti-textured-ref.png │ ├── nefertiti-textured.json │ ├── teapot-50spp.png │ ├── teapot-ref.png │ ├── teapot.json │ ├── textured-box-ref.png │ └── textured-box.json ├── assignment4 │ ├── ajax-ao-ref.png │ ├── ajax-ao.json │ ├── ajax-normals-ref.png │ ├── ajax-normals.json │ ├── blinn_phong-pdf-ref.png │ ├── blinn_phong-ref.png │ ├── blinn_phong-rotated-pdf-ref.png │ ├── blinn_phong-rotated-sampled-ref.png │ ├── blinn_phong-sampled-ref.png │ ├── blinn_phong.json │ ├── lambertian-pdf-ref.png │ ├── lambertian-rotated-pdf-ref.png │ ├── lambertian-rotated-sampled-ref.png │ ├── lambertian-sampled-ref.png │ ├── odyssey_mats-ref.png │ ├── odyssey_mats.json │ ├── phong-pdf-ref.png │ ├── phong-ref.png │ ├── phong-rotated-pdf-ref.png │ ├── phong-rotated-sampled-ref.png │ ├── phong-sampled-ref.png │ ├── phong.json │ ├── test_materials.json │ ├── veach_mats-ref.png │ └── veach_mats.json └── assignment5 │ ├── group-pdf-ref.png │ ├── group-sampled-ref.png │ ├── jensen_box_mats-64spp.png │ ├── jensen_box_mats-ref.png │ ├── jensen_box_mats.json │ ├── jensen_box_mis-64spp.png │ ├── jensen_box_mis-ref.png │ ├── jensen_box_mis.json │ ├── jensen_box_nee-ref.png │ ├── jensen_box_nee.json │ ├── odyssey_mis-ref.png │ ├── odyssey_mis.json │ ├── odyssey_nee-ref.png │ ├── odyssey_nee.json │ ├── odyssey_triangle_mats-ref.png │ ├── odyssey_triangle_mats.json │ ├── odyssey_triangle_mis-ref.png │ ├── odyssey_triangle_mis.json │ ├── odyssey_triangle_nee-ref.png │ ├── odyssey_triangle_nee.json │ ├── quad-pdf-ref.png │ ├── quad-sampled-ref.png │ ├── sphere-pdf-ref.png │ ├── sphere-sampled-ref.png │ ├── sphere_light_large-ref.png │ ├── sphere_light_large_mats-ref.png │ ├── sphere_light_large_mats.json │ ├── sphere_light_large_mis-ref.png │ ├── sphere_light_large_mis.json │ ├── sphere_light_large_nee-ref.png │ ├── sphere_light_large_nee.json │ ├── sphere_light_medium-ref.png │ ├── sphere_light_medium_mats-ref.png │ ├── sphere_light_medium_mats.json │ ├── sphere_light_medium_mis-ref.png │ ├── sphere_light_medium_mis.json │ ├── sphere_light_medium_nee-ref.png │ ├── sphere_light_medium_nee.json │ ├── sphere_light_small-ref.png │ ├── sphere_light_small_mats-ref.png │ ├── sphere_light_small_mats.json │ ├── sphere_light_small_mis-ref.png │ ├── sphere_light_small_mis.json │ ├── sphere_light_small_nee-ref.png │ ├── sphere_light_small_nee.json │ ├── test_surfaces.json │ ├── triangle-pdf-ref.png │ ├── triangle-sampled-ref.png │ ├── veach_mis-ref.png │ ├── veach_mis.json │ ├── veach_mixture-ref.png │ ├── veach_mixture.json │ ├── veach_nee-ref.png │ └── veach_nee.json ├── setup-discovery.sh ├── src ├── common.cpp ├── darts.cpp ├── darts_tutorial0.cpp ├── darts_tutorial1.cpp ├── example_scenes.cpp ├── image.cpp ├── img_avg.cpp ├── img_compare.cpp ├── materials │ ├── dielectric.cpp │ ├── diffuse_light.cpp │ ├── lambertian.cpp │ ├── material.cpp │ └── metal.cpp ├── parser.cpp ├── progress.cpp ├── samplers │ └── independent.cpp ├── scene.cpp ├── surfaces │ ├── bbh.cpp │ ├── mesh.cpp │ ├── quad.cpp │ ├── sphere.cpp │ ├── surface.cpp │ ├── surface_group.cpp │ └── triangle.cpp └── tests │ ├── intersection_test.cpp │ ├── material_sample_test.cpp │ ├── surface_sample_test.cpp │ └── test.cpp └── test-slurm-job.sh /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: Microsoft 3 | TabWidth: 4 4 | IndentWidth: 4 5 | ColumnLimit: 120 6 | Standard: Cpp11 7 | 8 | AlignAfterOpenBracket: Align 9 | AlignConsecutiveMacros: 'true' 10 | AlignConsecutiveAssignments: 'true' 11 | AlignConsecutiveDeclarations: 'true' 12 | AlignTrailingComments: 'true' 13 | 14 | #AllowShortFunctionsOnASingleLine: All 15 | AllowShortLambdasOnASingleLine: All 16 | #AllowShortBlocksOnASingleLine: Always 17 | #AllowShortLoopsOnASingleLine: 'true' 18 | AllowShortCaseLabelsOnASingleLine: 'true' 19 | 20 | AccessModifierOffset: -4 21 | AlwaysBreakTemplateDeclarations: Yes 22 | BreakConstructorInitializers: AfterColon 23 | 24 | BreakBeforeBraces: Allman 25 | 26 | ... 27 | -------------------------------------------------------------------------------- /.cmake-format: -------------------------------------------------------------------------------- 1 | format: 2 | tab_size: 2 3 | line_width: 100 4 | dangle_parens: true 5 | 6 | parse: 7 | additional_commands: 8 | cpmaddpackage: 9 | pargs: 10 | nargs: '*' 11 | flags: [] 12 | spelling: CPMAddPackage 13 | kwargs: &cpmaddpackagekwargs 14 | NAME: 1 15 | FORCE: 1 16 | VERSION: 1 17 | GIT_TAG: 1 18 | DOWNLOAD_ONLY: 1 19 | GITHUB_REPOSITORY: 1 20 | GITLAB_REPOSITORY: 1 21 | GIT_REPOSITORY: 1 22 | SVN_REPOSITORY: 1 23 | SVN_REVISION: 1 24 | SOURCE_DIR: 1 25 | DOWNLOAD_COMMAND: 1 26 | FIND_PACKAGE_ARGUMENTS: 1 27 | NO_CACHE: 1 28 | GIT_SHALLOW: 1 29 | URL: 1 30 | URL_HASH: 1 31 | URL_MD5: 1 32 | DOWNLOAD_NAME: 1 33 | DOWNLOAD_NO_EXTRACT: 1 34 | HTTP_USERNAME: 1 35 | HTTP_PASSWORD: 1 36 | OPTIONS: + 37 | cpmfindpackage: 38 | pargs: 39 | nargs: '*' 40 | flags: [] 41 | spelling: CPMFindPackage 42 | kwargs: *cpmaddpackagekwargs 43 | packageproject: 44 | pargs: 45 | nargs: '*' 46 | flags: [] 47 | spelling: packageProject 48 | kwargs: 49 | NAME: 1 50 | VERSION: 1 51 | NAMESPACE: 1 52 | INCLUDE_DIR: 1 53 | INCLUDE_DESTINATION: 1 54 | BINARY_DIR: 1 55 | COMPATIBILITY: 1 56 | VERSION_HEADER: 1 57 | DEPENDENCIES: + 58 | -------------------------------------------------------------------------------- /.github/workflows/mac-linux.yml: -------------------------------------------------------------------------------- 1 | name: MacOS and Ubuntu 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | # branches: 7 | # - "*" 8 | # Jobs are skipped when ONLY Markdown (*.md) files are changed 9 | # paths-ignore: 10 | # - "**.md" 11 | pull_request: 12 | # branches: 13 | # - main 14 | # Jobs are skipped when ONLY Markdown (*.md) files are changed 15 | # paths-ignore: 16 | # - "**.md" 17 | 18 | env: 19 | CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules 20 | 21 | jobs: 22 | build: 23 | name: Build 24 | runs-on: ${{matrix.os}} 25 | 26 | strategy: 27 | matrix: 28 | # Run several build types 29 | # buildtype: ["Release", "Debug", "RelWithDebInfo"] 30 | buildtype: ["Release"] 31 | os: [macos-latest, ubuntu-latest, ubuntu-18.04] 32 | # os: [macos-latest] 33 | fail-fast: true 34 | 35 | steps: 36 | - uses: actions/checkout@v2 37 | 38 | - uses: actions/cache@v2 39 | with: 40 | path: "**/cpm_modules" 41 | key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }} 42 | 43 | - name: ccache 44 | uses: hendrikmuhs/ccache-action@v1 45 | with: 46 | key: ${{ matrix.os }}-${{ matrix.buildtype }} 47 | 48 | - name: configure 49 | run: cmake -B ${{github.workspace}}/build -DUSE_FLIP:BOOL=TRUE -DCMAKE_BUILD_TYPE=${{matrix.buildtype}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache 50 | 51 | - name: build 52 | run: cmake --build ${{github.workspace}}/build --parallel --config ${{matrix.buildtype}} 53 | 54 | - name: Checking that darts runs 55 | working-directory: ${{github.workspace}} 56 | run: | 57 | ./build/darts --help 58 | 59 | - name: Running tests 60 | working-directory: ${{github.workspace}} 61 | run: | 62 | ./build/darts_tutorial0 63 | ./build/darts_tutorial1 64 | ./build/point_gen 65 | 66 | - name: Comparing generated images against reference 67 | working-directory: ${{github.workspace}} 68 | run: | 69 | mkdir build/differences 70 | cd build/differences 71 | ../_deps/flip-build/flip -et -c diff.csv -t ${{github.workspace}}/scenes/assignment0/gradient.png -r ${{github.workspace}}/scenes/assignment0/gradient-ref.png 72 | ../_deps/flip-build/flip -et -c diff.csv -t ${{github.workspace}}/scenes/assignment0/cornell_grayscale.png -r ${{github.workspace}}/scenes/assignment0/cornell_grayscale-ref.png 73 | ../_deps/flip-build/flip -et -c diff.csv -t ${{github.workspace}}/scenes/assignment1/01_xformed_camera_sphere_image.png -r ${{github.workspace}}/scenes/assignment1/01_xformed_camera_sphere_image-ref.png 74 | ../_deps/flip-build/flip -et -c diff.csv -t ${{github.workspace}}/scenes/assignment1/01_xformed_camera_ray_image.png -r ${{github.workspace}}/scenes/assignment1/01_xformed_camera_ray_image-ref.png 75 | ../_deps/flip-build/flip -et -c diff.csv -t ${{github.workspace}}/scenes/assignment1/01_manual_ray_image.png -r ${{github.workspace}}/scenes/assignment1/01_manual_ray_image-ref.png 76 | ../_deps/flip-build/flip -et -c diff.csv -t ${{github.workspace}}/scenes/assignment1/01_recursive_raytracing.png -r ${{github.workspace}}/scenes/assignment1/01_recursive_raytracing-ref.png 77 | 78 | - name: Archive test artifacts 79 | uses: actions/upload-artifact@v2 80 | with: 81 | name: differences-${{ matrix.os }}-${{ matrix.buildtype }} 82 | path: | 83 | ${{github.workspace}}/build/differences/ 84 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build* 2 | /.vscode 3 | /cpm_modules 4 | .DS_Store 5 | __pycache__ 6 | /documentation/build* 7 | # /scenes/**/*.obj 8 | # /scenes/**/*.exr 9 | # /scenes/**/*.hdr 10 | # /scenes/**/*.jpg 11 | # /scenes/**/*.png 12 | /scenes/**/*2021-*.* 13 | /scenes/**/*.mtl 14 | /scenes/misc 15 | /scenes/meshes 16 | /scenes/assets -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This base code is provided exclusively for educational purposes/classroom use. 2 | Sharing modifications of this repository online, especially including your 3 | solutions, is expressively forbidden. For example, you may not post your final 4 | implementation in a publicly accessible GitHub/GitLab repository. Since it can 5 | lead to problematic cases of cheating, we are strict about this rule and 6 | regularly search for leaked solutions online. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CS 87/287 Assignments 2 | ===================== 3 | 4 | Student name: 5 | 6 | netid: 7 | 8 | ## Build status 9 | 10 | [![macOS+Ubuntu](https://github.com/cs87-dartmouth/darts-solutions/actions/workflows/mac-linux.yml/badge.svg?branch=main)](https://github.com/cs87-dartmouth/darts-solutions/actions/workflows/mac-linux.yml) 11 | [![Windows](https://github.com/cs87-dartmouth/darts-solutions/actions/workflows/windows.yml/badge.svg?branch=main)](https://github.com/cs87-dartmouth/darts-solutions/actions/workflows/windows.yml) 12 | 13 | ## Assignment reports 14 | 15 | | Assignment | Links 16 | | ---------: | --------------------------------------------- 17 | | 0 | [report.html](reports/assignment0/report.html) 18 | | 1 | [report.html](reports/assignment1/report.html) 19 | | 2 | [report.html](reports/assignment2/report.html) 20 | | 3 | [report.html](reports/assignment3/report.html) 21 | | 4 | [report.html](reports/assignment4/report.html) 22 | | 5 | [report.html](reports/assignment5/report.html) 23 | 24 | 25 | ## Featured result 26 | 27 | Feel free to show off your best render here! -------------------------------------------------------------------------------- /SHARING_SOLUTIONS_ONLINE_IS_FORBIDDEN.txt: -------------------------------------------------------------------------------- 1 | This base code is provided exclusively for educational purposes/classroom use. 2 | Sharing modifications of this repository online, especially including your 3 | solutions, is expressively forbidden. For example, you may not post your final 4 | implementation in a publicly accessible GitHub/GitLab repository. Since it can 5 | lead to problematic cases of cheating, we are strict about this rule and 6 | regularly search for leaked solutions online. -------------------------------------------------------------------------------- /build-discovery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | module load cmake/3.21 4 | module load git/2.0.4 5 | 6 | cmake --build build --parallel -------------------------------------------------------------------------------- /cmake/CPM.cmake: -------------------------------------------------------------------------------- 1 | set(CPM_DOWNLOAD_VERSION 0.32.0) 2 | 3 | if(CPM_SOURCE_CACHE) 4 | # Expand relative path. This is important if the provided path contains a tilde (~) 5 | get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE) 6 | set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") 7 | elseif(DEFINED ENV{CPM_SOURCE_CACHE}) 8 | set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") 9 | else() 10 | set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") 11 | endif() 12 | 13 | if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) 14 | message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") 15 | file(DOWNLOAD 16 | https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake 17 | ${CPM_DOWNLOAD_LOCATION} 18 | ) 19 | endif() 20 | 21 | include(${CPM_DOWNLOAD_LOCATION}) 22 | -------------------------------------------------------------------------------- /cmake/tools.cmake: -------------------------------------------------------------------------------- 1 | # this file contains a list of tools that can be activated and downloaded on-demand each tool is 2 | # enabled during configuration by passing an additional `-DUSE_=` argument to CMake 3 | 4 | # only activate tools for top level project 5 | if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) 6 | return() 7 | endif() 8 | 9 | include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake) 10 | 11 | # enables sanitizers support using the the `USE_SANITIZER` flag available values are: Address, 12 | # Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined' 13 | if(USE_SANITIZER OR USE_STATIC_ANALYZER) 14 | CPMAddPackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354") 15 | 16 | if(USE_SANITIZER) 17 | include(${cmake-scripts_SOURCE_DIR}/sanitizers.cmake) 18 | endif() 19 | 20 | if(USE_STATIC_ANALYZER) 21 | if("clang-tidy" IN_LIST USE_STATIC_ANALYZER) 22 | set(CLANG_TIDY 23 | ON 24 | CACHE INTERNAL "" 25 | ) 26 | else() 27 | set(CLANG_TIDY 28 | OFF 29 | CACHE INTERNAL "" 30 | ) 31 | endif() 32 | if("iwyu" IN_LIST USE_STATIC_ANALYZER) 33 | set(IWYU 34 | ON 35 | CACHE INTERNAL "" 36 | ) 37 | else() 38 | set(IWYU 39 | OFF 40 | CACHE INTERNAL "" 41 | ) 42 | endif() 43 | if("cppcheck" IN_LIST USE_STATIC_ANALYZER) 44 | set(CPPCHECK 45 | ON 46 | CACHE INTERNAL "" 47 | ) 48 | else() 49 | set(CPPCHECK 50 | OFF 51 | CACHE INTERNAL "" 52 | ) 53 | endif() 54 | 55 | include(${cmake-scripts_SOURCE_DIR}/tools.cmake) 56 | 57 | clang_tidy(${CLANG_TIDY_ARGS}) 58 | include_what_you_use(${IWYU_ARGS}) 59 | cppcheck(${CPPCHECK_ARGS}) 60 | endif() 61 | endif() 62 | 63 | # enables CCACHE support through the USE_CCACHE flag possible values are: YES, NO or equivalent 64 | if(USE_CCACHE) 65 | CPMAddPackage("gh:TheLartians/Ccache.cmake@1.2.3") 66 | endif() 67 | -------------------------------------------------------------------------------- /configure-discovery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | module load cmake/3.21 4 | module load git/2.0.4 5 | 6 | cmake -B build -------------------------------------------------------------------------------- /documentation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14 FATAL_ERROR) 2 | 3 | project(documentation) 4 | 5 | # ---- Dependencies ---- 6 | 7 | include(../cmake/CPM.cmake) 8 | CPMAddPackage("gh:wkjarosz/m.css#51a02af8132b3ba1f632fa7928f46a411e6d844e") 9 | 10 | # ---- Doxygen variables ---- 11 | 12 | # set Doxyfile variables 13 | set(DOXYGEN_PROJECT_NAME Darts) 14 | set(DOXYGEN_PROJECT_VERSION ${Darts_VERSION}) 15 | set(DOXYGEN_PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/..") 16 | set(DOXYGEN_MCSS_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doxygen-mcss") 17 | 18 | configure_file(${CMAKE_CURRENT_LIST_DIR}/Doxyfile-mcss ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-mcss) 19 | configure_file(${CMAKE_CURRENT_LIST_DIR}/conf.py ${CMAKE_CURRENT_BINARY_DIR}/conf.py) 20 | 21 | add_custom_target( 22 | website 23 | ${CMAKE_COMMAND} -E rm -rf "${DOXYGEN_MCSS_OUTPUT_DIRECTORY}/html" 24 | COMMAND ${CMAKE_COMMAND} -E make_directory "${DOXYGEN_MCSS_OUTPUT_DIRECTORY}" 25 | COMMAND "${m.css_SOURCE_DIR}/documentation/doxygen.py" "--debug" 26 | "${CMAKE_CURRENT_BINARY_DIR}/conf.py" 27 | COMMAND echo "Docs written to: ${DOXYGEN_MCSS_OUTPUT_DIRECTORY}" 28 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" 29 | ) 30 | -------------------------------------------------------------------------------- /documentation/assignment0.md: -------------------------------------------------------------------------------- 1 | 2 | @page assignment0 A0: Darts preliminaries 3 | 4 | @m_footernavigation 5 | @tableofcontents 6 | 7 | In this assignment, you will learn the basics of how to setup your programming environment, how to get the [darts](\ref darts-overview) base code, and how to submit your solutions. This assignment is not difficult to do – and its only intention is to make sure you have a working development environment – but there is however quite a bit to read. 8 | 9 | By the end of this assignment, you will have 10 | 11 | * Cloned the base code git repository 12 | * Setup your programming environment and successfully compiled the basecode 13 | * Completed both parts of the programming assignment, explained below 14 | 15 | Getting started with the code 16 | ============================= 17 | 18 | Please go read the [brief overview](\ref darts-overview) of our darts codebase. 19 | 20 | Then, walk through the [getting-started guide](\ref getting-started). 21 | 22 | Once you've accepted the assignment, and added the base code repo, here's the TLDR for how to compile the code: 23 | * **Recommended**: Get [VS Code](https://code.visualstudio.com/), install the C++ and CMake Tools extensions, then configure and build the project; or 24 | * In a terminal, configure and build as follows: 25 | 26 | @code{.sh} 27 | cmake -B build 28 | cmake --build build --parallel 29 | @endcode 30 | 31 | 32 | Programming Assignment 33 | ====================== 34 | 35 | For the programming part of this assignment, you will need to familiarize yourself with the basecode that we provide and implement a few tiny changes to make things work. 36 | 37 | Go ahead and open up `%src/darts_tutorial0.cpp`. This is the file you will be editing for this assignment. 38 | 39 | Don't be overwhelmed by the size of this file - the majority of it is comments and functionality provided by us to test your code. 40 | 41 | Part 1: Vectors 42 | --------------- 43 | 44 | For the first part of the programming assignment you need to learn how to use vectors and matrices in darts. Head over to `void %test_vectors_and_matrices()` and read the comments to get started. Everything that you need to change has been marked with a `TODO` comment. 45 | 46 | Part 2: Colors and Images 47 | ------------------------- 48 | 49 | Head on over to `void %test_color_and_image()` and read through the instructions. Everything that you need to change has been marked with a _TODO_ comment. 50 | 51 | @m_div{m-clearfix-s} @m_enddiv 52 | @m_div{m-clearfix-m} @m_enddiv 53 | @m_div{m-clearfix-l} @m_enddiv 54 | 55 | @m_div{m-col-t-8 m-col-s-5 m-col-m-4 m-right-s} 56 | 57 | @m_enddiv 58 | 59 | You will generate and write a `gradient.png` image, that should look like the one shown here. 60 | 61 | To complete the last part of the function, you should load the image in `scenes/assignment0/cornellbox.png` that comes with the base code, convert it to grayscale (as described in the code) and save it under `scenes/assignment0/cornell_grayscale.png`. The input image is shown below on the left; the expected output is shown on the right. 62 | 63 | @m_div{twentytwenty-container} 64 | Original 65 | Grayscale 66 | @m_enddiv 67 | 68 | This handy way of showing off the differences between images is also available for you to use in your assignment project reports. 69 | 70 | 71 | What to submit 72 | ============== 73 | 74 | Submit according to the instructions in the \ref submitting-on-canvas section of \ref getting-started guide. 75 | 76 | @m_footernavigation 77 | -------------------------------------------------------------------------------- /documentation/assignments.md: -------------------------------------------------------------------------------- 1 | @page assignments Assignments 2 | 3 | - @subpage assignment0 \copybrief assignment0 4 | - @subpage assignment1 5 | - @subpage assignment2 6 | - @subpage assignment3 7 | - @subpage assignment4 8 | - @subpage assignment5 9 | - @subpage assignment6 -------------------------------------------------------------------------------- /documentation/credits.md: -------------------------------------------------------------------------------- 1 | @page credits Credits 2 | 3 | The class design, lecture slides, starter code, and assignments have evolved over many years with the help of many individuals. This is my best attempt at tracing this genealogy and crediting the major players. 4 | 5 | The overall concept for the class is based on the one I took at UCSD from Henrik Wann Jensen in 2004. My understanding is that that course was itself modeled after Pat Hanrahan's rendering course at Stanford. 6 | 7 | The current incarnation of the class evolved from the Image Synthesis and Computer Graphics classes I co-taught at ETH Zurich between 2009 and 2015 with Alex Hornung, Ilya Baran, and Wenzel Jakob. Marios Papas and Romain Prévost contributed many ideas and improvements as long-serving TAs for those classes. 8 | 9 | I co-taught my last iteration of the Image Synthesis class at ETH in 2015 with Wenzel Jakob, where we used his then-new Nori 2 educational ray tracer. In many ways darts is inspired by Nori, but darts and its accompanying assignments are designed to start more bare-bones and have a more gradual learning curve while still aiming to end up in the same place (all while fitting into a 9-week Dartmouth term!). Wenzel also created or improved many of the lecture sides. Several of the lectures are created or adapted from slides by Jan Novák. 10 | 11 | I inherited some lecture and assignment material from Fabio Pellacini and Jon Denning when starting at Dartmouth in 2015, and those ideas inevitably shaped some of the current lectures and assignment designs (we still use a `punchout.py` script to generate the basecode from a master solution that, while now entirely rewritten, was originally handed down from them). Some of the slides have also been modeled after those by Steve Marschner (sometimes by way of Fabio Pellacini). As much as possible, I have tried to maintain credits within the slides. 12 | 13 | The GitHub classroom approach to the assignments was borrowed from Wenzel Jakob with the help of his TAs Tizian Zeltner, Merlin Nimier-David, Delio Vicini, and Baptiste Nicolet. Bailey Miller undertook the first Dartmouth incarnation of that for our 2018 offering. 14 | 15 | This class has continued to evolve over the years at Dartmouth, and each redesign has always been helped tremendously by my gifted students and TAs, including Benedikt Bitterli, Bailey Miller, and Srinath Ravichandran. Benedikt Bitterli in particular had a major hand in writing at least some parts of most assignments, as well as co-developing some of the tooling in the base code. 16 | 17 | The PBRT books by Matt Pharr, Greg Humphrey's and now Wenzel Jakob undeniably shaped how I teach the design of a ray tracer over the years. I always struggled, however, finding the balance between teaching from a full-featured codebase like PBRT that allows students to focus on cutting-edge features vs. using bare-bones starter code that forces students to implement more from the ground up. I always leaned more towards the code-it-yourself side, since I felt that so much of the joy of my own experience was in building the system myself. More recently, Pete Shirley's %Ray Tracing books re-imagined how to teach these ideas in a refreshingly accessible way, and the current iteration of this class and the darts code is my take on bridging these extremes. 18 | -------------------------------------------------------------------------------- /documentation/images/RTNextWeek.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/RTNextWeek.jpg -------------------------------------------------------------------------------- /documentation/images/RTOneWeekend.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/RTOneWeekend.jpg -------------------------------------------------------------------------------- /documentation/images/RTRestOfYourLife.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/RTRestOfYourLife.jpg -------------------------------------------------------------------------------- /documentation/images/accept-assignment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/accept-assignment.png -------------------------------------------------------------------------------- /documentation/images/assignment-accepted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/assignment-accepted.png -------------------------------------------------------------------------------- /documentation/images/benedikt_bitterli_2014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/benedikt_bitterli_2014.png -------------------------------------------------------------------------------- /documentation/images/build-dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/build-dialog.png -------------------------------------------------------------------------------- /documentation/images/build-directory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/build-directory.png -------------------------------------------------------------------------------- /documentation/images/build-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/build-mode.png -------------------------------------------------------------------------------- /documentation/images/c++-plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/c++-plugin.png -------------------------------------------------------------------------------- /documentation/images/classroom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/classroom.png -------------------------------------------------------------------------------- /documentation/images/cmake-plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/cmake-plugin.png -------------------------------------------------------------------------------- /documentation/images/configure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/configure.png -------------------------------------------------------------------------------- /documentation/images/cs87-banner-f21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/cs87-banner-f21.jpg -------------------------------------------------------------------------------- /documentation/images/dario_seyb_2019.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/dario_seyb_2019.png -------------------------------------------------------------------------------- /documentation/images/download-code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/download-code.png -------------------------------------------------------------------------------- /documentation/images/edit-readme1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/edit-readme1.png -------------------------------------------------------------------------------- /documentation/images/edit-readme2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/edit-readme2.png -------------------------------------------------------------------------------- /documentation/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/favicon.png -------------------------------------------------------------------------------- /documentation/images/github-actions1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/github-actions1.png -------------------------------------------------------------------------------- /documentation/images/github-actions2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/github-actions2.png -------------------------------------------------------------------------------- /documentation/images/github-actions3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/github-actions3.png -------------------------------------------------------------------------------- /documentation/images/integrator-li.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/integrator-li.png -------------------------------------------------------------------------------- /documentation/images/jensen_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/jensen_box.png -------------------------------------------------------------------------------- /documentation/images/kit-selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/kit-selection.png -------------------------------------------------------------------------------- /documentation/images/loewenfeld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/loewenfeld.png -------------------------------------------------------------------------------- /documentation/images/mode-selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/mode-selection.png -------------------------------------------------------------------------------- /documentation/images/nefertiti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/nefertiti.png -------------------------------------------------------------------------------- /documentation/images/open-dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/open-dialog.png -------------------------------------------------------------------------------- /documentation/images/pbrt-bookcover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/pbrt-bookcover.png -------------------------------------------------------------------------------- /documentation/images/phong-pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/phong-pdf.png -------------------------------------------------------------------------------- /documentation/images/phong-sampled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/phong-sampled.png -------------------------------------------------------------------------------- /documentation/images/plugins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/plugins.png -------------------------------------------------------------------------------- /documentation/images/points-in-sphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/points-in-sphere.png -------------------------------------------------------------------------------- /documentation/images/points-on-cosine-hemisphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/points-on-cosine-hemisphere.png -------------------------------------------------------------------------------- /documentation/images/points-on-cosine-power-hemisphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/points-on-cosine-power-hemisphere.png -------------------------------------------------------------------------------- /documentation/images/points-on-hemisphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/points-on-hemisphere.png -------------------------------------------------------------------------------- /documentation/images/points-on-sphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/points-on-sphere.png -------------------------------------------------------------------------------- /documentation/images/run-darts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/run-darts.png -------------------------------------------------------------------------------- /documentation/images/run-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/run-output.png -------------------------------------------------------------------------------- /documentation/images/shoe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/shoe.png -------------------------------------------------------------------------------- /documentation/images/shruti_agarwal_2018.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/shruti_agarwal_2018.png -------------------------------------------------------------------------------- /documentation/images/simon_kallweit_2015.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/simon_kallweit_2015.png -------------------------------------------------------------------------------- /documentation/images/spherical-cap-points.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/spherical-cap-points.png -------------------------------------------------------------------------------- /documentation/images/submit-assignment.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/submit-assignment.gif -------------------------------------------------------------------------------- /documentation/images/tizian_zeltner_2015.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/tizian_zeltner_2015.png -------------------------------------------------------------------------------- /documentation/images/triangle-points.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/documentation/images/triangle-points.png -------------------------------------------------------------------------------- /documentation/modules.md: -------------------------------------------------------------------------------- 1 | 2 | @defgroup group_sampling Sampling 3 | \brief Random number generation, generation of points and directions, Monte Carlo utilities 4 | @defgroup group_surfaces Surfaces 5 | \brief Geometric surfaces in the scene which can be intersected by rays 6 | @defgroup group_materials Materials 7 | \brief BSDFs and phase functions 8 | @defgroup group_integrators Integrators 9 | \brief Algorithms that solve the rendering equation in different ways 10 | @defgroup group_parser Parser 11 | \brief %Scene parser and JSON serialization/deserialization 12 | @defgroup group_math Math 13 | \brief Fixed-size vectors/colors, matrices, transforms, rays, orthonormal bases 14 | @defgroup group_media Participating media 15 | \brief Participating media between surfaces 16 | @defgroup group_cmdln Command line utils 17 | \brief Printing utilities, and command-line parsing -------------------------------------------------------------------------------- /include/darts/fwd.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | /*! 7 | \dir 8 | \brief main darts include directory 9 | 10 | \file 11 | \brief Various forward declaration 12 | */ 13 | #pragma once 14 | 15 | // Forward declarations 16 | class Camera; 17 | class Image3f; 18 | class Integrator; 19 | struct HitInfo; 20 | struct ScatterRecord; 21 | class Light; 22 | class Material; 23 | class Medium; 24 | struct Mesh; 25 | class Progress; 26 | class Sampler; 27 | class Scene; 28 | class Sphere; 29 | class Surface; 30 | class XformedSurfaceWithMaterial; 31 | class SurfaceGroup; 32 | class Texture; 33 | struct Test; 34 | struct Transform; -------------------------------------------------------------------------------- /include/darts/image.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | /// A floating-point RGB image 14 | class Image3f : public Array2d 15 | { 16 | using Base = Array2d; 17 | 18 | public: 19 | /// Default constructor (empty image) 20 | Image3f() : Base() 21 | { 22 | } 23 | /*! 24 | Size Constructor (sets width and height) 25 | 26 | \param w The width of the image 27 | \param h The height of the image 28 | */ 29 | Image3f(int w, int h) : Base(w, h) 30 | { 31 | } 32 | 33 | /*! 34 | Construct an image of a fixed size and initialize all pixels 35 | 36 | \param w The width of the image 37 | \param h The height of the image 38 | \param v The Color to set all pixels 39 | */ 40 | Image3f(int w, int h, const Color3f &v) : Base(w, h) 41 | { 42 | reset(v); 43 | } 44 | 45 | /*! 46 | Load an image from file 47 | 48 | \param filename The filename 49 | \return True if the file loaded successfully 50 | */ 51 | bool load(const std::string &filename); 52 | 53 | /*! 54 | Save an image to the specified filename 55 | \param filename The filename to save to 56 | \param gain The multiplicative gain to apply to pixel values before saving 57 | \return True if the file saved successfully 58 | */ 59 | bool save(const std::string &filename, float gain = 1.0f); 60 | 61 | /// Set of supported formats for image loading 62 | static std::set loadable_formats() 63 | { 64 | return {"jpg", 65 | "jpeg" 66 | "png", 67 | "bmp", 68 | "psd", 69 | "tga", 70 | "gif", 71 | "hdr", 72 | "pic", 73 | "ppm", 74 | "pgm", 75 | "exr"}; 76 | } 77 | 78 | /// Set of supported formats for image saving 79 | static std::set savable_formats() 80 | { 81 | return {"bmp", "exr", "hdr", "jpg", "png", "tga"}; 82 | } 83 | }; 84 | 85 | /*! 86 | \file 87 | \brief Class #Image3f 88 | */ 89 | -------------------------------------------------------------------------------- /include/darts/material.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /*! \addtogroup group_materials 13 | @{ 14 | */ 15 | 16 | 17 | /// A base class used to represent surface material properties. 18 | class Material 19 | { 20 | public: 21 | /// Default constructor which accepts a #json object of named parameters 22 | Material(const json &j = json::object()); 23 | 24 | /// Free all memory 25 | virtual ~Material() = default; 26 | 27 | /*! 28 | \brief Compute the scattered direction scattered at a surface hitpoint. 29 | 30 | The base Material does not scatter any light, so it simply returns false. 31 | 32 | \param ray incoming ray 33 | \param hit the ray's intersection with the surface 34 | \param attenuation how much the light should be attenuated 35 | \param scattered the direction light should be scattered 36 | \return bool True if the surface scatters light 37 | */ 38 | virtual bool scatter(const Ray3f &ray, const HitInfo &hit, Color3f &attenuation, Ray3f &scattered) const 39 | { 40 | return false; 41 | } 42 | 43 | /*! 44 | Compute the amount of emitted light at the surface hitpoint. 45 | 46 | The base Material class does not emit light, so it simply returns black. 47 | 48 | \param ray the incoming ray 49 | \param hit the ray's intersection with the surface 50 | \return the emitted color 51 | */ 52 | virtual Color3f emitted(const Ray3f &ray, const HitInfo &hit) const 53 | { 54 | return Color3f(0, 0, 0); 55 | } 56 | 57 | /*! 58 | Return whether or not this Material is emissive. 59 | This is primarily used to create a global list of emitters for sampling. 60 | */ 61 | virtual bool is_emissive() const 62 | { 63 | return false; 64 | } 65 | 66 | }; 67 | 68 | /// A perfectly diffuse (Lambertian) material 69 | class Lambertian : public Material 70 | { 71 | public: 72 | Lambertian(const json &j = json::object()); 73 | 74 | bool scatter(const Ray3f &ray, const HitInfo &hit, Color3f &attenuation, Ray3f &scattered) const override; 75 | 76 | 77 | Color3f albedo = Color3f(0.8f); ///< The diffuse color (fraction of light that is reflected per color channel). 78 | }; 79 | 80 | /*! @}*/ 81 | 82 | /*! 83 | \file 84 | \brief Class #Material 85 | */ -------------------------------------------------------------------------------- /include/darts/mesh.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #pragma once 7 | 8 | #include 9 | 10 | /*! 11 | A triangle mesh. 12 | 13 | This class stores a triangle mesh object and provides numerous functions 14 | for querying the individual triangles. Subclasses of \c Mesh implement 15 | the specifics of how to create its contents (e.g. by loading from an 16 | external file) 17 | */ 18 | struct Mesh : public Surface 19 | { 20 | public: 21 | /// Create an empty mesh 22 | Mesh() 23 | { 24 | } 25 | 26 | /// Try to load a mesh from an OBJ file 27 | Mesh(const json &j); 28 | 29 | Box3f bounds() const override 30 | { 31 | return bbox; 32 | } 33 | 34 | bool empty() const 35 | { 36 | return Fv.empty() || vs.empty(); 37 | } 38 | 39 | vector vs; ///< Vertex positions 40 | vector ns; ///< Vertex normals 41 | vector uvs; ///< Vertex texture coordinates 42 | vector Fv; ///< Vertex indices per face (triangle) 43 | vector Fn; ///< Normal indices per face (triangle) 44 | vector Ft; ///< Texture indices per face (triangle) 45 | vector Fm; ///< One material index per face (triangle) 46 | vector> materials; ///< All materials in the mesh 47 | Transform xform = Transform(); ///< Transformation that the data has already been transformed by 48 | Box3f bbox; ///< The bounds, after transformation 49 | 50 | virtual void add_to_parent(Surface *parent, shared_ptr self, const json &j) override; 51 | }; 52 | 53 | /*! 54 | \file 55 | \brief Class #Mesh 56 | */ 57 | -------------------------------------------------------------------------------- /include/darts/parallel_for.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | /*! 14 | Executes the body of a for loop in parallel. 15 | 16 | \param begin The starting index of the for loop 17 | \param end One past the ending index of the for loop 18 | \param step How much to increment at each iteration when moving from begin to end 19 | \param body The body of the for loop as a lambda, taking two parameters: the iterator index in [begin,end), 20 | and the CPU number. 21 | \param num_threads Specify the number of threads to use. 0: as many as there are cores; 1: 22 | execute in serial 23 | 24 | adapted from http://www.andythomason.com/2016/08/21/c-multithreading-an-effective-parallel-for-loop/ 25 | license unknown, presumed public domain 26 | */ 27 | inline void parallel_for(int begin, int end, int step, std::function body, size_t num_threads = 0) 28 | { 29 | std::atomic next_index; 30 | next_index = begin; 31 | 32 | auto policy = num_threads == 1 ? std::launch::deferred : std::launch::async; 33 | size_t num_CPUs = num_threads == 0 ? std::thread::hardware_concurrency() : num_threads; 34 | std::vector> futures(num_CPUs); 35 | for (size_t cpu = 0; cpu != num_CPUs; ++cpu) 36 | { 37 | futures[cpu] = std::async(policy, 38 | [cpu, &next_index, end, step, &body]() 39 | { 40 | // just iterate, grabbing the next available atomic index in the range [begin, 41 | // end) 42 | while (true) 43 | { 44 | int i = next_index.fetch_add(step); 45 | if (i >= end) 46 | break; 47 | body(i, cpu); 48 | } 49 | }); 50 | } 51 | for (auto &f : futures) 52 | f.get(); 53 | } 54 | 55 | /// A version of the parallel_for accepting a body lambda that only takes the iterator index as a parameter 56 | inline void parallel_for(int begin, int end, int step, std::function body, size_t num_threads = 0) 57 | { 58 | parallel_for( 59 | begin, end, step, [&body](int i, size_t) { body(i); }, num_threads); 60 | } 61 | 62 | /// A version of parallel_for with a step of 1, providing the integer index and thread number to the loop \p body 63 | inline void parallel_for(int begin, int end, std::function body, size_t num_threads = 0) 64 | { 65 | parallel_for(begin, end, 1, body, num_threads); 66 | } 67 | 68 | /// A version of parallel_for with a step of 1, providing just the integer index to the loop \p body 69 | inline void parallel_for(int begin, int end, std::function body, size_t num_threads = 0) 70 | { 71 | parallel_for(begin, end, 1, body, num_threads); 72 | } 73 | 74 | /*! 75 | \file 76 | \brief #parallel_for constructs 77 | */ -------------------------------------------------------------------------------- /include/darts/progress.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /*! \addtogroup group_cmdln 13 | @{ 14 | */ 15 | 16 | /*! 17 | A thread-safe helper object to display and update a progress bar in the terminal. 18 | 19 | Example usage: 20 | 21 | \code{.cpp} 22 | { 23 | Progress p1("Solving", 10); 24 | for (int i = 0; i < 10; ++i, ++p1) 25 | { 26 | // do something 27 | } 28 | } // end progress p1 29 | \endcode 30 | */ 31 | class Progress 32 | { 33 | public: 34 | /*! 35 | Create a progress bar with a \p title and \p total_steps number of steps. 36 | 37 | \param title A descriptive title for the task being performed. 38 | 39 | \param total_steps When this is positive, it indicates the number of steps for the calculation. When it is 40 | non-positive, an indeterminate progress bar is created instead (for a task with an unknown 41 | number of steps), and \p total_steps is used as the period, in milliseconds, of the 42 | progress bar's spinning animation. If 0 is specified, a default number of milliseconds is 43 | used. 44 | */ 45 | Progress(const std::string &title, int64_t total_steps = 0); 46 | ~Progress(); 47 | 48 | /// increment the progress by \p steps. \see operator+=() 49 | void step(int64_t steps = 1) 50 | { 51 | m_steps_done += steps; 52 | } 53 | 54 | /// mark the progress as complete 55 | void set_done(); 56 | 57 | /// the current progress 58 | int progress() const 59 | { 60 | return int(m_steps_done); 61 | } 62 | 63 | /// increment the progress by 1 step 64 | Progress &operator++() 65 | { 66 | step(); 67 | return *this; 68 | } 69 | 70 | /// increment the progress by \p steps. \see step() 71 | Progress &operator+=(int64_t steps) 72 | { 73 | step(steps); 74 | return *this; 75 | } 76 | 77 | private: 78 | std::string m_title; 79 | int64_t m_num_steps; 80 | std::atomic m_steps_done; 81 | std::atomic m_exit; 82 | std::thread m_update_thread; 83 | }; 84 | 85 | /*! 86 | \file 87 | \brief Class #Progress 88 | */ 89 | 90 | /*! @}*/ 91 | -------------------------------------------------------------------------------- /include/darts/ray.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | /*! \addtogroup group_math 12 | @{ 13 | */ 14 | 15 | /*! 16 | Simple ray segment data structure. 17 | 18 | Along with the ray origin and direction, this data structure additionally stores the segment interval [\ref mint, 19 | \ref maxt], which may include positive/negative infinity. 20 | */ 21 | template 22 | struct Ray 23 | { 24 | /// "Ray epsilon": relative error threshold for ray intersection computations 25 | static constexpr float epsilon = T(0.0001); 26 | /// infinity for type \tparam T 27 | static constexpr float infinity = std::numeric_limits::infinity(); 28 | 29 | Vec o; ///< The origin of the ray 30 | Vec d; ///< The direction of the ray 31 | T mint; ///< Minimum distance along the ray segment 32 | T maxt; ///< Maximum distance along the ray segment 33 | 34 | /// Construct a new ray 35 | Ray() : mint(epsilon), maxt(std::numeric_limits::infinity()) 36 | { 37 | } 38 | 39 | /// Construct a new ray 40 | Ray(const Vec &o, const Vec &d) : o(o), d(d), mint(epsilon), maxt(std::numeric_limits::infinity()) 41 | { 42 | } 43 | 44 | /// Construct a new ray 45 | Ray(const Vec &o, const Vec &d, T mint, T maxt) : o(o), d(d), mint(mint), maxt(maxt) 46 | { 47 | } 48 | 49 | /// Copy a ray, but change the covered segment of the copy 50 | Ray(const Ray &ray, T mint, T maxt) : o(ray.o), d(ray.d), mint(mint), maxt(maxt) 51 | { 52 | } 53 | 54 | /// Return the position of a point along the ray 55 | Vec operator()(T t) const 56 | { 57 | return o + t * d; 58 | } 59 | }; 60 | 61 | template 62 | using Ray2 = Ray<2, T>; ///< 2D ray 63 | template 64 | using Ray3 = Ray<3, T>; ///< 3D ray 65 | 66 | using Ray2f = Ray2; ///< 2D floating-point ray 67 | using Ray2d = Ray2; ///< 2D double-precision ray 68 | 69 | using Ray3f = Ray3; ///< 3D floating-point ray 70 | using Ray3d = Ray3; ///< 3D double-precision ray 71 | 72 | /*! @}*/ 73 | 74 | /*! 75 | \file 76 | \brief Contains the definition of a generic, N-dimension #Ray class. 77 | */ 78 | -------------------------------------------------------------------------------- /include/darts/sampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /*! 13 | Abstract sample generator. 14 | 15 | A sample generator is responsible for generating the random number stream that will be passed to an #Integrator 16 | implementation as it computes the radiance incident along a specified ray. 17 | */ 18 | class Sampler 19 | { 20 | public: 21 | Sampler() : m_sample_count(1u), m_current_sample(0u), m_current_dimension(0u) 22 | { 23 | } 24 | 25 | virtual ~Sampler() 26 | { 27 | } 28 | 29 | /// Create an exact copy of this Sampler instance 30 | virtual std::unique_ptr clone() const = 0; 31 | 32 | /// Deterministically seed the underlying RNG (to produce identical results between runs) 33 | virtual void seed(int seedx, int seedy) 34 | { 35 | m_current_dimension = 0u; 36 | m_current_sample = 0u; 37 | } 38 | 39 | /*! 40 | Prepare to generate samples for pixel (x,y). 41 | 42 | This function is called every time the integrator starts rendering a new pixel. 43 | */ 44 | virtual void start_pixel(int x, int y) = 0; 45 | 46 | /// Advance to the next sample 47 | virtual void advance() 48 | { 49 | m_current_dimension = 0u; 50 | m_current_sample++; 51 | } 52 | 53 | /// Retrieve the next float value (dimension) from the current sample 54 | virtual float next1f() = 0; 55 | 56 | /// Retrieve the next two float values (dimensions) from the current sample 57 | virtual Vec2f next2f() = 0; 58 | 59 | /// Return the number of configured pixel samples 60 | virtual uint32_t sample_count() const 61 | { 62 | return m_sample_count; 63 | } 64 | 65 | void set_base_seed(uint32_t base) 66 | { 67 | m_base_seed = base; 68 | } 69 | 70 | uint32_t current_sample() const 71 | { 72 | return m_current_sample; 73 | } 74 | 75 | uint32_t current_dimension() const 76 | { 77 | return m_current_dimension; 78 | } 79 | 80 | protected: 81 | uint32_t m_base_seed; 82 | uint32_t m_sample_count; 83 | uint32_t m_current_sample; 84 | uint32_t m_current_dimension; 85 | }; 86 | 87 | /*! 88 | \file 89 | \brief Class #Sampler 90 | */ 91 | -------------------------------------------------------------------------------- /include/darts/scene.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | /*! 16 | Main scene data structure. 17 | 18 | This class aggregates all the surfaces and materials along with the camera. 19 | It provides convenience functions for querying materials by name. 20 | */ 21 | class Scene : public Surface 22 | { 23 | public: 24 | Scene() = default; 25 | /// Construct a new scene from a json object 26 | Scene(const json &j); 27 | 28 | /// Parser a scene from a json object 29 | void parse(const json &j); 30 | 31 | /// Release all memory 32 | virtual ~Scene(); 33 | 34 | virtual void add_child(shared_ptr surface) override 35 | { 36 | m_surfaces->add_child(surface); 37 | } 38 | 39 | bool intersect(const Ray3f &ray, HitInfo &hit) const override 40 | { 41 | INCREMENT_TRACED_RAYS; 42 | return m_surfaces->intersect(ray, hit); 43 | } 44 | 45 | Box3f bounds() const override 46 | { 47 | return m_surfaces->bounds(); 48 | } 49 | 50 | /// Return the background color 51 | Color3f background(const Ray3f &ray) const; 52 | 53 | /// Return the camera 54 | shared_ptr camera() const 55 | { 56 | return m_camera; 57 | } 58 | 59 | /*! 60 | Sample the color along a ray 61 | 62 | \param ray The ray in question 63 | \param depth The current recursion depth 64 | \return An estimate of the color from this direction 65 | */ 66 | Color3f recursive_color(const Ray3f &ray, int depth) const; 67 | 68 | /// Generate the entire image by ray tracing. 69 | Image3f raytrace() const; 70 | 71 | private: 72 | shared_ptr m_camera; 73 | shared_ptr m_surfaces; 74 | Color3f m_background = Color3f(0.2f); 75 | int m_num_samples = 1; 76 | }; 77 | 78 | /// create hard-coded test scenes that do not need to be loaded from a file 79 | json create_example_scene(int scene_number); 80 | 81 | /*! 82 | \file 83 | \brief Class #Scene 84 | */ -------------------------------------------------------------------------------- /include/darts/sphere.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #pragma once 7 | 8 | #include 9 | 10 | /*! \addtogroup group_surfaces 11 | @{ 12 | */ 13 | 14 | /// A sphere centered at the origin with radius \ref m_radius 15 | class Sphere : public XformedSurfaceWithMaterial 16 | { 17 | public: 18 | Sphere(float radius, shared_ptr material, const Transform &xform = Transform()); 19 | Sphere(const json &j = json::object()); 20 | 21 | bool intersect(const Ray3f &ray, HitInfo &hit) const override; 22 | Box3f local_bounds() const override; 23 | 24 | protected: 25 | float m_radius = 1.0f; ///< The radius of the sphere 26 | }; 27 | 28 | /*! @}*/ 29 | 30 | /*! 31 | \file 32 | \brief Class #Sphere 33 | */ 34 | -------------------------------------------------------------------------------- /include/darts/surface_group.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #pragma once 7 | 8 | #include 9 | 10 | /*! \addtogroup group_surfaces 11 | @{ 12 | */ 13 | 14 | /*! 15 | A collection of Surfaces grouped together. 16 | 17 | Provides an interface for treating a collection of Surfaces as a single Surface. This base class implements a naive 18 | linear-time intersection routine which simply intersects each ray with every child Surface. 19 | 20 | This class also serves as the superclass for acceleration structures (such as BVHs, KD-Trees) which are responsible 21 | for performing ray-surface intersection tests against a collection of Surfaces. 22 | */ 23 | class SurfaceGroup : public Surface 24 | { 25 | public: 26 | /// Create a new and empty naive accelerator 27 | SurfaceGroup(const json &j = json::object()) 28 | { 29 | } 30 | 31 | virtual void add_child(shared_ptr surface) override; 32 | 33 | /*! 34 | Intersect a ray against all surfaces registered with the Accelerator. 35 | 36 | Detailed information about the intersection, if any, will be stored in the provided \p hit data record. 37 | 38 | \return true If an intersection was found 39 | */ 40 | bool intersect(const Ray3f &ray, HitInfo &hit) const override; 41 | 42 | Box3f bounds() const override; 43 | 44 | 45 | protected: 46 | vector> m_surfaces; ///< All children 47 | Box3f m_bounds; 48 | }; 49 | 50 | /*! @}*/ 51 | 52 | /*! 53 | \file 54 | \brief Class #SurfaceGroup 55 | */ 56 | -------------------------------------------------------------------------------- /include/darts/test.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /// Base class for unit tests in Darts 13 | struct Test 14 | { 15 | /*! 16 | Run the actual test. 17 | 18 | This is where all the work happens. Derived classes should override this function. 19 | */ 20 | virtual void run() = 0; 21 | }; 22 | 23 | /// Check if this json object contains tests, and run them 24 | void run_tests(const json &j); 25 | 26 | struct SampleTest : public Test 27 | { 28 | SampleTest(const json &j); 29 | 30 | Vec2i direction_to_pixel(const Vec3f &dir) const; 31 | Vec3f pixel_to_direction(const Vec2i &pixel) const; 32 | static Image3f generate_heatmap(const Array2d &density, float max_value); 33 | 34 | virtual void run() override; 35 | virtual bool sample(Vec3f &dir, const Vec2f &rv) = 0; 36 | virtual float pdf(Vec3f &dir) = 0; 37 | virtual void print_more_statistics() 38 | { 39 | } 40 | 41 | string name; 42 | int image_width; 43 | int image_height; 44 | int num_samples; 45 | }; 46 | 47 | /*! 48 | \file 49 | \brief Class #Test. 50 | */ -------------------------------------------------------------------------------- /include/darts/triangle.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #pragma once 7 | 8 | #include 9 | 10 | /// An instance of a triangle for a given face in a mesh 11 | class Triangle : public Surface 12 | { 13 | public: 14 | /// Parse and construct a single triangle 15 | Triangle(const json &j); 16 | 17 | /// Construct a single triangle of an existing mesh 18 | Triangle(const json &j, shared_ptr mesh, uint32_t tri_number); 19 | 20 | bool intersect(const Ray3f &ray, HitInfo &hit) const override; 21 | 22 | Box3f bounds() const override; 23 | 24 | 25 | bool is_emissive() const override 26 | { 27 | return m_mesh && m_mesh->materials[m_mesh->Fm[m_face_idx]] && 28 | m_mesh->materials[m_mesh->Fm[m_face_idx]]->is_emissive(); 29 | } 30 | 31 | protected: 32 | // convenience function to access the i-th vertex (i must be 0, 1, or 2) 33 | Vec3f vertex(size_t i) const 34 | { 35 | return m_mesh->vs[m_mesh->Fv[m_face_idx][i]]; 36 | } 37 | 38 | shared_ptr m_mesh; 39 | uint32_t m_face_idx; 40 | }; 41 | 42 | /// ray - single triangle intersection routine 43 | bool single_triangle_intersect(const Ray3f &ray, const Vec3f &v0, const Vec3f &v1, const Vec3f &v2, const Vec3f *n0, 44 | const Vec3f *n1, const Vec3f *n2, const Vec2f *t0, const Vec2f *t1, const Vec2f *t2, 45 | HitInfo &isect, const Material *material = nullptr); 46 | 47 | /*! 48 | \file 49 | \brief Class #Triangle 50 | */ -------------------------------------------------------------------------------- /plot_csv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "Collecting package metadata (current_repodata.json): ...working... done\n", 13 | "Solving environment: ...working... done\n", 14 | "\n", 15 | "# All requested packages already installed.\n", 16 | "\n", 17 | "\n", 18 | "Note: you may need to restart the kernel to use updated packages.\n" 19 | ] 20 | } 21 | ], 22 | "source": [ 23 | "conda install plotly" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 2, 29 | "metadata": {}, 30 | "outputs": [ 31 | { 32 | "data": { 33 | "application/vnd.jupyter.widget-view+json": { 34 | "model_id": "09735e0f6d044863b3255bf07b12d3ca", 35 | "version_major": 2, 36 | "version_minor": 0 37 | }, 38 | "text/plain": [ 39 | "Button(description='Select File', style=ButtonStyle())" 40 | ] 41 | }, 42 | "metadata": {}, 43 | "output_type": "display_data" 44 | } 45 | ], 46 | "source": [ 47 | "from ipywidgets import Button\n", 48 | "from tkinter import Tk, filedialog\n", 49 | "from IPython.display import clear_output, display\n", 50 | "import pandas as pd\n", 51 | "import plotly.graph_objects as go\n", 52 | "import numpy as np\n", 53 | "\n", 54 | "filename=\"\"\n", 55 | "\n", 56 | "def select_files(b):\n", 57 | " root = Tk()\n", 58 | " root.withdraw() \n", 59 | " root.call('wm', 'attributes', '.', '-topmost', True) \n", 60 | " b.files = filedialog.askopenfilename(multiple=False,title = \"Select File\",filetypes = ((\"CSV files\", \".csv\"),)) \n", 61 | " filename = b.files\n", 62 | " if(filename!=\"\"):\n", 63 | " clear_output()\n", 64 | " print(\"%s chosen\"%filename) \n", 65 | " data = pd.read_csv(filename)\n", 66 | " print(data)\n", 67 | " # tight layout\n", 68 | " x, y, z = data['x'].tolist(),data['y'].tolist(),data['z'].tolist()\n", 69 | " fig = go.Figure(data=[go.Scatter3d(x=x, y=y, z=z,mode='markers')])\n", 70 | " fig.update_layout(margin=dict(l=0, r=0, b=0, t=0)) \n", 71 | " fig.show()\n", 72 | " else:\n", 73 | " print(\"No file chosen\")\n", 74 | " \n", 75 | "\n", 76 | "fileselect = Button(description=\"Select File\")\n", 77 | "fileselect.on_click(select_files)\n", 78 | "display(fileselect)\n", 79 | "\n", 80 | "\n" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "metadata": {}, 87 | "outputs": [], 88 | "source": [] 89 | } 90 | ], 91 | "metadata": { 92 | "kernelspec": { 93 | "display_name": "Python 3", 94 | "language": "python", 95 | "name": "python3" 96 | }, 97 | "language_info": { 98 | "codemirror_mode": { 99 | "name": "ipython", 100 | "version": 3 101 | }, 102 | "file_extension": ".py", 103 | "mimetype": "text/x-python", 104 | "name": "python", 105 | "nbconvert_exporter": "python", 106 | "pygments_lexer": "ipython3", 107 | "version": "3.8.5" 108 | } 109 | }, 110 | "nbformat": 4, 111 | "nbformat_minor": 4 112 | } 113 | -------------------------------------------------------------------------------- /reports/assignment0/report.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | **Assignment 0** 6 | 7 | Student name: XXXX 8 | 9 | netid: YYYY 10 | 11 | (##) About this template 12 | 13 | * Structure your report using numbers and titles following those of the assignment. 14 | 15 | * For every task include all images you generated. darts will generate both an `.exr` and an sRGB tonemapped `.png` image of your rendering. Use the `.png` in the comparisons in your report. 16 | 17 | * For tasks where we provide a reference image, include a comparison of your output to the reference (see examples of this below) 18 | 19 | * Include descriptions of encountered problems, if any. 20 | 21 | For an overview of Markdeep and its syntax, see the [official demo document](https://casual-effects.com/markdeep/features.md.html) and the associated [source code](https://casual-effects.com/markdeep/features.md.html?noformat). 22 | 23 | (##) Task 1 24 | 25 | Create one section for each task. You can create subsections within each task if you need more structure. 26 | 27 | LaTeX is also supported: 28 | $$ 29 | L_o(\mathbf{x}, \omega_o) = \int_{\Omega} L_i(\mathbf{x},\omega_i)\, f(\mathbf{x}, \omega_i, \omega_o)\, 30 | |\cos\theta_i|\, \mathrm{d}\omega_i 31 | $$ 32 | 33 | You can easily include an image comparison like so: 34 | 35 |
36 | Reference 37 | Mine 38 |
39 | 40 | (##) Task 2 41 | 42 |
43 | Reference 44 | Mine 45 |
46 | 47 | (##) Task 3, etc. 48 | 49 | Add additional sections as needed. 50 | 51 | 52 | (##) Tutorial output 53 | 54 | For this assignment, make sure to run the tutorial and save the output, for instance with: 55 | 56 | `build/darts_tutorial0 > output.txt` 57 | 58 | Copy-paste this output into the report here. 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /reports/assignment0/task1-mine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/reports/assignment0/task1-mine.png -------------------------------------------------------------------------------- /reports/assignment0/task1-reference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/reports/assignment0/task1-reference.png -------------------------------------------------------------------------------- /reports/assignment0/task2-mine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/reports/assignment0/task2-mine.png -------------------------------------------------------------------------------- /reports/assignment0/task2-reference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/reports/assignment0/task2-reference.png -------------------------------------------------------------------------------- /reports/assignment1/report.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | **Assignment 1** 6 | 7 | Student name: XXXX 8 | 9 | Netid: YYYY 10 | 11 | (##) Task 1: Generating rays and using JSON 12 | 13 | Manual Ray 14 | 15 |
16 | Reference 17 | Mine 18 |
19 | 20 | Camera Ray 21 | 22 |
23 | Reference 24 | Mine 25 |
26 | 27 | 28 | (##) Task 2: Transforms 29 | 30 |
31 | Reference 32 | Mine 33 |
34 | 35 | (##) Task 3: Spheres 36 | 37 |
38 | Reference 39 | Mine 40 |
41 | 42 | (##) Task 4: Materials 43 | 44 | 45 | (##) Task 5: Recursive Ray Tracing 46 | 47 |
48 | Reference 49 | Mine 50 |
51 | 52 | (##) Task 6: Scene Renderer 53 | 54 |
55 | Reference 56 | Mine 57 |
58 | 59 |
60 | Reference 61 | Mine 62 |
63 | 64 |
65 | Reference 66 | Mine 67 |
68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /reports/assignment2/report.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | **Assignment 2** 6 | 7 | Student name: XXXX 8 | 9 | Netid: YYYY 10 | 11 | (##) Task 1: Ray-triangle intersection 12 | 13 | 14 |
15 | Reference 16 | Mine 17 |
18 | 19 | 20 | (##) Task 2: Ray-AABB intersection 21 | 22 | 23 | (##) Task 3: Hierarchy construction and traversal 24 | 25 | 26 |
27 | Reference 28 | Mine 29 |
30 | 31 |
32 | Reference 33 | Mine 34 |
35 | 36 |
37 | Reference 38 | Mine 39 |
40 | 41 |
42 | Reference 43 | Mine 44 |
45 | 46 |
47 | Reference 48 | Mine 49 |
50 | 51 |
52 | Reference 53 | Mine 54 |
55 | 56 |
57 | Reference 58 | Mine 59 |
60 | 61 | (##) Task 4: Extensions 62 | 63 | (##) Task 5: Surface area heuristic 64 | 65 | (##) Task 6: Evaluation scene and leaderboard 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /reports/assignment3/report.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | **Assignment 3** 6 | 7 | Student name: XXXX 8 | 9 | Netid: YYYY 10 | 11 | (##) Task 1: The Texture class 12 | 13 |
14 | Reference 15 | Mine 16 |
17 | 18 | 19 | (##) Task 2: Solid textures 20 | 21 | Checkerboard 22 | 23 |
24 | Reference 25 | Mine 26 |
27 | 28 | Perlin noise 29 | 30 |
31 | Reference 32 | Mine 33 |
34 | 35 | 36 | (##) Task 3: Image texture mapping 37 | 38 | 39 |
40 | Reference 41 | Mine 42 |
43 | 44 |
45 | Reference 46 | Mine 47 |
48 | 49 |
50 | Reference 51 | Mine 52 |
53 | 54 | 55 | (##) Task 4: Fresnel blend material 56 | 57 |
58 | Reference 59 | Mine 60 |
61 | 62 | (##) Task 5: Interesting scene 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /reports/final_project_proposal/report.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | **Final project proposal** 6 | 7 | (#) Student 1 name (netid1) and Student 2 name (netid1) 8 | 9 | (##) Motivational image 10 | 11 | ![This is our motivational image. It is awesome because...](../assignment0/task2-reference.png) 12 | 13 | A few sentences describing how the image conforms with this year's theme. 14 | 15 | (##) Proposed features and points 16 | 17 | * A list of features relevant to your image that you'd like to implement along with a tentative point breakdown which sums up to 16 points. 18 | 19 | (##) Stretch goals (optional) 20 | 21 | (##) Division of labor/collaboration plan 22 | 23 | A few sentences about how you plan to collaborate/divide the work. 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /reports/resources/common.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,400;0,500;0,600;0,700;0,900;1,400;1,500;1,600;1,700;1,900&family=Source+Sans+Pro:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap'); 2 | 3 | body { 4 | font-family: 'Source Sans Pro', sans-serif; 5 | background:#2f363f; 6 | 7 | color: rgb(220, 220, 220); 8 | /* font-weight: 700; */ 9 | } 10 | 11 | /* reset heading/link fonts to that of body */ 12 | .md a, 13 | .md div.title, contents, .md .tocHeader, 14 | .md h1, .md h2, .md h3, .md h4, .md h5, .md h6, 15 | .md .nonumberh1, .md .nonumberh2, .md .nonumberh3, .md .nonumberh4, .md .nonumberh5, .md .nonumberh6, 16 | .md .shortTOC, .md .mediumTOC, .md .longTOC { 17 | font-family: inherit; 18 | background: inherit; 19 | color: inherit; 20 | } 21 | 22 | a { 23 | color: rgb(165, 201, 234) !important; 24 | font-weight: 600; 25 | } 26 | 27 | body, 28 | table { 29 | font-weight: 500; 30 | /* color: #555; */ 31 | } 32 | 33 | /* em.asterisk { 34 | font-style: normal; 35 | font-weight: 500; 36 | color: #333; 37 | } */ 38 | 39 | 40 | .md div.title { 41 | margin-top: 20px; 42 | font-size: x-large; 43 | /* font-family: 'Source Sans Pro', sans-serif; */ 44 | } 45 | 46 | 47 | /* inline and block code */ 48 | .md code { 49 | color: rgb(230, 230, 230); 50 | background-color: rgb(0, 0, 0, 0.2); 51 | padding: 0.1em 0.2em; 52 | border-radius: 0.15em; 53 | font-weight: 500; 54 | font-family: 'Source Code Pro'; 55 | } 56 | 57 | .md pre.listing, 58 | .md pre.listing.tilde, 59 | .md pre.listing.backtick { 60 | background-color: rgb(0, 0, 0, 0.2); 61 | padding: 0.4em 0.8em; 62 | border-radius: 0.25em; 63 | border: none; 64 | } 65 | 66 | .md pre.listing code { 67 | background-color: transparent; 68 | color: rgb(230, 230, 230); 69 | padding: 0; 70 | font-weight: 500; 71 | } 72 | 73 | 74 | .hljs-string { 75 | color: rgb(216, 142, 116); 76 | } 77 | .hljs-attr { 78 | color: rgb(136, 222, 255); 79 | } 80 | .hljs-number { 81 | color: rgb(175, 207, 164); 82 | } 83 | .hljs-built_in, 84 | .hljs-literal { 85 | color: rgb(57, 158, 219); 86 | } 87 | .hljs-keyword { 88 | /* color: rgb(208, 130, 196); */ 89 | color: rgb(57, 158, 219); 90 | } 91 | .hljs-comment { 92 | color: rgb(91, 154, 76); 93 | } 94 | .hljs-class .hljs-title { 95 | color: rgb(0, 205, 175); 96 | } 97 | .hljs-function .hljs-title { 98 | color: rgb(220, 220, 164); 99 | } 100 | .hljs-function .hljs-params { 101 | color: rgb(212, 212, 212); 102 | } 103 | .hljs-title { 104 | color: rgb(0, 205, 175); 105 | } 106 | 107 | 108 | /* tables; use fainter colors than regular markdeep style */ 109 | .md table.table { 110 | font-size: 90%; 111 | border: none; 112 | } 113 | 114 | .md table.table th { 115 | border: none; 116 | background-color: rgba(255, 255, 255, 0.5); 117 | color: rgba(0,0,0,.9); 118 | } 119 | .md table.table tr, .md table.table td { 120 | border-left:none; 121 | border-right:none; 122 | border-color: rgba(255,255,255,0.1); 123 | } 124 | .md table.table tr:nth-child(even) { 125 | background-color: inherit; 126 | } 127 | .md table.table tr:hover { 128 | background-color: rgba(255,255,255,0.1); 129 | } 130 | 131 | 132 | /* End standard markdeep stuff */ 133 | 134 | -------------------------------------------------------------------------------- /scenes/assignment0/cornell_grayscale-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment0/cornell_grayscale-ref.png -------------------------------------------------------------------------------- /scenes/assignment0/cornellbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment0/cornellbox.png -------------------------------------------------------------------------------- /scenes/assignment0/gradient-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment0/gradient-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/01_camera_ray_image-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/01_camera_ray_image-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/01_manual_ray_image-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/01_manual_ray_image-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/01_plane-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/01_plane-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/01_plane.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "o": [0, 0, 4] 5 | }, 6 | "vfov": 45, 7 | "resolution": [640, 480] 8 | }, 9 | "sampler": { 10 | "type": "independent", 11 | "samples": 100 12 | }, 13 | "background": [ 14 | 1, 1, 1 15 | ], 16 | "surfaces": [ 17 | { 18 | "type": "sphere", 19 | "radius": 1, 20 | "material": { 21 | "type": "lambertian", 22 | "albedo": [0.6, 0.4, 0.4] 23 | } 24 | }, { 25 | "type": "quad", 26 | "transform": { 27 | "o": [ 28 | 0, -1, 0 29 | ], 30 | "x": [ 31 | 1, 0, 0 32 | ], 33 | "y": [ 34 | 0, 0, -1 35 | ], 36 | "z": [0, 1, 0] 37 | }, 38 | "size": 100, 39 | "material": { 40 | "type": "lambertian", 41 | "albedo": [0.75, 0.75, 0.75] 42 | } 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /scenes/assignment1/01_recursive_raytracing-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/01_recursive_raytracing-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/01_xformed_camera_ray_image-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/01_xformed_camera_ray_image-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/01_xformed_camera_sphere_image-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/01_xformed_camera_sphere_image-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/02_balls-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/02_balls-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/02_balls.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "o": [0, 0, 4] 5 | }, 6 | "vfov": 45, 7 | "resolution": [640, 480] 8 | }, 9 | "sampler": { 10 | "type": "independent", 11 | "samples": 100 12 | }, 13 | "background": [ 14 | 1, 1, 1 15 | ], 16 | "materials": [ 17 | { 18 | "type": "lambertian", 19 | "name": "white", 20 | "albedo": [0.6, 0.6, 0.6] 21 | }, { 22 | "type": "lambertian", 23 | "name": "red", 24 | "albedo": [0.6, 0.4, 0.4] 25 | }, { 26 | "type": "lambertian", 27 | "name": "green", 28 | "albedo": [0.4, 0.6, 0.4] 29 | } 30 | ], 31 | "surfaces": [ 32 | { 33 | "type": "quad", 34 | "transform": [ 35 | { 36 | "axis": [ 37 | 1, 0, 0 38 | ], 39 | "angle": -90 40 | }, { 41 | "translate": [0, -1, 0] 42 | } 43 | ], 44 | "size": 100, 45 | "material": "white" 46 | }, { 47 | "type": "sphere", 48 | "transform": { 49 | "translate": [0.5, 0, 0] 50 | }, 51 | "radius": 1.0, 52 | "material": "red" 53 | }, { 54 | "type": "sphere", 55 | "transform": [ 56 | { 57 | "translate": [-0.5, 0, 0] 58 | }, { 59 | "scale": 0.75 60 | }, { 61 | "translate": [-1.0, -0.25, -1] 62 | } 63 | ], 64 | "material": "green" 65 | } 66 | ] 67 | } 68 | -------------------------------------------------------------------------------- /scenes/assignment1/03_refl-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/03_refl-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/03_refl.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "o": [0, 0, 4] 5 | }, 6 | "vfov": 45, 7 | "resolution": [640, 480] 8 | }, 9 | "sampler": { 10 | "type": "independent", 11 | "samples": 100 12 | }, 13 | "background": [ 14 | 1, 1, 1 15 | ], 16 | "materials": [ 17 | { 18 | "type": "lambertian", 19 | "name": "white", 20 | "albedo": [0.6, 0.6, 0.6] 21 | }, { 22 | "type": "metal", 23 | "name": "chrome", 24 | "albedo": [ 25 | 0.8, 0.8, 0.8 26 | ], 27 | "roughness": 0.1 28 | }, { 29 | "type": "lambertian", 30 | "name": "green", 31 | "albedo": [0.4, 0.6, 0.4] 32 | } 33 | ], 34 | "surfaces": [ 35 | { 36 | "type": "quad", 37 | "transform": [ 38 | { 39 | "axis": [ 40 | 1, 0, 0 41 | ], 42 | "angle": -90 43 | }, { 44 | "translate": [0, -1, 0] 45 | } 46 | ], 47 | "size": 100, 48 | "material": "white" 49 | }, { 50 | "type": "sphere", 51 | "transform": { 52 | "translate": [0.5, 0, 0] 53 | }, 54 | "radius": 1.0, 55 | "material": "chrome" 56 | }, { 57 | "type": "sphere", 58 | "transform": [ 59 | { 60 | "translate": [-0.5, 0, 0] 61 | }, { 62 | "scale": 0.75 63 | }, { 64 | "translate": [-1.0, -0.25, -1] 65 | } 66 | ], 67 | "material": "green" 68 | } 69 | ] 70 | } 71 | -------------------------------------------------------------------------------- /scenes/assignment1/04_refr-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/04_refr-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/04_refr.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "o": [0, 0, 4] 5 | }, 6 | "vfov": 45, 7 | "resolution": [640, 480] 8 | }, 9 | "sampler": { 10 | "type": "independent", 11 | "samples": 100 12 | }, 13 | "background": [ 14 | 1, 1, 1 15 | ], 16 | "materials": [ 17 | { 18 | "type": "lambertian", 19 | "name": "white", 20 | "albedo": [0.6, 0.6, 0.6] 21 | }, { 22 | "type": "dielectric", 23 | "name": "glass", 24 | "ior": 1.1 25 | }, { 26 | "type": "lambertian", 27 | "name": "green", 28 | "albedo": [0.4, 0.6, 0.4] 29 | } 30 | ], 31 | "surfaces": [ 32 | { 33 | "type": "quad", 34 | "transform": [ 35 | { 36 | "axis": [ 37 | 1, 0, 0 38 | ], 39 | "angle": -90 40 | }, { 41 | "translate": [0, -1, 0] 42 | } 43 | ], 44 | "size": 100, 45 | "material": "white" 46 | }, { 47 | "type": "sphere", 48 | "transform": { 49 | "translate": [0.5, 0.0, 0] 50 | }, 51 | "radius": 1.0, 52 | "material": "glass" 53 | }, { 54 | "type": "sphere", 55 | "transform": { 56 | "translate": [-0.3, -0.25, -1.8] 57 | }, 58 | "radius": 0.75, 59 | "material": "green" 60 | } 61 | ] 62 | } 63 | -------------------------------------------------------------------------------- /scenes/assignment1/05_quad-light-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/05_quad-light-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/05_quad-light.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 0, 1.75, 6 6 | ], 7 | "at": [0, 1, 0] 8 | }, 9 | "resolution": [ 10 | 640, 480 11 | ], 12 | "vfov": 45 13 | }, 14 | "sampler": { 15 | "type": "independent", 16 | "samples": 256 17 | }, 18 | "background": [ 19 | 0, 0, 0 20 | ], 21 | "materials": [ 22 | { 23 | "type": "lambertian", 24 | "name": "white", 25 | "albedo": [0.6, 0.6, 0.6] 26 | }, 27 | { 28 | "type": "metal", 29 | "name": "chrome", 30 | "roughness": 0.0, 31 | "albedo": [0.6, 0.6, 0.6] 32 | }, 33 | { 34 | "type": "lambertian", 35 | "name": "green", 36 | "albedo": [0.4, 0.6, 0.4] 37 | }, 38 | { 39 | "type": "dielectric", 40 | "name": "glass", 41 | "ior": 1.5 42 | }, { 43 | "type": "diffuse_light", 44 | "name": "light", 45 | "emit": [20, 20, 20] 46 | } 47 | ], 48 | "surfaces": [ 49 | { 50 | "type": "quad", 51 | "transform": [ 52 | { 53 | "axis": [ 54 | 1, 0, 0 55 | ], 56 | "angle": -90 57 | } 58 | ], 59 | "size": [ 60 | 100, 100 61 | ], 62 | "material": "white" 63 | }, 64 | { 65 | "type": "sphere", 66 | "radius": 1.0, 67 | "transform": { 68 | "translate": [0.5, 1, 0] 69 | }, 70 | "material": "glass" 71 | }, 72 | { 73 | "type": "sphere", 74 | "radius": 1.0, 75 | "transform": { 76 | "translate": [2.2, 1, -4] 77 | }, 78 | "material": "green" 79 | }, 80 | { 81 | "type": "sphere", 82 | "radius": 1.5, 83 | "transform": [ 84 | { 85 | "translate": [-2.5, 1.5, -3.5] 86 | } 87 | ], 88 | "material": "chrome" 89 | }, { 90 | "type": "quad", 91 | "transform": [ 92 | { 93 | "axis": [ 94 | 0, 1, 0 95 | ], 96 | "angle": -90 97 | }, { 98 | "axis": [ 99 | 0, 0, 1 100 | ], 101 | "angle": 50 102 | }, { 103 | "translate": [4, 3.5, 0] 104 | }, { 105 | "axis": [ 106 | 0, 1, 0 107 | ], 108 | "angle": 65 109 | } 110 | ], 111 | "size": [ 112 | 1, 1 113 | ], 114 | "material": "light" 115 | } 116 | ] 117 | } 118 | -------------------------------------------------------------------------------- /scenes/assignment1/06_jensen_box-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/06_jensen_box-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/example_scene0-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/example_scene0-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/example_scene1-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/example_scene1-1spp.png -------------------------------------------------------------------------------- /scenes/assignment1/example_scene1-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/example_scene1-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/example_scene2-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/example_scene2-1spp.png -------------------------------------------------------------------------------- /scenes/assignment1/example_scene2-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/example_scene2-ref.png -------------------------------------------------------------------------------- /scenes/assignment1/example_scene3-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/example_scene3-1spp.png -------------------------------------------------------------------------------- /scenes/assignment1/example_scene3-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment1/example_scene3-ref.png -------------------------------------------------------------------------------- /scenes/assignment2/ajax-white-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/ajax-white-1spp.png -------------------------------------------------------------------------------- /scenes/assignment2/ajax-white-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/ajax-white-ref.png -------------------------------------------------------------------------------- /scenes/assignment2/ajax-white.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 24, 10, 0 6 | ], 7 | "at": [ 8 | 0, 3.5, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [720, 1280] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 1 19 | }, 20 | "background": 5, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "materials": [ 25 | { 26 | "type": "lambertian", 27 | "name": "white", 28 | "albedo": 0.2 29 | } 30 | ], 31 | "surfaces": [ 32 | { 33 | "type": "mesh", 34 | "name": "ajax", 35 | "filename": "../assets/ajax.obj", 36 | "material": "white", 37 | "transform": [ 38 | { 39 | "translate": [-0.053126335, 0.030193329, 17.283958] 40 | }, { 41 | "scale": 0.2 42 | }, { 43 | "axis": [ 44 | 0, 1, 0 45 | ], 46 | "angle": 150 47 | }, { 48 | "translate": [0, 0, -0.25] 49 | } 50 | ] 51 | }, { 52 | "type": "mesh", 53 | "name": "floor", 54 | "filename": "../assets/plane.obj", 55 | "transform": [ 56 | { 57 | "scale": [1000, 1, 1000] 58 | } 59 | ], 60 | "material": "white" 61 | } 62 | ] 63 | } 64 | -------------------------------------------------------------------------------- /scenes/assignment2/buddha-box-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/buddha-box-1spp.png -------------------------------------------------------------------------------- /scenes/assignment2/buddha-box-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/buddha-box-ref.png -------------------------------------------------------------------------------- /scenes/assignment2/bunny-dragons-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/bunny-dragons-1spp.png -------------------------------------------------------------------------------- /scenes/assignment2/bunny-dragons-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/bunny-dragons-ref.png -------------------------------------------------------------------------------- /scenes/assignment2/loewenfeld-in-box-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/loewenfeld-in-box-1spp.png -------------------------------------------------------------------------------- /scenes/assignment2/loewenfeld-in-box-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/loewenfeld-in-box-ref.png -------------------------------------------------------------------------------- /scenes/assignment2/loewenfeld-white-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/loewenfeld-white-1spp.png -------------------------------------------------------------------------------- /scenes/assignment2/loewenfeld-white-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/loewenfeld-white-ref.png -------------------------------------------------------------------------------- /scenes/assignment2/loewenfeld-white.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 24, 10, 0 6 | ], 7 | "at": [ 8 | 0, 3.5, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [720, 1280] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 1 19 | }, 20 | "background": 5, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "materials": [ 25 | { 26 | "type": "lambertian", 27 | "name": "defaultMat", 28 | "albedo": 0.2 29 | } 30 | ], 31 | "surfaces": [ 32 | { 33 | "type": "quad", 34 | "transform": [ 35 | { 36 | "axis": [ 37 | 1, 0, 0 38 | ], 39 | "angle": -90 40 | }, { 41 | "axis": [ 42 | 0, 1, 0 43 | ], 44 | "angle": 45 45 | } 46 | ], 47 | "size": [ 48 | 150, 150 49 | ], 50 | "material": "defaultMat" 51 | }, { 52 | "type": "mesh", 53 | "filename": "../assets/loewenfeld/models/smoothed.obj", 54 | "transform": [ 55 | { 56 | "translate": [0, 222.3563, 0] 57 | }, { 58 | "scale": 0.014 59 | }, { 60 | "axis": [ 61 | 0, 1, 0 62 | ], 63 | "angle": 165 64 | } 65 | ], 66 | "material": "defaultMat" 67 | } 68 | ] 69 | } 70 | -------------------------------------------------------------------------------- /scenes/assignment2/nefertiti-white-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/nefertiti-white-1spp.png -------------------------------------------------------------------------------- /scenes/assignment2/nefertiti-white-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/nefertiti-white-ref.png -------------------------------------------------------------------------------- /scenes/assignment2/nefertiti-white.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 24, 10, 0 6 | ], 7 | "at": [ 8 | 0, 3.5, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [720, 1280] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 1 19 | }, 20 | "background": 5, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "materials": [ 25 | { 26 | "type": "lambertian", 27 | "name": "defaultMat", 28 | "albedo": 0.2 29 | } 30 | ], 31 | "surfaces": [ 32 | { 33 | "type": "quad", 34 | "name": "floor", 35 | "transform": [ 36 | { 37 | "axis": [ 38 | 1, 0, 0 39 | ], 40 | "angle": -90 41 | }, { 42 | "axis": [ 43 | 0, 1, 0 44 | ], 45 | "angle": 45 46 | } 47 | ], 48 | "size": [ 49 | 150, 150 50 | ], 51 | "material": "defaultMat" 52 | }, { 53 | "type": "mesh", 54 | "name": "ajax", 55 | "filename": "../assets/nefertiti/aem_aem21300_3dsl01_mo08-03_p.obj", 56 | "transform": [ 57 | { 58 | "axis": [ 59 | 1, 0, 0 60 | ], 61 | "angle": -90 62 | }, { 63 | "translate": [413.7063, 226.50739, 86.24023] 64 | }, { 65 | "scale": 0.015 66 | }, { 67 | "axis": [ 68 | 0, 1, 0 69 | ], 70 | "angle": 115 71 | } 72 | ], 73 | "material": "defaultMat" 74 | } 75 | ] 76 | } 77 | -------------------------------------------------------------------------------- /scenes/assignment2/simple-geometry-50spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/simple-geometry-50spp.png -------------------------------------------------------------------------------- /scenes/assignment2/simple-geometry-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/simple-geometry-ref.png -------------------------------------------------------------------------------- /scenes/assignment2/sponza-buddha-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/sponza-buddha-1spp.png -------------------------------------------------------------------------------- /scenes/assignment2/sponza-buddha-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment2/sponza-buddha-ref.png -------------------------------------------------------------------------------- /scenes/assignment2/sponza-buddha.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | -2, 0.5, -0.1 6 | ], 7 | "at": [0, 0.5, 0] 8 | } 9 | }, 10 | "sampler": { 11 | "type": "independent", 12 | "samples": 1 13 | }, 14 | "background": [ 15 | 2, 2, 2 16 | ], 17 | "accelerator": { 18 | "type": "bbh" 19 | }, 20 | "materials": [ 21 | { 22 | "type": "lambertian", 23 | "name": "white", 24 | "albedo": [0.73, 0.73, 0.73] 25 | }, { 26 | "type": "lambertian", 27 | "name": "red", 28 | "albedo": [0.65, 0.05, 0.05] 29 | }, { 30 | "type": "lambertian", 31 | "name": "green", 32 | "albedo": [0.12, 0.45, 0.15] 33 | } 34 | ], 35 | "surfaces": [ 36 | { 37 | "type": "mesh", 38 | "name": "sponza", 39 | "filename": "../assets/sponza.obj", 40 | "material": "white" 41 | }, { 42 | "type": "mesh", 43 | "filename": "../assets/buddha.obj", 44 | "material": "green", 45 | "transform": [ 46 | { 47 | "translate": [-2, 0, 0] 48 | } 49 | ] 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /scenes/assignment2/test_intersection.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "tests", 3 | "tests": [ 4 | { 5 | "type": "intersection", 6 | "surface": { 7 | "type": "triangle", 8 | "positions": [ 9 | [ 10 | -2.0, -5.0, -1.0 11 | ], 12 | [ 13 | 1.0, 3.0, 1.0 14 | ], 15 | [ 16 | 2.0, -2.0, 3.0 17 | ] 18 | ], 19 | "normals": [ 20 | [ 21 | 0.0, 0.707106, 0.707106 22 | ], 23 | [ 24 | 0.666666, 0.333333, 0.666666 25 | ], 26 | [ 27 | 0.0, -0.447213, -0.894427 28 | ] 29 | ], 30 | "material": { 31 | "type": "lambertian", 32 | "albedo": 1.0 33 | } 34 | }, 35 | "ray": 36 | { 37 | "origin": [1.0, -1.0, -5.0], 38 | "direction": [0.0, 0.20, 0.50] 39 | }, 40 | "t": 12.520326, 41 | "p": [1.0, 1.504065, 1.260162], 42 | "gn": [0.744073, -0.114473, -0.658218], 43 | "sn": [0.762482, 0.317441, 0.563784] 44 | } 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /scenes/assignment3/ajax-textured-16spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/ajax-textured-16spp.png -------------------------------------------------------------------------------- /scenes/assignment3/ajax-textured-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/ajax-textured-1spp.png -------------------------------------------------------------------------------- /scenes/assignment3/ajax-textured-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/ajax-textured-ref.png -------------------------------------------------------------------------------- /scenes/assignment3/ajax-textured.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 24, 10, 0 6 | ], 7 | "at": [ 8 | 0, 3.5, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [720, 1280] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 1 19 | }, 20 | "background": 1, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "materials": [ 25 | { 26 | "type": "lambertian", 27 | "name": "stone", 28 | "albedo": { 29 | "type": "marble", 30 | "scale": 3.0, 31 | "veins": [ 32 | 0.29, 0.23, 0.15 33 | ], 34 | "base": [ 35 | 0.45, 0.4, 0.29 36 | ], 37 | "transform": [ 38 | { 39 | "scale": 0.6 40 | } 41 | ] 42 | } 43 | }, { 44 | "name": "statue", 45 | "type": "fresnel_blend", 46 | "ior": 1.5, 47 | "refr": "stone", 48 | "refl": { 49 | "type": "metal", 50 | "albedo": 1.0, 51 | "roughness": 0.1 52 | } 53 | }, { 54 | "type": "lambertian", 55 | "name": "Floor", 56 | "albedo": { 57 | "type": "checker", 58 | "even": [ 59 | 0.725, 0.71, 0.68 60 | ], 61 | "odd": [ 62 | 0.325, 0.31, 0.25 63 | ], 64 | "scale": 1.75, 65 | "transform": [ 66 | { 67 | "axis": [ 68 | 0, 1, 0 69 | ], 70 | "angle": 45 71 | }, { 72 | "translate": [0, -0.001, 0] 73 | } 74 | ] 75 | } 76 | } 77 | ], 78 | "surfaces": [ 79 | { 80 | "type": "mesh", 81 | "name": "ajax", 82 | "filename": "../assets/ajax.obj", 83 | "material": "statue", 84 | "transform": [ 85 | { 86 | "translate": [-0.053126335, 0.030193329, 17.283958] 87 | }, { 88 | "scale": 0.2 89 | }, { 90 | "axis": [ 91 | 0, 1, 0 92 | ], 93 | "angle": 150 94 | }, { 95 | "translate": [0, 0, -0.25] 96 | } 97 | ] 98 | }, { 99 | "type": "mesh", 100 | "name": "floor", 101 | "filename": "../assets/plane.obj", 102 | "transform": [ 103 | { 104 | "scale": [1000, 1, 1000] 105 | } 106 | ], 107 | "material": "Floor" 108 | } 109 | ] 110 | } 111 | -------------------------------------------------------------------------------- /scenes/assignment3/blend-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/blend-ref.png -------------------------------------------------------------------------------- /scenes/assignment3/checker-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/checker-ref.png -------------------------------------------------------------------------------- /scenes/assignment3/checker.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 5, 0, 0.6 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 1, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "materials": [ 25 | { 26 | "type": "lambertian", 27 | "name": "checker", 28 | "albedo": { 29 | "type": "checker", 30 | "even": [ 31 | 0.2, 0.3, 0.1 32 | ], 33 | "odd": [ 34 | 0.9, 0.9, 0.9 35 | ], 36 | "scale": 0.1 37 | } 38 | } 39 | ], 40 | "surfaces": [ 41 | { 42 | "type": "sphere", 43 | "material": "checker", 44 | "radius": 1, 45 | "transform": [ 46 | { 47 | "axis": [ 48 | 1, 0, 0 49 | ], 50 | "angle": 23.5 51 | }, { 52 | "axis": [ 53 | 0, 0, 1 54 | ], 55 | "angle": 50 56 | }, { 57 | "translate": [0, 0, 1] 58 | } 59 | ] 60 | }, { 61 | "type": "quad", 62 | "transform": { 63 | "translate": [0.0, 0.0, 0.01] 64 | }, 65 | "size": 100, 66 | "material": "checker" 67 | } 68 | ] 69 | } 70 | -------------------------------------------------------------------------------- /scenes/assignment3/constant-cornell-box-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/constant-cornell-box-ref.png -------------------------------------------------------------------------------- /scenes/assignment3/earth-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/earth-ref.png -------------------------------------------------------------------------------- /scenes/assignment3/earth.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 5, 0, 0.6 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 50 19 | }, 20 | "background": 1, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "materials": [ 25 | { 26 | "type": "lambertian", 27 | "name": "earth", 28 | "albedo": { 29 | "type": "image", 30 | "filename": "../assets/earth.jpg" 31 | } 32 | }, { 33 | "type": "lambertian", 34 | "name": "white", 35 | "albedo": 1 36 | } 37 | ], 38 | "surfaces": [ 39 | { 40 | "type": "sphere", 41 | "material": "earth", 42 | "radius": 1, 43 | "transform": [ 44 | { 45 | "axis": [ 46 | 1, 0, 0 47 | ], 48 | "angle": 23.5 49 | }, { 50 | "axis": [ 51 | 0, 0, 1 52 | ], 53 | "angle": 50 54 | }, { 55 | "translate": [0, 0, 1] 56 | } 57 | ] 58 | }, { 59 | "type": "quad", 60 | "transform": { 61 | "translate": [0, 0, 0] 62 | }, 63 | "size": 100, 64 | "material": "white" 65 | } 66 | ] 67 | } 68 | -------------------------------------------------------------------------------- /scenes/assignment3/fresnel_blend-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/fresnel_blend-ref.png -------------------------------------------------------------------------------- /scenes/assignment3/loewenfeld-textured-16spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/loewenfeld-textured-16spp.png -------------------------------------------------------------------------------- /scenes/assignment3/loewenfeld-textured-1spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/loewenfeld-textured-1spp.png -------------------------------------------------------------------------------- /scenes/assignment3/loewenfeld-textured-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/loewenfeld-textured-ref.png -------------------------------------------------------------------------------- /scenes/assignment3/loewenfeld-textured.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 24, 10, 0 6 | ], 7 | "at": [ 8 | 0, 3.5, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [720, 1280] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 1 19 | }, 20 | "background": 1, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "materials": [ 25 | { 26 | "type": "lambertian", 27 | "name": "stone", 28 | "albedo": { 29 | "type": "image", 30 | "filename": "../assets/loewenfeld/textures/albedo.jpg" 31 | } 32 | }, { 33 | "name": "statue", 34 | "type": "fresnel_blend", 35 | "ior": 1.5, 36 | "refr": "stone", 37 | "refl": { 38 | "type": "metal", 39 | "albedo": 1.0, 40 | "roughness": 0.1 41 | } 42 | }, { 43 | "type": "lambertian", 44 | "name": "Floor", 45 | "albedo": { 46 | "type": "checker", 47 | "even": [ 48 | 0.725, 0.71, 0.68 49 | ], 50 | "odd": [ 51 | 0.325, 0.31, 0.25 52 | ], 53 | "scale": 1.75, 54 | "transform": [ 55 | { 56 | "axis": [ 57 | 0, 1, 0 58 | ], 59 | "angle": 45 60 | }, { 61 | "translate": [0, -0.001, 0] 62 | } 63 | ] 64 | } 65 | } 66 | ], 67 | "surfaces": [ 68 | { 69 | "type": "quad", 70 | "transform": [ 71 | { 72 | "axis": [ 73 | 1, 0, 0 74 | ], 75 | "angle": -90 76 | }, { 77 | "axis": [ 78 | 0, 1, 0 79 | ], 80 | "angle": 45 81 | } 82 | ], 83 | "size": [ 84 | 150, 150 85 | ], 86 | "material": "Floor" 87 | }, { 88 | "type": "mesh", 89 | "filename": "../assets/loewenfeld/models/smoothed.obj", 90 | "transform": [ 91 | { 92 | "translate": [0, 222.3563, 0] 93 | }, { 94 | "scale": 0.014 95 | }, { 96 | "axis": [ 97 | 0, 1, 0 98 | ], 99 | "angle": 165 100 | } 101 | ], 102 | "material": "statue" 103 | } 104 | ] 105 | } 106 | -------------------------------------------------------------------------------- /scenes/assignment3/marble-128spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/marble-128spp.png -------------------------------------------------------------------------------- /scenes/assignment3/marble.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 1, 6, 1 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 128 19 | }, 20 | "background": [ 21 | 0.6, 0.6, 0.8 22 | ], 23 | "accelerator": { 24 | "type": "bbh" 25 | }, 26 | "materials": [ 27 | { 28 | "type": "lambertian", 29 | "name": "marble", 30 | "albedo": { 31 | "type": "marble", 32 | "scale": 2, 33 | "veins": 0, 34 | "base": 0.9 35 | } 36 | }, { 37 | "type": "lambertian", 38 | "name": "floor", 39 | "albedo": { 40 | "type": "marble", 41 | "scale": 3, 42 | "veins": [ 43 | 0.08, 0.1, 0.08 44 | ], 45 | "base": [0.38, 0.4, 0.38] 46 | } 47 | }, { 48 | "type": "diffuse_light", 49 | "name": "light", 50 | "emit": [10, 10, 8] 51 | }, { 52 | "type": "lambertian", 53 | "name": "white", 54 | "albedo": 1 55 | } 56 | ], 57 | "surfaces": [ 58 | { 59 | "type": "sphere", 60 | "material": "marble", 61 | "radius": 1, 62 | "transform": [ 63 | { 64 | "translate": [0, 0, 1] 65 | } 66 | ] 67 | }, { 68 | "type": "sphere", 69 | "material": "light", 70 | "radius": 2, 71 | "transform": [ 72 | { 73 | "translate": [-5, 1, 6] 74 | } 75 | ] 76 | }, { 77 | "type": "quad", 78 | "transform": { 79 | "translate": [0, 0, 0] 80 | }, 81 | "size": 100, 82 | "material": "floor" 83 | } 84 | ] 85 | } 86 | -------------------------------------------------------------------------------- /scenes/assignment3/nefertiti-textured-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/nefertiti-textured-ref.png -------------------------------------------------------------------------------- /scenes/assignment3/nefertiti-textured.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 24, 10, 0 6 | ], 7 | "at": [ 8 | 0, 3.5, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [720, 1280] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 16 19 | }, 20 | "background": 1, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "materials": [ 25 | { 26 | "type": "lambertian", 27 | "name": "aem_aem21300_3dsl01_mo08-03_p_img ", 28 | "albedo": { 29 | "type": "image", 30 | "filename": "../assets/nefertiti/albedo.png" 31 | } 32 | }, { 33 | "type": "lambertian", 34 | "name": "Floor", 35 | "albedo": { 36 | "type": "checker", 37 | "even": [ 38 | 0.725, 0.71, 0.68 39 | ], 40 | "odd": [ 41 | 0.325, 0.31, 0.25 42 | ], 43 | "scale": 1.75, 44 | "transform": [ 45 | { 46 | "axis": [ 47 | 0, 1, 0 48 | ], 49 | "angle": 45 50 | }, { 51 | "translate": [0, -0.001, 0] 52 | } 53 | ] 54 | } 55 | } 56 | ], 57 | "surfaces": [ 58 | { 59 | "type": "quad", 60 | "name": "floor", 61 | "transform": [ 62 | { 63 | "axis": [ 64 | 1, 0, 0 65 | ], 66 | "angle": -90 67 | }, { 68 | "axis": [ 69 | 0, 1, 0 70 | ], 71 | "angle": 45 72 | } 73 | ], 74 | "size": [ 75 | 150, 150 76 | ], 77 | "material": "Floor" 78 | }, { 79 | "type": "mesh", 80 | "name": "ajax", 81 | "filename": "../assets/nefertiti/aem_aem21300_3dsl01_mo08-03_p.obj", 82 | "transform": [ 83 | { 84 | "axis": [ 85 | 1, 0, 0 86 | ], 87 | "angle": -90 88 | }, { 89 | "translate": [413.7063, 226.50739, 86.24023] 90 | }, { 91 | "scale": 0.015 92 | }, { 93 | "axis": [ 94 | 0, 1, 0 95 | ], 96 | "angle": 115 97 | } 98 | ], 99 | "material": "aem_aem21300_3dsl01_mo08-03_p_img " 100 | } 101 | ] 102 | } 103 | -------------------------------------------------------------------------------- /scenes/assignment3/teapot-50spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/teapot-50spp.png -------------------------------------------------------------------------------- /scenes/assignment3/teapot-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/teapot-ref.png -------------------------------------------------------------------------------- /scenes/assignment3/textured-box-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment3/textured-box-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/ajax-ao-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/ajax-ao-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/ajax-ao.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | -65.6055, 47.5762, 24.3583 6 | ], 7 | "at": [ 8 | -64.8161, 47.2211, 23.8576 9 | ], 10 | "up": [0.299858, 0.934836, -0.190177] 11 | }, 12 | "vfov": 30, 13 | "fdist": 800, 14 | "resolution": [768, 768] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 100 19 | }, 20 | "background": 5, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "ao" 26 | }, 27 | "materials": [ 28 | { 29 | "type": "lambertian", 30 | "name": "white", 31 | "albedo": 1.0 32 | } 33 | ], 34 | "surfaces": [ 35 | { 36 | "type": "mesh", 37 | "name": "ajax", 38 | "filename": "../assets/ajax.obj", 39 | "material": "white" 40 | }, { 41 | "type": "mesh", 42 | "name": "floor", 43 | "filename": "../assets/plane.obj", 44 | "transform": [ 45 | { 46 | "scale": [1000, 1, 1000] 47 | } 48 | ], 49 | "material": "white" 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /scenes/assignment4/ajax-normals-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/ajax-normals-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/ajax-normals.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | -65.6055, 47.5762, 24.3583 6 | ], 7 | "at": [ 8 | -64.8161, 47.2211, 23.8576 9 | ], 10 | "up": [0.299858, 0.934836, -0.190177] 11 | }, 12 | "vfov": 30, 13 | "fdist": 800, 14 | "resolution": [768, 768] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 10 19 | }, 20 | "background": [ 21 | 0, 0, 0 22 | ], 23 | "accelerator": { 24 | "type": "bbh" 25 | }, 26 | "integrator": { 27 | "type": "normals" 28 | }, 29 | "materials": [ 30 | { 31 | "type": "lambertian", 32 | "name": "white", 33 | "albedo": 1.0 34 | } 35 | ], 36 | "surfaces": [ 37 | { 38 | "type": "mesh", 39 | "name": "ajax", 40 | "filename": "../assets/ajax.obj", 41 | "material": "white" 42 | }, { 43 | "type": "mesh", 44 | "name": "floor", 45 | "filename": "../assets/plane.obj", 46 | "transform": [ 47 | { 48 | "scale": [100, 1, 100] 49 | } 50 | ], 51 | "material": "white" 52 | } 53 | ] 54 | } 55 | -------------------------------------------------------------------------------- /scenes/assignment4/blinn_phong-pdf-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/blinn_phong-pdf-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/blinn_phong-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/blinn_phong-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/blinn_phong-rotated-pdf-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/blinn_phong-rotated-pdf-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/blinn_phong-rotated-sampled-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/blinn_phong-rotated-sampled-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/blinn_phong-sampled-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/blinn_phong-sampled-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/lambertian-pdf-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/lambertian-pdf-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/lambertian-rotated-pdf-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/lambertian-rotated-pdf-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/lambertian-rotated-sampled-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/lambertian-rotated-sampled-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/lambertian-sampled-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/lambertian-sampled-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/odyssey_mats-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/odyssey_mats-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/odyssey_mats.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 20, 20, 50 6 | ], 7 | "at": [ 8 | 0, 4, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [768, 432] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0.0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mats", 26 | "max_bounces": 1 27 | }, 28 | "surfaces": [ 29 | { 30 | "type": "mesh", 31 | "filename": "../assets/cube.obj", 32 | "name": "monolith", 33 | "transform": [ 34 | { 35 | "translate": [0, 0.5, 0] 36 | }, { 37 | "scale": [1, 9, 4] 38 | } 39 | ], 40 | "material": { 41 | "type": "lambertian", 42 | "albedo": 0.8 43 | } 44 | }, { 45 | "type": "quad", 46 | "name": "floor", 47 | "transform": [ 48 | { 49 | "y": [ 50 | 0, 0, -1 51 | ], 52 | "z": [0, 1, 0] 53 | } 54 | ], 55 | "size": [ 56 | 24, 18 57 | ], 58 | "material": { 59 | "type": "lambertian", 60 | "albedo": 0.95 61 | } 62 | }, { 63 | "type": "quad", 64 | "name": "glowing wall", 65 | "transform": [ 66 | { 67 | "translate": [0, 5, 0] 68 | }, { 69 | "x": [ 70 | 0, 0, 1 71 | ], 72 | "y": [ 73 | 0, 1, 0 74 | ], 75 | "z": [1, 0, 0] 76 | }, { 77 | "translate": [-12, 0, 0] 78 | } 79 | ], 80 | "size": [ 81 | 18, 10 82 | ], 83 | "material": { 84 | "type": "diffuse_light", 85 | "emit": 1 86 | } 87 | } 88 | ] 89 | } 90 | -------------------------------------------------------------------------------- /scenes/assignment4/phong-pdf-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/phong-pdf-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/phong-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/phong-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/phong-rotated-pdf-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/phong-rotated-pdf-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/phong-rotated-sampled-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/phong-rotated-sampled-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/phong-sampled-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/phong-sampled-ref.png -------------------------------------------------------------------------------- /scenes/assignment4/test_materials.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "tests", 3 | "tests": [ 4 | { 5 | "type": "sample_material", 6 | "material": { 7 | "type": "lambertian", 8 | "albedo": 1.0 9 | }, 10 | "normal": [ 11 | 0, 0, 1 12 | ], 13 | "name": "lambertian" 14 | }, 15 | { 16 | "type": "sample_material", 17 | "material": { 18 | "type": "lambertian", 19 | "albedo": 1.0 20 | }, 21 | "normal": [ 22 | 0.25, 0.5, 1.0 23 | ], 24 | "name": "lambertian-rotated" 25 | }, 26 | { 27 | "type": "sample_material", 28 | "material": { 29 | "type": "phong", 30 | "albedo": 1.0, 31 | "exponent": 2 32 | }, 33 | "normal": [ 34 | 0, 0, 1 35 | ], 36 | "name": "phong" 37 | }, 38 | { 39 | "type": "sample_material", 40 | "material": { 41 | "type": "phong", 42 | "albedo": 1.0, 43 | "exponent": 2 44 | }, 45 | "normal": [ 46 | 0.25, 0.5, 1.0 47 | ], 48 | "name": "phong-rotated" 49 | }, { 50 | "type": "sample_material", 51 | "material": { 52 | "type": "blinn_phong", 53 | "albedo": 1.0, 54 | "exponent": 10 55 | }, 56 | "normal": [ 57 | 0, 0, 1 58 | ], 59 | "name": "blinn_phong" 60 | }, { 61 | "type": "sample_material", 62 | "material": { 63 | "type": "blinn_phong", 64 | "albedo": 1.0, 65 | "exponent": 10 66 | }, 67 | "normal": [ 68 | 0.25, 0.5, 1.0 69 | ], 70 | "name": "blinn_phong-rotated" 71 | } 72 | ] 73 | } 74 | -------------------------------------------------------------------------------- /scenes/assignment4/veach_mats-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment4/veach_mats-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/group-pdf-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/group-pdf-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/group-sampled-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/group-sampled-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/jensen_box_mats-64spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/jensen_box_mats-64spp.png -------------------------------------------------------------------------------- /scenes/assignment5/jensen_box_mats-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/jensen_box_mats-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/jensen_box_mis-64spp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/jensen_box_mis-64spp.png -------------------------------------------------------------------------------- /scenes/assignment5/jensen_box_mis-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/jensen_box_mis-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/jensen_box_nee-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/jensen_box_nee-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/odyssey_mis-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/odyssey_mis-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/odyssey_mis.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 20, 20, 50 6 | ], 7 | "at": [ 8 | 0, 4, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [768, 432] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0.0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mis", 26 | "max_bounces": 1 27 | }, 28 | "surfaces": [ 29 | { 30 | "type": "mesh", 31 | "filename": "../assets/cube.obj", 32 | "name": "monolith", 33 | "transform": [ 34 | { 35 | "translate": [0, 0.5, 0] 36 | }, { 37 | "scale": [1, 9, 4] 38 | } 39 | ], 40 | "material": { 41 | "type": "lambertian", 42 | "albedo": 0.8 43 | } 44 | }, { 45 | "type": "quad", 46 | "name": "floor", 47 | "transform": [ 48 | { 49 | "y": [ 50 | 0, 0, -1 51 | ], 52 | "z": [0, 1, 0] 53 | } 54 | ], 55 | "size": [ 56 | 24, 18 57 | ], 58 | "material": { 59 | "type": "lambertian", 60 | "albedo": 0.95 61 | } 62 | }, { 63 | "type": "quad", 64 | "name": "glowing wall", 65 | "transform": [ 66 | { 67 | "translate": [0, 5, 0] 68 | }, { 69 | "x": [ 70 | 0, 0, 1 71 | ], 72 | "y": [ 73 | 0, 1, 0 74 | ], 75 | "z": [1, 0, 0] 76 | }, { 77 | "translate": [-12, 0, 0] 78 | } 79 | ], 80 | "size": [ 81 | 18, 10 82 | ], 83 | "material": { 84 | "type": "diffuse_light", 85 | "emit": 1 86 | } 87 | } 88 | ] 89 | } 90 | -------------------------------------------------------------------------------- /scenes/assignment5/odyssey_nee-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/odyssey_nee-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/odyssey_nee.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 20, 20, 50 6 | ], 7 | "at": [ 8 | 0, 4, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [768, 432] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0.0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_nee", 26 | "max_bounces": 1 27 | }, 28 | "surfaces": [ 29 | { 30 | "type": "mesh", 31 | "filename": "../assets/cube.obj", 32 | "name": "monolith", 33 | "transform": [ 34 | { 35 | "translate": [0, 0.5, 0] 36 | }, { 37 | "scale": [1, 9, 4] 38 | } 39 | ], 40 | "material": { 41 | "type": "lambertian", 42 | "albedo": 0.8 43 | } 44 | }, { 45 | "type": "quad", 46 | "name": "floor", 47 | "transform": [ 48 | { 49 | "y": [ 50 | 0, 0, -1 51 | ], 52 | "z": [0, 1, 0] 53 | } 54 | ], 55 | "size": [ 56 | 24, 18 57 | ], 58 | "material": { 59 | "type": "lambertian", 60 | "albedo": 0.95 61 | } 62 | }, { 63 | "type": "quad", 64 | "name": "glowing wall", 65 | "transform": [ 66 | { 67 | "translate": [0, 5, 0] 68 | }, { 69 | "x": [ 70 | 0, 0, 1 71 | ], 72 | "y": [ 73 | 0, 1, 0 74 | ], 75 | "z": [1, 0, 0] 76 | }, { 77 | "translate": [-12, 0, 0] 78 | } 79 | ], 80 | "size": [ 81 | 18, 10 82 | ], 83 | "material": { 84 | "type": "diffuse_light", 85 | "emit": 1 86 | } 87 | } 88 | ] 89 | } 90 | -------------------------------------------------------------------------------- /scenes/assignment5/odyssey_triangle_mats-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/odyssey_triangle_mats-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/odyssey_triangle_mats.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 20, 20, 50 6 | ], 7 | "at": [ 8 | 0, 4, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [768, 432] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0.0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mats", 26 | "max_bounces": 1 27 | }, 28 | "surfaces": [ 29 | { 30 | "type": "mesh", 31 | "filename": "../assets/cube.obj", 32 | "name": "monolith", 33 | "transform": [ 34 | { 35 | "translate": [0, 0.5, 0] 36 | }, { 37 | "scale": [1, 9, 4] 38 | } 39 | ], 40 | "material": { 41 | "type": "lambertian", 42 | "albedo": 0.8 43 | } 44 | }, { 45 | "type": "quad", 46 | "name": "floor", 47 | "transform": [ 48 | { 49 | "y": [ 50 | 0, 0, -1 51 | ], 52 | "z": [0, 1, 0] 53 | } 54 | ], 55 | "size": [ 56 | 24, 18 57 | ], 58 | "material": { 59 | "type": "lambertian", 60 | "albedo": 0.95 61 | } 62 | }, { 63 | "type": "triangle", 64 | "name": "glowing wall1", 65 | "positions": [ 66 | [ 67 | -12, 0, 9 68 | ], 69 | [ 70 | -12, 0, -9 71 | ], 72 | [ 73 | -12, 10, -9 74 | ] 75 | ], 76 | "material": { 77 | "type": "diffuse_light", 78 | "emit": 1 79 | } 80 | }, { 81 | "type": "triangle", 82 | "name": "glowing wall2", 83 | "positions": [ 84 | [ 85 | -12, 0, 9 86 | ], 87 | [ 88 | -12, 10, -9 89 | ], 90 | [ 91 | -12, 10, 9 92 | ] 93 | ], 94 | "material": { 95 | "type": "diffuse_light", 96 | "emit": 1 97 | } 98 | } 99 | ] 100 | } 101 | -------------------------------------------------------------------------------- /scenes/assignment5/odyssey_triangle_mis-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/odyssey_triangle_mis-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/odyssey_triangle_mis.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 20, 20, 50 6 | ], 7 | "at": [ 8 | 0, 4, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [768, 432] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0.0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mis", 26 | "max_bounces": 1 27 | }, 28 | "surfaces": [ 29 | { 30 | "type": "mesh", 31 | "filename": "../assets/cube.obj", 32 | "name": "monolith", 33 | "transform": [ 34 | { 35 | "translate": [0, 0.5, 0] 36 | }, { 37 | "scale": [1, 9, 4] 38 | } 39 | ], 40 | "material": { 41 | "type": "lambertian", 42 | "albedo": 0.8 43 | } 44 | }, { 45 | "type": "quad", 46 | "name": "floor", 47 | "transform": [ 48 | { 49 | "y": [ 50 | 0, 0, -1 51 | ], 52 | "z": [0, 1, 0] 53 | } 54 | ], 55 | "size": [ 56 | 24, 18 57 | ], 58 | "material": { 59 | "type": "lambertian", 60 | "albedo": 0.95 61 | } 62 | }, { 63 | "type": "triangle", 64 | "name": "glowing wall1", 65 | "positions": [ 66 | [ 67 | -12, 0, 9 68 | ], 69 | [ 70 | -12, 0, -9 71 | ], 72 | [ 73 | -12, 10, -9 74 | ] 75 | ], 76 | "material": { 77 | "type": "diffuse_light", 78 | "emit": 1 79 | } 80 | }, { 81 | "type": "triangle", 82 | "name": "glowing wall2", 83 | "positions": [ 84 | [ 85 | -12, 0, 9 86 | ], 87 | [ 88 | -12, 10, -9 89 | ], 90 | [ 91 | -12, 10, 9 92 | ] 93 | ], 94 | "material": { 95 | "type": "diffuse_light", 96 | "emit": 1 97 | } 98 | } 99 | ] 100 | } 101 | -------------------------------------------------------------------------------- /scenes/assignment5/odyssey_triangle_nee-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/odyssey_triangle_nee-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/odyssey_triangle_nee.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 20, 20, 50 6 | ], 7 | "at": [ 8 | 0, 4, 0 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 20, 13 | "fdist": 800, 14 | "resolution": [768, 432] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0.0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_nee", 26 | "max_bounces": 1 27 | }, 28 | "surfaces": [ 29 | { 30 | "type": "mesh", 31 | "filename": "../assets/cube.obj", 32 | "name": "monolith", 33 | "transform": [ 34 | { 35 | "translate": [0, 0.5, 0] 36 | }, { 37 | "scale": [1, 9, 4] 38 | } 39 | ], 40 | "material": { 41 | "type": "lambertian", 42 | "albedo": 0.8 43 | } 44 | }, { 45 | "type": "quad", 46 | "name": "floor", 47 | "transform": [ 48 | { 49 | "y": [ 50 | 0, 0, -1 51 | ], 52 | "z": [0, 1, 0] 53 | } 54 | ], 55 | "size": [ 56 | 24, 18 57 | ], 58 | "material": { 59 | "type": "lambertian", 60 | "albedo": 0.95 61 | } 62 | }, { 63 | "type": "triangle", 64 | "name": "glowing wall1", 65 | "positions": [ 66 | [ 67 | -12, 0, 9 68 | ], 69 | [ 70 | -12, 0, -9 71 | ], 72 | [ 73 | -12, 10, -9 74 | ] 75 | ], 76 | "material": { 77 | "type": "diffuse_light", 78 | "emit": 1 79 | } 80 | }, { 81 | "type": "triangle", 82 | "name": "glowing wall2", 83 | "positions": [ 84 | [ 85 | -12, 0, 9 86 | ], 87 | [ 88 | -12, 10, -9 89 | ], 90 | [ 91 | -12, 10, 9 92 | ] 93 | ], 94 | "material": { 95 | "type": "diffuse_light", 96 | "emit": 1 97 | } 98 | } 99 | ] 100 | } 101 | -------------------------------------------------------------------------------- /scenes/assignment5/quad-pdf-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/quad-pdf-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/quad-sampled-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/quad-sampled-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere-pdf-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere-pdf-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere-sampled-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere-sampled-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_large-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_large-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_large_mats-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_large_mats-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_large_mats.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 3, 0, 0.25 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mats", 26 | "max_bounces": 1 27 | }, 28 | "materials": [ 29 | { 30 | "type": "diffuse_light", 31 | "name": "light", 32 | "emit": 1 33 | }, { 34 | "type": "lambertian", 35 | "name": "white", 36 | "albedo": 1 37 | } 38 | ], 39 | "surfaces": [ 40 | { 41 | "type": "sphere", 42 | "material": "light", 43 | "radius": 1, 44 | "transform": { 45 | "translate": [0, 0, 1] 46 | } 47 | }, { 48 | "type": "quad", 49 | "transform": { 50 | "translate": [0, 0, 0] 51 | }, 52 | "size": 100, 53 | "material": "white" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_large_mis-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_large_mis-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_large_mis.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 3, 0, 0.25 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mis", 26 | "max_bounces": 1 27 | }, 28 | "materials": [ 29 | { 30 | "type": "diffuse_light", 31 | "name": "light", 32 | "emit": 1 33 | }, { 34 | "type": "lambertian", 35 | "name": "white", 36 | "albedo": 1 37 | } 38 | ], 39 | "surfaces": [ 40 | { 41 | "type": "sphere", 42 | "material": "light", 43 | "radius": 1, 44 | "transform": { 45 | "translate": [0, 0, 1] 46 | } 47 | }, { 48 | "type": "quad", 49 | "transform": { 50 | "translate": [0, 0, 0] 51 | }, 52 | "size": 100, 53 | "material": "white" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_large_nee-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_large_nee-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_large_nee.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 3, 0, 0.25 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_nee", 26 | "max_bounces": 1 27 | }, 28 | "materials": [ 29 | { 30 | "type": "diffuse_light", 31 | "name": "light", 32 | "emit": 1 33 | }, { 34 | "type": "lambertian", 35 | "name": "white", 36 | "albedo": 1 37 | } 38 | ], 39 | "surfaces": [ 40 | { 41 | "type": "sphere", 42 | "material": "light", 43 | "radius": 1, 44 | "transform": { 45 | "translate": [0, 0, 1] 46 | } 47 | }, { 48 | "type": "quad", 49 | "transform": { 50 | "translate": [0, 0, 0] 51 | }, 52 | "size": 100, 53 | "material": "white" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_medium-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_medium-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_medium_mats-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_medium_mats-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_medium_mats.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 3, 0, 0.25 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mats", 26 | "max_bounces": 1 27 | }, 28 | "materials": [ 29 | { 30 | "type": "diffuse_light", 31 | "name": "light", 32 | "emit": 4 33 | }, { 34 | "type": "lambertian", 35 | "name": "white", 36 | "albedo": 1 37 | } 38 | ], 39 | "surfaces": [ 40 | { 41 | "type": "sphere", 42 | "material": "light", 43 | "radius": 0.5, 44 | "transform": { 45 | "translate": [0, 0, 1] 46 | } 47 | }, { 48 | "type": "quad", 49 | "transform": { 50 | "translate": [0, 0, 0] 51 | }, 52 | "size": 100, 53 | "material": "white" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_medium_mis-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_medium_mis-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_medium_mis.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 3, 0, 0.25 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mis", 26 | "max_bounces": 1 27 | }, 28 | "materials": [ 29 | { 30 | "type": "diffuse_light", 31 | "name": "light", 32 | "emit": 4 33 | }, { 34 | "type": "lambertian", 35 | "name": "white", 36 | "albedo": 1 37 | } 38 | ], 39 | "surfaces": [ 40 | { 41 | "type": "sphere", 42 | "material": "light", 43 | "radius": 0.5, 44 | "transform": { 45 | "translate": [0, 0, 1] 46 | } 47 | }, { 48 | "type": "quad", 49 | "transform": { 50 | "translate": [0, 0, 0] 51 | }, 52 | "size": 100, 53 | "material": "white" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_medium_nee-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_medium_nee-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_medium_nee.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 3, 0, 0.25 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_nee", 26 | "max_bounces": 1 27 | }, 28 | "materials": [ 29 | { 30 | "type": "diffuse_light", 31 | "name": "light", 32 | "emit": 4 33 | }, { 34 | "type": "lambertian", 35 | "name": "white", 36 | "albedo": 1 37 | } 38 | ], 39 | "surfaces": [ 40 | { 41 | "type": "sphere", 42 | "material": "light", 43 | "radius": 0.5, 44 | "transform": { 45 | "translate": [0, 0, 1] 46 | } 47 | }, { 48 | "type": "quad", 49 | "transform": { 50 | "translate": [0, 0, 0] 51 | }, 52 | "size": 100, 53 | "material": "white" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_small-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_small-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_small_mats-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_small_mats-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_small_mats.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 3, 0, 0.25 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mats", 26 | "max_bounces": 1 27 | }, 28 | "materials": [ 29 | { 30 | "type": "diffuse_light", 31 | "name": "light", 32 | "emit": 64 33 | }, { 34 | "type": "lambertian", 35 | "name": "white", 36 | "albedo": 1 37 | } 38 | ], 39 | "surfaces": [ 40 | { 41 | "type": "sphere", 42 | "material": "light", 43 | "radius": 0.125, 44 | "transform": { 45 | "translate": [0, 0, 1] 46 | } 47 | }, { 48 | "type": "quad", 49 | "transform": { 50 | "translate": [0, 0, 0] 51 | }, 52 | "size": 100, 53 | "material": "white" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_small_mis-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_small_mis-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_small_mis.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 3, 0, 0.25 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mis", 26 | "max_bounces": 1 27 | }, 28 | "materials": [ 29 | { 30 | "type": "diffuse_light", 31 | "name": "light", 32 | "emit": 64 33 | }, { 34 | "type": "lambertian", 35 | "name": "white", 36 | "albedo": 1 37 | } 38 | ], 39 | "surfaces": [ 40 | { 41 | "type": "sphere", 42 | "material": "light", 43 | "radius": 0.125, 44 | "transform": { 45 | "translate": [0, 0, 1] 46 | } 47 | }, { 48 | "type": "quad", 49 | "transform": { 50 | "translate": [0, 0, 0] 51 | }, 52 | "size": 100, 53 | "material": "white" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_small_nee-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/sphere_light_small_nee-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/sphere_light_small_nee.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 3, 0, 0.25 6 | ], 7 | "at": [ 8 | 0, 0, 0.5 9 | ], 10 | "up": [0, 0, 1] 11 | }, 12 | "vfov": 40, 13 | "fdist": 6, 14 | "resolution": [512, 512] 15 | }, 16 | "sampler": { 17 | "type": "independent", 18 | "samples": 64 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_nee", 26 | "max_bounces": 1 27 | }, 28 | "materials": [ 29 | { 30 | "type": "diffuse_light", 31 | "name": "light", 32 | "emit": 64 33 | }, { 34 | "type": "lambertian", 35 | "name": "white", 36 | "albedo": 1 37 | } 38 | ], 39 | "surfaces": [ 40 | { 41 | "type": "sphere", 42 | "material": "light", 43 | "radius": 0.125, 44 | "transform": { 45 | "translate": [0, 0, 1] 46 | } 47 | }, { 48 | "type": "quad", 49 | "transform": { 50 | "translate": [0, 0, 0] 51 | }, 52 | "size": 100, 53 | "material": "white" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /scenes/assignment5/triangle-pdf-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/triangle-pdf-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/triangle-sampled-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/triangle-sampled-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/veach_mis-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/veach_mis-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/veach_mis.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 0, 6, 27.5 6 | ], 7 | "at": [ 8 | 0, -1.5, 2.5 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 16, 13 | "fdist": 800, 14 | "resolution": [768, 512] 15 | }, 16 | "sampler": { 17 | "type": "cmj", 18 | "samples": 32 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_mis", 26 | "max_bounces": 1 27 | }, 28 | "surfaces": [ 29 | { 30 | "type": "sphere", 31 | "material": { 32 | "type": "diffuse_light", 33 | "emit": 901.803 34 | }, 35 | "transform": [ 36 | { 37 | "scale": [0.03333, 0.03333, 0.03333] 38 | }, { 39 | "translate": [3.75, 0, 0] 40 | } 41 | ] 42 | }, 43 | { 44 | "type": "sphere", 45 | "material": { 46 | "type": "diffuse_light", 47 | "emit": 100 48 | }, 49 | "transform": [ 50 | { 51 | "scale": [0.1, 0.1, 0.1] 52 | }, { 53 | "translate": [1.25, 0, 0] 54 | } 55 | ] 56 | }, 57 | { 58 | "type": "sphere", 59 | "material": { 60 | "type": "diffuse_light", 61 | "emit": 11.1111 62 | }, 63 | "transform": [ 64 | { 65 | "scale": [0.3, 0.3, 0.3] 66 | }, { 67 | "translate": [-1.25, 0, 0] 68 | } 69 | ] 70 | }, 71 | { 72 | "type": "sphere", 73 | "material": { 74 | "type": "diffuse_light", 75 | "emit": 1.23457 76 | }, 77 | "transform": [ 78 | { 79 | "scale": [0.9, 0.9, 0.9] 80 | }, { 81 | "translate": [-3.75, 0, 0] 82 | } 83 | ] 84 | }, { 85 | "type": "mesh", 86 | "filename": "../assets/veach/plate1.obj", 87 | "material": { 88 | "type": "phong", 89 | "albedo": 0.35, 90 | "exponent": 100000 91 | } 92 | }, { 93 | "type": "mesh", 94 | "filename": "../assets/veach/plate2.obj", 95 | "material": { 96 | "type": "phong", 97 | "albedo": 0.25, 98 | "exponent": 5000 99 | } 100 | }, { 101 | "type": "mesh", 102 | "filename": "../assets/veach/plate3.obj", 103 | "material": { 104 | "type": "phong", 105 | "albedo": 0.2, 106 | "exponent": 400 107 | } 108 | }, { 109 | "type": "mesh", 110 | "filename": "../assets/veach/plate4.obj", 111 | "material": { 112 | "type": "phong", 113 | "albedo": 0.2, 114 | "exponent": 100 115 | } 116 | }, { 117 | "type": "mesh", 118 | "filename": "../assets/veach/floor.obj", 119 | "material": { 120 | "type": "lambertian", 121 | "albedo": [0.2, 0.2, 0.2] 122 | } 123 | } 124 | ] 125 | } 126 | -------------------------------------------------------------------------------- /scenes/assignment5/veach_mixture-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/veach_mixture-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/veach_nee-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cs87-dartmouth/Fall2021/699e8e54b048c7c7396fdbcdc445d1c345fc453d/scenes/assignment5/veach_nee-ref.png -------------------------------------------------------------------------------- /scenes/assignment5/veach_nee.json: -------------------------------------------------------------------------------- 1 | { 2 | "camera": { 3 | "transform": { 4 | "from": [ 5 | 0, 6, 27.5 6 | ], 7 | "at": [ 8 | 0, -1.5, 2.5 9 | ], 10 | "up": [0, 1, 0] 11 | }, 12 | "vfov": 16, 13 | "fdist": 800, 14 | "resolution": [768, 512] 15 | }, 16 | "sampler": { 17 | "type": "cmj", 18 | "samples": 64 19 | }, 20 | "background": 0, 21 | "accelerator": { 22 | "type": "bbh" 23 | }, 24 | "integrator": { 25 | "type": "path_tracer_nee", 26 | "max_bounces": 1 27 | }, 28 | "surfaces": [ 29 | { 30 | "type": "sphere", 31 | "material": { 32 | "type": "diffuse_light", 33 | "emit": 901.803 34 | }, 35 | "transform": [ 36 | { 37 | "scale": [0.03333, 0.03333, 0.03333] 38 | }, { 39 | "translate": [3.75, 0, 0] 40 | } 41 | ] 42 | }, 43 | { 44 | "type": "sphere", 45 | "material": { 46 | "type": "diffuse_light", 47 | "emit": 100 48 | }, 49 | "transform": [ 50 | { 51 | "scale": [0.1, 0.1, 0.1] 52 | }, { 53 | "translate": [1.25, 0, 0] 54 | } 55 | ] 56 | }, 57 | { 58 | "type": "sphere", 59 | "material": { 60 | "type": "diffuse_light", 61 | "emit": 11.1111 62 | }, 63 | "transform": [ 64 | { 65 | "scale": [0.3, 0.3, 0.3] 66 | }, { 67 | "translate": [-1.25, 0, 0] 68 | } 69 | ] 70 | }, 71 | { 72 | "type": "sphere", 73 | "material": { 74 | "type": "diffuse_light", 75 | "emit": 1.23457 76 | }, 77 | "transform": [ 78 | { 79 | "scale": [0.9, 0.9, 0.9] 80 | }, { 81 | "translate": [-3.75, 0, 0] 82 | } 83 | ] 84 | }, { 85 | "type": "mesh", 86 | "filename": "../assets/veach/plate1.obj", 87 | "material": { 88 | "type": "phong", 89 | "albedo": 0.35, 90 | "exponent": 100000 91 | } 92 | }, { 93 | "type": "mesh", 94 | "filename": "../assets/veach/plate2.obj", 95 | "material": { 96 | "type": "phong", 97 | "albedo": 0.25, 98 | "exponent": 5000 99 | } 100 | }, { 101 | "type": "mesh", 102 | "filename": "../assets/veach/plate3.obj", 103 | "material": { 104 | "type": "phong", 105 | "albedo": 0.2, 106 | "exponent": 400 107 | } 108 | }, { 109 | "type": "mesh", 110 | "filename": "../assets/veach/plate4.obj", 111 | "material": { 112 | "type": "phong", 113 | "albedo": 0.2, 114 | "exponent": 100 115 | } 116 | }, { 117 | "type": "mesh", 118 | "filename": "../assets/veach/floor.obj", 119 | "material": { 120 | "type": "lambertian", 121 | "albedo": [0.2, 0.2, 0.2] 122 | } 123 | } 124 | ] 125 | } 126 | -------------------------------------------------------------------------------- /setup-discovery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | module load cmake/3.21 4 | module load git/2.0.4 5 | scl enable devtoolset-9 bash -------------------------------------------------------------------------------- /src/img_avg.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /*! 12 | Average a sequence of images 13 | */ 14 | int main(int argc, char **argv) 15 | { 16 | string outfile; 17 | vector infiles; 18 | int verbosity = spdlog::get_level(); 19 | 20 | CLI::App app{"\nAverage a sequence of images and save the result to a new file."}; 21 | 22 | app.get_formatter()->column_width(35); 23 | 24 | string save_formats = fmt::format("{}", fmt::join(Image3f::savable_formats(), ", ")); 25 | 26 | app.add_option("-o,--outfile", outfile, 27 | fmt::format("Specify the output image filename (extension must be one of: {})", save_formats)); 28 | app.add_option("infiles", infiles, "The files to read in and average.")->required()->check(CLI::ExistingFile); 29 | app.add_option("-v,--verbosity", verbosity, 30 | R"(Set verbosity threshold T with lower values meaning more verbose 31 | and higher values removing low-priority messages. All messages with 32 | severity >= T are displayed, where the severities are: 33 | trace = 0 34 | debug = 1 35 | info = 2 36 | warn = 3 37 | err = 4 38 | critical = 5 39 | off = 6 40 | The default is 2 (info).)") 41 | ->check(CLI::Range(0, 6)); 42 | 43 | try 44 | { 45 | CLI11_PARSE(app, argc, argv); 46 | 47 | darts_init(verbosity); 48 | 49 | spdlog::info("Averaging {} images.", infiles.size()); 50 | 51 | Image3f average; 52 | if (!average.load(infiles[0])) 53 | throw DartsException("Cannot load image \"{}\".", infiles[0]); 54 | 55 | average.reset(Color3f(0.f)); 56 | 57 | for (int i = 0; i < infiles.size(); ++i) 58 | { 59 | Image3f image; 60 | if (!image.load(infiles[i])) 61 | throw DartsException("Cannot load image {}: \"{}\".", i, infiles[i]); 62 | 63 | if (image.width() != average.width() || image.height() != average.height()) 64 | throw DartsException("Image dimensions don't match. \"{}\" : ({}x{}) vs. \"{}\" ({}x{}).", infiles[0], 65 | average.width(), average.height(), infiles[i], image.width(), image.height()); 66 | 67 | for (auto y : range(average.height())) 68 | for (auto x : range(average.width())) 69 | average(x, y) += image(x, y); 70 | } 71 | 72 | for (auto y : range(average.height())) 73 | for (auto x : range(average.width())) 74 | average(x, y) /= float(infiles.size()); 75 | 76 | if (!outfile.empty()) 77 | { 78 | spdlog::info("Writing average image to '{}'.", outfile); 79 | average.save(outfile); 80 | } 81 | } 82 | catch (const std::exception &e) 83 | { 84 | spdlog::error("{}", e.what()); 85 | exit(EXIT_FAILURE); 86 | } 87 | 88 | exit(EXIT_SUCCESS); 89 | } 90 | -------------------------------------------------------------------------------- /src/materials/dielectric.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /// A smooth dielectric surface that reflects and refracts light according to the specified index of refraction #ior 12 | class Dielectric : public Material 13 | { 14 | public: 15 | Dielectric(const json &j = json::object()); 16 | 17 | bool scatter(const Ray3f &ray, const HitInfo &hit, Color3f &attenuation, Ray3f &scattered) const override; 18 | 19 | 20 | float ior; ///< The (relative) index of refraction of the material 21 | }; 22 | 23 | 24 | Dielectric::Dielectric(const json &j) : Material(j) 25 | { 26 | ior = j.value("ior", ior); 27 | } 28 | 29 | bool Dielectric::scatter(const Ray3f &ray, const HitInfo &hit, Color3f &attenuation, Ray3f &scattered) const 30 | { 31 | // TODO: Implement dielectric scattering 32 | return false; 33 | } 34 | 35 | 36 | DARTS_REGISTER_CLASS_IN_FACTORY(Material, Dielectric, "dielectric") 37 | -------------------------------------------------------------------------------- /src/materials/diffuse_light.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /// A material that emits light equally in all directions from the front side of a surface. 12 | class DiffuseLight : public Material 13 | { 14 | public: 15 | DiffuseLight(const json &j = json::object()); 16 | 17 | /// Returns a constant Color3f if the ray hits the surface on the front side. 18 | Color3f emitted(const Ray3f &ray, const HitInfo &hit) const override; 19 | 20 | bool is_emissive() const override 21 | { 22 | return true; 23 | } 24 | 25 | 26 | Color3f emit; ///< The emissive color of the light 27 | }; 28 | 29 | DiffuseLight::DiffuseLight(const json &j) : Material(j) 30 | { 31 | emit = j.value("emit", emit); 32 | } 33 | 34 | Color3f DiffuseLight::emitted(const Ray3f &ray, const HitInfo &hit) const 35 | { 36 | // only emit from the normal-facing side 37 | if (dot(ray.d, hit.sn) > 0) 38 | return Color3f(0, 0, 0); 39 | else 40 | return emit; 41 | } 42 | 43 | 44 | DARTS_REGISTER_CLASS_IN_FACTORY(Material, DiffuseLight, "diffuse_light") 45 | -------------------------------------------------------------------------------- /src/materials/lambertian.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | Lambertian::Lambertian(const json &j) : Material(j) 12 | { 13 | albedo = j.value("albedo", albedo); 14 | } 15 | 16 | bool Lambertian::scatter(const Ray3f &ray, const HitInfo &hit, Color3f &attenuation, Ray3f &scattered) const 17 | { 18 | // TODO: Implement Lambertian reflection 19 | // You should assign the albedo to ``attenuation'', and 20 | // you should assign the scattered ray to ``scattered'' 21 | // The origin of the scattered ray should be at the hit point, 22 | // and the scattered direction is the shading normal plus a random 23 | // point on a sphere (please look at the text book for this) 24 | 25 | // You can get the hit point using hit.p, and the shading normal using hit.sn 26 | 27 | // Hint: You can use the function random_in_unit_sphere() to get a random 28 | // point in a sphere. IMPORTANT: You want to add a random point *on* 29 | // a sphere, not *in* the sphere (the text book gets this wrong) 30 | // If you normalize the point, you can force it to be on the sphere always, so 31 | // add normalize(random_in_unit_sphere()) to your shading normal 32 | return false; 33 | } 34 | 35 | 36 | DARTS_REGISTER_CLASS_IN_FACTORY(Material, Lambertian, "lambertian") 37 | -------------------------------------------------------------------------------- /src/materials/material.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | Material::Material(const json &j) 14 | { 15 | } 16 | -------------------------------------------------------------------------------- /src/materials/metal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | /// A metallic material that reflects light into the (potentially rough) mirror reflection direction. 12 | class Metal : public Material 13 | { 14 | public: 15 | Metal(const json &j = json::object()); 16 | 17 | bool scatter(const Ray3f &ray, const HitInfo &hit, Color3f &attenuation, Ray3f &scattered) const override; 18 | 19 | 20 | Color3f albedo = Color3f(0.8f); ///< The reflective color (fraction of light that is reflected per color channel). 21 | float roughness = 0.f; ///< A value between 0 and 1 indicating how smooth vs. rough the reflection should be. 22 | }; 23 | 24 | inline bool refract(const Vec3f &v, const Vec3f &n, float iorIOverT, Vec3f &refracted) 25 | { 26 | Vec3f uv = normalize(v); 27 | float dt = dot(uv, n); 28 | float discrim = 1.0f - iorIOverT * iorIOverT * (1.0f - dt * dt); 29 | if (discrim > 0) 30 | { 31 | refracted = iorIOverT * (uv - n * dt) - n * std::sqrt(discrim); 32 | return true; 33 | } 34 | else 35 | return false; 36 | } 37 | 38 | inline Vec3f reflect(const Vec3f &v, const Vec3f &n) 39 | { 40 | return v - 2 * dot(v, n) * n; 41 | } 42 | 43 | Metal::Metal(const json &j) : Material(j) 44 | { 45 | albedo = j.value("albedo", albedo); 46 | roughness = clamp(j.value("roughness", roughness), 0.f, 1.f); 47 | } 48 | 49 | bool Metal::scatter(const Ray3f &ray, const HitInfo &hit, Color3f &attenuation, Ray3f &scattered) const 50 | { 51 | // TODO: Implement metal reflection 52 | // This function proceeds similar to the lambertian material, except that the 53 | // scattered direction is different. 54 | // Instead of adding a point on a sphere to the normal as before, you should add the point 55 | // to the *reflected ray direction*. 56 | // You can reflect a vector by the normal using reflect(vector, hit.sn); make sure the vector is normalized. 57 | // Unlike before you can't just use random_in_unit_sphere directly; the sphere should be scaled by 58 | // roughness. (see text book). In other words, if roughness is 0, the scattered direction should just be the 59 | // reflected direction. 60 | // 61 | // This procedure could produce directions below the surface. Handle this by returning false if the scattered 62 | // direction and the shading normal point in different directions (i.e. their dot product is negative) 63 | return false; 64 | } 65 | 66 | 67 | DARTS_REGISTER_CLASS_IN_FACTORY(Material, Metal, "metal") 68 | -------------------------------------------------------------------------------- /src/parser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #include 7 | #include 8 | #include 9 | 10 | // anonymous namespace for variables/functions local to this file 11 | namespace 12 | { 13 | 14 | // helper function to check for a required string key within a json object 15 | string check_key(const string &key, const string &parent, const json &j) 16 | { 17 | try 18 | { 19 | return j.at(key).get(); 20 | } 21 | catch (...) 22 | { 23 | throw DartsException("Missing '{}' on '{}' specification:\n{}", key, parent, j.dump(4)); 24 | } 25 | } 26 | 27 | } // namespace 28 | 29 | void Scene::parse(const json &j) 30 | { 31 | spdlog::info("parsing..."); 32 | 33 | // 34 | // check for and parse the camera specification 35 | // 36 | if (j.contains("camera")) 37 | m_camera = make_shared(j["camera"]); 38 | else 39 | throw DartsException("No camera specified in scene!"); 40 | 41 | // 42 | // read number of samples to take per pixel 43 | // 44 | if (j.contains("sampler") && j["sampler"].contains("samples")) 45 | m_num_samples = j["sampler"]["samples"]; 46 | 47 | // 48 | // create the scene-wide acceleration structure so we can put other surfaces into it 49 | // 50 | if (j.contains("accelerator")) 51 | m_surfaces = DartsFactory::create(j["accelerator"]); 52 | else 53 | // default to a naive linear accelerator 54 | m_surfaces = make_shared(json::object()); 55 | 56 | // 57 | // parse scene background 58 | // 59 | if (j.contains("background")) 60 | { 61 | m_background = j["background"].get(); 62 | } 63 | 64 | // 65 | // parse materials 66 | // 67 | if (j.contains("materials")) 68 | { 69 | for (auto &m : j["materials"]) 70 | { 71 | auto material = DartsFactory::create(m); 72 | DartsFactory::register_instance(check_key("name", "material", m), material); 73 | } 74 | } 75 | 76 | // 77 | // parse surfaces 78 | // 79 | if (j.contains("surfaces")) 80 | { 81 | for (auto &s : j["surfaces"]) 82 | { 83 | auto surface = DartsFactory::create(s); 84 | surface->add_to_parent(this, surface, j); 85 | } 86 | } 87 | 88 | // set of all fields we'd expect to see at the top level of a darts scene 89 | // some of these are not yet supported, but we include them to be future-proof 90 | set toplevel_fields{"integrator", "media", "materials", "surfaces", 91 | "accelerator", "camera", "sampler", "background"}; 92 | 93 | // now loop through all keys in the json file to see if there are any that we don't recognize 94 | for (auto it = j.begin(); it != j.end(); ++it) 95 | if (toplevel_fields.count(it.key()) == 0) 96 | throw DartsException("Unsupported field '{}' here:\n{}", it.key(), it.value().dump(4)); 97 | 98 | m_surfaces->build(); 99 | spdlog::info("done parsing scene."); 100 | } 101 | -------------------------------------------------------------------------------- /src/samplers/independent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | /** 11 | %Independent sampling - returns independent uniformly distributed random numbers on \f$[0, 1)^2\f$. 12 | 13 | This class is essentially just a wrapper around the pcg32 pseudorandom number generator. For more details on what 14 | sample generators do in general, refer to the \ref Sampler class. 15 | */ 16 | class Independent : public Sampler 17 | { 18 | public: 19 | Independent(const json &j) 20 | { 21 | m_sample_count = j.at("samples").get(); 22 | } 23 | 24 | virtual ~Independent() 25 | { 26 | } 27 | 28 | /** 29 | Create an exact clone of the current instance 30 | 31 | This is useful if you want to duplicate a sampler to use in multiple threads 32 | */ 33 | std::unique_ptr clone() const override 34 | { 35 | std::unique_ptr cloned(new Independent()); 36 | cloned->m_sample_count = m_sample_count; 37 | cloned->m_base_seed = m_base_seed; 38 | cloned->m_sample_count = m_sample_count; 39 | cloned->m_current_sample = m_current_sample; 40 | cloned->m_current_dimension = m_current_dimension; 41 | 42 | cloned->m_rng = m_rng; 43 | return std::move(cloned); 44 | } 45 | 46 | void seed(int seedx, int seedy) override 47 | { 48 | Sampler::seed(seedx, seedy); 49 | m_rng.seed(m_base_seed + seedx, m_base_seed + seedy); 50 | } 51 | 52 | void start_pixel(int x, int y) override 53 | { 54 | // No-op for this sampler 55 | } 56 | 57 | float next1f() override 58 | { 59 | m_current_dimension++; 60 | return m_rng.nextFloat(); 61 | } 62 | 63 | Vec2f next2f() override 64 | { 65 | m_current_dimension += 2; 66 | return {m_rng.nextFloat(), m_rng.nextFloat()}; 67 | } 68 | 69 | protected: 70 | Independent() 71 | { 72 | } 73 | 74 | pcg32 m_rng; 75 | }; 76 | 77 | DARTS_REGISTER_CLASS_IN_FACTORY(Sampler, Independent, "independent") 78 | -------------------------------------------------------------------------------- /src/scene.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | /// Construct a new scene from a json object 13 | Scene::Scene(const json &j) 14 | { 15 | parse(j); 16 | } 17 | 18 | Scene::~Scene() 19 | { 20 | } 21 | 22 | Color3f Scene::background(const Ray3f &ray) const 23 | { 24 | return m_background; 25 | } 26 | 27 | // compute the color corresponding to a ray by raytracing 28 | Color3f Scene::recursive_color(const Ray3f &ray, int depth) const 29 | { 30 | constexpr int max_depth = 64; 31 | put_your_code_here("Assignment 1: Insert your recursive_color() code here"); 32 | return Color3f(0.0f, 0.0f, 0.0f); 33 | 34 | // TODO: Recursively raytrace the scene, similar to the code you wrote in darts_tutorial1 35 | // Different to before, you should also take into account surfaces that are self-emitting 36 | // Pseudo-code: 37 | // 38 | // if scene.intersect: 39 | // get emitted color (hint: you can use hit.mat->emitted) 40 | // if depth < max_depth and hit_material.scatter(....) is successful: 41 | // recursive_color = call this function recursively with the scattered ray and increased depth 42 | // return emitted color + attenuation * recursive_color 43 | // else 44 | // return emitted color; 45 | // else: 46 | // return background color (hint: look at background()) 47 | } 48 | 49 | // raytrace an image 50 | Image3f Scene::raytrace() const 51 | { 52 | // allocate an image of the proper size 53 | auto image = Image3f(m_camera->resolution().x, m_camera->resolution().y); 54 | 55 | put_your_code_here("Assignment 1: insert your raytrace() code here"); 56 | 57 | // TODO: Render the image, similar to the tutorial 58 | // Pseudo-code: 59 | // 60 | // foreach image row (go over image height) 61 | // foreach pixel in the row (go over image width) 62 | // init accumulated color to zero 63 | // repeat m_num_samples times: 64 | // compute a random point within the pixel (you can just add a random number between 0 and 1 65 | // to the pixel coordinate. You can use randf() for 66 | // this) 67 | // compute camera ray 68 | // accumulate color raytraced with the ray (by calling recursive_color) 69 | // divide color by the number of pixel samples 70 | 71 | // Hint: you can create a Progress object (progress.h) to provide a 72 | // progress bar during rendering. 73 | 74 | 75 | // return the ray-traced image 76 | return image; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /src/surfaces/quad.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | #include 7 | 8 | /** \addtogroup group_surfaces 9 | * @{ 10 | */ 11 | 12 | /// A quad spanning from -\ref m_size / 2 to \ref m_size / 2 in the (x,y)-plane at z=0. 13 | class Quad : public XformedSurfaceWithMaterial 14 | { 15 | public: 16 | Quad(const json &j = json::object()); 17 | 18 | bool intersect(const Ray3f &ray, HitInfo &hit) const override; 19 | Box3f local_bounds() const override; 20 | Color3f sample(EmitterRecord &rec, const Vec2f &rv) const override; 21 | float pdf(const Vec3f &o, const Vec3f &v) const override; 22 | 23 | protected: 24 | Vec2f m_size = Vec2f(1.f); ///< The extent of the quad in the (x,y) plane 25 | }; 26 | 27 | Quad::Quad(const json &j) : XformedSurfaceWithMaterial(j) 28 | { 29 | m_size = j.value("size", m_size); 30 | m_size /= 2.f; 31 | 32 | } 33 | 34 | bool Quad::intersect(const Ray3f &ray, HitInfo &hit) const 35 | { 36 | INCREMENT_INTERSECTION_TESTS; 37 | 38 | // compute ray intersection (and ray parameter), continue if not hit 39 | auto tray = m_xform.inverse().ray(ray); 40 | if (tray.d.z == 0) 41 | return false; 42 | auto t = -tray.o.z / tray.d.z; 43 | auto p = tray(t); 44 | 45 | if (m_size.x < std::abs(p.x) || m_size.y < std::abs(p.y)) 46 | return false; 47 | 48 | // check if computed param is within ray.mint and ray.maxt 49 | if (t < tray.mint || t > tray.maxt) 50 | return false; 51 | 52 | // project hitpoint onto plane to reduce floating-point error 53 | p.z = 0; 54 | 55 | // if hit, set intersection record values 56 | hit.t = t; 57 | hit.p = m_xform.point(p); 58 | hit.gn = hit.sn = normalize(m_xform.normal({0, 0, 1})); 59 | hit.mat = m_material.get(); 60 | hit.uv = Vec2f(0.0f, 0.0f); /* TODO: Compute proper UV coordinates */ 61 | 62 | return true; 63 | } 64 | 65 | Box3f Quad::local_bounds() const 66 | { 67 | return Box3f(-Vec3f(m_size.x, m_size.y, 0) - Vec3f(1e-4f), Vec3f(m_size.x, m_size.y, 0) + Vec3f(1e-4f)); 68 | } 69 | 70 | Color3f Quad::sample(EmitterRecord &rec, const Vec2f &rv) const 71 | { 72 | rec.hit.p = m_xform.point({(2 * rv.x - 1) * m_size.x, (2 * rv.y - 1) * m_size.y, 0}); 73 | rec.wi = rec.hit.p - rec.o; 74 | float dist2 = length2(rec.wi); 75 | rec.hit.t = std::sqrt(dist2); 76 | rec.hit.mat = m_material.get(); 77 | rec.hit.gn = rec.hit.sn = m_xform.normal({0, 0, 1}); 78 | rec.wi /= rec.hit.t; 79 | 80 | // convert to solid angle measure 81 | float area = 4 * length(cross(m_xform.vector({m_size.x, 0, 0}), m_xform.vector({0, m_size.y, 0}))); 82 | float cosine = std::abs(dot(rec.hit.gn, rec.wi)); 83 | rec.pdf = dist2 / (cosine * area); 84 | 85 | return rec.hit.mat->emitted(Ray3f(rec.o, rec.wi), rec.hit) / rec.pdf; 86 | } 87 | 88 | float Quad::pdf(const Vec3f &o, const Vec3f &v) const 89 | { 90 | HitInfo rec; 91 | if (this->intersect(Ray3f(o, v), rec)) 92 | { 93 | float area = 4 * length(cross(m_xform.vector({m_size.x, 0, 0}), m_xform.vector({0, m_size.y, 0}))); 94 | float distance_squared = rec.t * rec.t * length2(v); 95 | float cosine = std::abs(dot(v, rec.gn) / length(v)); 96 | return distance_squared / (cosine * area); 97 | } 98 | else 99 | return 0; 100 | } 101 | 102 | DARTS_REGISTER_CLASS_IN_FACTORY(Surface, Quad, "quad") 103 | 104 | /** 105 | \file 106 | \brief Class #Quad 107 | */ 108 | 109 | /** @}*/ 110 | -------------------------------------------------------------------------------- /src/surfaces/sphere.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | 9 | /** \addtogroup group_surfaces 10 | * @{ 11 | */ 12 | 13 | Sphere::Sphere(float radius, shared_ptr material, const Transform &xform) : 14 | XformedSurfaceWithMaterial(material, xform), m_radius(radius) 15 | { 16 | } 17 | 18 | Sphere::Sphere(const json &j) : XformedSurfaceWithMaterial(j) 19 | { 20 | m_radius = j.value("radius", m_radius); 21 | } 22 | 23 | bool Sphere::intersect(const Ray3f &ray, HitInfo &hit) const 24 | { 25 | INCREMENT_INTERSECTION_TESTS; 26 | // TODO: Assignment 1: Implement ray-sphere intersection 27 | 28 | put_your_code_here("Assignment 1: Insert your ray-sphere intersection code here"); 29 | return false; 30 | 31 | // TODO: If the ray misses the sphere, you should return false 32 | // TODO: If you successfully hit something, you should compute the hit point (p), 33 | // hit distance (t), and normal (n) and fill in these values 34 | Vec3f p; 35 | float t = 0.0f; 36 | Vec3f n; 37 | 38 | // For this assignment you can leave these two values as is 39 | Vec3f shading_normal = n; 40 | Vec2f uv = Vec2f(0.0f, 0.0f); 41 | 42 | // You should only assign hit and return true if you successfully hit something 43 | hit.t = t; 44 | hit.p = p; 45 | hit.gn = n; 46 | hit.sn = shading_normal; 47 | hit.uv = uv; 48 | hit.mat = m_material.get(); 49 | 50 | return true; 51 | } 52 | 53 | Box3f Sphere::local_bounds() const 54 | { 55 | return Box3f(Vec3f(-m_radius), Vec3f(m_radius)); 56 | } 57 | 58 | 59 | DARTS_REGISTER_CLASS_IN_FACTORY(Surface, Sphere, "sphere") 60 | 61 | /** 62 | \file 63 | \brief Class #Sphere 64 | */ 65 | 66 | /** @}*/ 67 | -------------------------------------------------------------------------------- /src/surfaces/surface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | XformedSurfaceWithMaterial::XformedSurfaceWithMaterial(const json &j) 11 | { 12 | m_xform = j.value("transform", m_xform); 13 | m_material = DartsFactory::find(j); 14 | } 15 | 16 | Box3f XformedSurfaceWithMaterial::bounds() const 17 | { 18 | return m_xform.box(local_bounds()); 19 | } 20 | 21 | bool XformedSurfaceWithMaterial::is_emissive() const 22 | { 23 | return m_material && m_material->is_emissive(); 24 | } -------------------------------------------------------------------------------- /src/surfaces/surface_group.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | 9 | void SurfaceGroup::add_child(shared_ptr surface) 10 | { 11 | m_surfaces.push_back(surface); 12 | m_bounds.enclose(m_surfaces.back()->bounds()); 13 | } 14 | 15 | bool SurfaceGroup::intersect(const Ray3f &_ray, HitInfo &hit) const 16 | { 17 | // copy the ray so we can modify the tmax values as we traverse 18 | Ray3f ray = _ray; 19 | bool hit_anything = false; 20 | 21 | // This is a linear intersection test that iterates over all primitives 22 | // within the scene. It's the most naive intersection test and hence very 23 | // slow if you have many primitives. 24 | 25 | // foreach primitive 26 | for (auto surface : m_surfaces) 27 | { 28 | if (surface->intersect(ray, hit)) 29 | { 30 | hit_anything = true; 31 | ray.maxt = hit.t; 32 | } 33 | } 34 | 35 | // record closest intersection 36 | return hit_anything; 37 | } 38 | 39 | Box3f SurfaceGroup::bounds() const 40 | { 41 | return m_bounds; 42 | } 43 | 44 | 45 | DARTS_REGISTER_CLASS_IN_FACTORY(SurfaceGroup, SurfaceGroup, "group") -------------------------------------------------------------------------------- /src/tests/material_sample_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | struct MaterialSampleTest : public SampleTest 16 | { 17 | MaterialSampleTest(const json &j); 18 | 19 | bool sample(Vec3f &dir, const Vec2f &rv) override; 20 | float pdf(Vec3f &dir) override; 21 | void print_more_statistics() override; 22 | 23 | shared_ptr material; 24 | Vec3f normal; 25 | Vec3f incoming; 26 | HitInfo hit; 27 | 28 | bool any_specular = false; 29 | bool any_below_hemisphere = false; 30 | }; 31 | 32 | MaterialSampleTest::MaterialSampleTest(const json &j) : SampleTest(j) 33 | { 34 | material = DartsFactory::create(j.at("material")); 35 | normal = normalize(j.at("normal").get()); 36 | incoming = normalize(j.value("incoming", Vec3f(0.25f, 0.0f, -1.0f))); 37 | 38 | hit.t = 1.0f; 39 | hit.p = Vec3f(0.0f); 40 | hit.gn = hit.sn = normal; 41 | hit.uv = Vec2f(0.5f); 42 | } 43 | 44 | bool MaterialSampleTest::sample(Vec3f &dir, const Vec2f &rv) 45 | { 46 | // Sample material 47 | ScatterRecord record; 48 | if (!material->sample(incoming, hit, record, rv)) 49 | return false; 50 | 51 | dir = record.wo; 52 | 53 | if (record.is_specular) 54 | any_specular = true; 55 | 56 | // Sanity check to make sure directions are valid 57 | Vec3f wo = normalize(record.wo); 58 | if (dot(wo, hit.sn) < -Ray3f::epsilon) 59 | { 60 | any_below_hemisphere = true; 61 | return false; 62 | } 63 | 64 | return true; 65 | } 66 | 67 | float MaterialSampleTest::pdf(Vec3f &dir) 68 | { 69 | return material->pdf(incoming, dir, hit); 70 | } 71 | void MaterialSampleTest::print_more_statistics() 72 | { 73 | if (any_specular) 74 | spdlog::warn("is_specular is set. It should not be."); 75 | if (any_below_hemisphere) 76 | spdlog::warn("Some generated directions were below the hemisphere. " 77 | "You should check for this case and return false from sample instead."); 78 | } 79 | 80 | DARTS_REGISTER_CLASS_IN_FACTORY(Test, MaterialSampleTest, "sample_material") 81 | -------------------------------------------------------------------------------- /src/tests/surface_sample_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of darts – the Dartmouth Academic Ray Tracing Skeleton. 3 | 4 | Copyright (c) 2017-2021 by Wojciech Jarosz 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | struct SurfaceSampleTest : public SampleTest 17 | { 18 | SurfaceSampleTest(const json &j); 19 | 20 | bool sample(Vec3f &dir, const Vec2f &rv) override; 21 | float pdf(Vec3f &dir) override; 22 | 23 | shared_ptr surface; 24 | Vec3f normal; 25 | }; 26 | 27 | SurfaceSampleTest::SurfaceSampleTest(const json &j) : SampleTest(j) 28 | { 29 | if (j.contains("surface")) 30 | surface = DartsFactory::create(j.at("surface")); 31 | else if (j.contains("surfaces")) 32 | { 33 | json j2 = j["surfaces"]; 34 | auto group = DartsFactory::create(j2); 35 | // 36 | // parse the children 37 | // 38 | if (j2.contains("children")) 39 | { 40 | for (auto &s : j2["children"]) 41 | { 42 | auto child = DartsFactory::create(s); 43 | child->add_to_parent(group.get(), child, j2); 44 | } 45 | } 46 | 47 | group->build(); 48 | 49 | surface = group; 50 | } 51 | else 52 | throw DartsException("Invalid sample_surface file. No 'surface' or 'surfaces' field found."); 53 | } 54 | 55 | bool SurfaceSampleTest::sample(Vec3f &dir, const Vec2f &rv) 56 | { 57 | // Sample geometry 58 | EmitterRecord rec; 59 | rec.o = Vec3f(0.f); 60 | surface->sample(rec, rv); 61 | dir = normalize(rec.wi); 62 | 63 | return true; 64 | } 65 | 66 | float SurfaceSampleTest::pdf(Vec3f &dir) 67 | { 68 | return surface->pdf(Vec3f(0.f), dir); 69 | } 70 | 71 | DARTS_REGISTER_CLASS_IN_FACTORY(Test, SurfaceSampleTest, "sample_surface") 72 | -------------------------------------------------------------------------------- /test-slurm-job.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Name for job 4 | #SBATCH --job-name=darts_render 5 | 6 | # Request the default queue for this job 7 | #SBATCH --partition=standard 8 | 9 | # Request 1 node for this job 10 | #SBATCH --nodes=1 11 | 12 | # Specify number of tasks per node for this job 13 | #SBATCH --ntasks-per-node=1 14 | 15 | # Number of tasks (i.e. cores) per CPU to allocate 16 | #SBATCH --cpus-per-task=8 17 | 18 | # Request 60 minutes of wall time 19 | #SBATCH --time=00:60:00 20 | 21 | # Specify compute resource account 22 | #SBATCH --account cs_comp 23 | 24 | # Submit a job array 25 | #SBATCH --array=0-32 26 | 27 | # Name the standard and error log files for each element of the job array 28 | # Where %A is the job ID and %a is the array index 29 | #SBATCH --output=results/stdout_%A-%a 30 | 31 | # You can use the environment variable SLURM_ARRAY_TASK_ID to identify 32 | # each element of the job array 33 | 34 | ./build/darts scenes/assignment5/jensen_box_mats.json -o results/jensen_box_mats_$SLURM_ARRAY_TASK_ID.exr --------------------------------------------------------------------------------