diff --git a/.gitignore b/.gitignore
index 89942d9e..02e6993b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,7 +23,8 @@ build
.LSOverride
# Icon must end with two \r
-Icon
+Icon
+
# Thumbnails
._*
@@ -189,7 +190,6 @@ install_manifest.txt
*.slo
*.lo
*.o
-*.obj
# Precompiled Headers
*.gch
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c473e2c0..e62696cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -73,6 +73,8 @@ set(headers
src/sceneStructs.h
src/preview.h
src/utilities.h
+ src/ThirdPartyLib/tiny_obj_loader.h
+ src/bvhTree.h
src/ImGui/imconfig.h
src/ImGui/imgui.h
@@ -95,6 +97,8 @@ set(sources
src/scene.cpp
src/preview.cpp
src/utilities.cpp
+ src/ThirdPartyLib/tiny_obj_loader.cc
+ src/bvhTree.cu
src/ImGui/imgui.cpp
src/ImGui/imgui_demo.cpp
diff --git a/README.md b/README.md
index 110697ce..241e4799 100644
--- a/README.md
+++ b/README.md
@@ -3,11 +3,44 @@ CUDA Path Tracer
**University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 3**
-* (TODO) YOUR NAME HERE
-* Tested on: (TODO) Windows 22, i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (Moore 2222 Lab)
+* Zhuohao Lin
+ * [LinkedIn](https://www.linkedin.com/in/zhuohao-lin-960b54194/)
+* Tested on: Windows 10, i7-10875H @ 2.30GHz 16GB, NVIDIA Grforce RTX 2060 6GB (personal machine)
-### (TODO: Your README)
+# Overview
+This is a GPU based path tracer. The project contains both visual and performance improvements so that mutiple objects with different kinds of materials can be rendered quickly.
+
-*DO NOT* leave the README to the last minute! It is a crucial part of the
-project, and we will not be able to grade you without a good README.
+# Features
+### `Arbitrary mesh loading and rendering with obj file`
+
+### `Antialiasing`
+Before Antialiasing | After Antialiasing
+:-------------------------:|:-------------------------:
+ | 
+
+### `Refraction material`
+Index of refraction of cube and sphere: 1.5
+
+
+### `Bounding volume hierarchy acceleration data structure`
+I implemented bounding volume hierarchy data structure in order to accelerate the intersection testing process. This data structure organize primitives into a binary tree based on their bounding box. There are various ways to split primitives. What I did is simply divide primitives into equal subsets. The BVH tree was built in CPU and then passed into GPU in a linear array. When doing intersection tests, first find box intersections within BVH tree apparently improve performance since a lot of primitives are abandoned.
+
+# Performance Analysis
+
+## Cache the First Bounce
+For the first intersection of every iteration, it's always the same without any doubts. Therefore, I cache the first intersection data so that the computation can be skipped in every iteration except the first one. To see how much performance this brings, I make a graph as below (all data are got from the same scene)
+
+
+
+By caching the first bounce in the scene, we always get a higher FPS than no cache. However, as the max ray depth increases, the percentage increase in FPS is going down.
+
+
+## Bounding Volume Hierarchy
+I put 3 objects with different number of faces in the same scene for performance comparison. In order to keep the number of intersections as close as possible, I set 3 objects in similar sizes.
+
+
+
+It's obvious that BVH tree brings a huge performance improvement. The more the number of faces a mesh has, the lower the FPS will be. However, the FPS is dropping much slower using BVH than not using BVH. This is expected since BVH is a binary tree. The time cost to search intersections using BVH is roughly log(N) but N for not using BVH.
+Note: Search intersections in BVH tree is roughly log(N) because it can get into different leaf nodes if some bounding boxes overlap.
diff --git a/img/afterAntialiasing.png b/img/afterAntialiasing.png
new file mode 100644
index 00000000..0e216e3f
Binary files /dev/null and b/img/afterAntialiasing.png differ
diff --git a/img/beforeAntialiasing.png b/img/beforeAntialiasing.png
new file mode 100644
index 00000000..e60ead93
Binary files /dev/null and b/img/beforeAntialiasing.png differ
diff --git a/img/bvhPerformance.PNG b/img/bvhPerformance.PNG
new file mode 100644
index 00000000..86eb3d79
Binary files /dev/null and b/img/bvhPerformance.PNG differ
diff --git a/img/cacheFirstBounce.PNG b/img/cacheFirstBounce.PNG
new file mode 100644
index 00000000..1ded52a8
Binary files /dev/null and b/img/cacheFirstBounce.PNG differ
diff --git a/img/cornell.2022-09-20_19-29-53z.6samp.png b/img/cornell.2022-09-20_19-29-53z.6samp.png
new file mode 100644
index 00000000..1070f907
Binary files /dev/null and b/img/cornell.2022-09-20_19-29-53z.6samp.png differ
diff --git a/img/cornell.2022-09-23_04-50-13z.5000samp.png b/img/cornell.2022-09-23_04-50-13z.5000samp.png
new file mode 100644
index 00000000..744a3b49
Binary files /dev/null and b/img/cornell.2022-09-23_04-50-13z.5000samp.png differ
diff --git a/img/cornell.2022-09-23_04-50-41z.5000samp.png b/img/cornell.2022-09-23_04-50-41z.5000samp.png
new file mode 100644
index 00000000..744a3b49
Binary files /dev/null and b/img/cornell.2022-09-23_04-50-41z.5000samp.png differ
diff --git a/img/cornell.2022-09-23_05-29-46z.5000samp.png b/img/cornell.2022-09-23_05-29-46z.5000samp.png
new file mode 100644
index 00000000..13e05393
Binary files /dev/null and b/img/cornell.2022-09-23_05-29-46z.5000samp.png differ
diff --git a/img/cornell.2022-09-24_01-28-07z.5000samp.png b/img/cornell.2022-09-24_01-28-07z.5000samp.png
new file mode 100644
index 00000000..0eb106cc
Binary files /dev/null and b/img/cornell.2022-09-24_01-28-07z.5000samp.png differ
diff --git a/img/cornell.2022-09-24_01-44-39z.160samp.png b/img/cornell.2022-09-24_01-44-39z.160samp.png
new file mode 100644
index 00000000..58eb671b
Binary files /dev/null and b/img/cornell.2022-09-24_01-44-39z.160samp.png differ
diff --git a/img/cornell.2022-09-24_03-18-33z.149samp.png b/img/cornell.2022-09-24_03-18-33z.149samp.png
new file mode 100644
index 00000000..2c6f2f9b
Binary files /dev/null and b/img/cornell.2022-09-24_03-18-33z.149samp.png differ
diff --git a/img/cornell.2022-09-28_23-33-58z.1120samp.png b/img/cornell.2022-09-28_23-33-58z.1120samp.png
new file mode 100644
index 00000000..6cafc88c
Binary files /dev/null and b/img/cornell.2022-09-28_23-33-58z.1120samp.png differ
diff --git a/img/cornell.2022-09-28_23-33-58z.1141samp.png b/img/cornell.2022-09-28_23-33-58z.1141samp.png
new file mode 100644
index 00000000..37c7124f
Binary files /dev/null and b/img/cornell.2022-09-28_23-33-58z.1141samp.png differ
diff --git a/img/cornell.2022-09-29_06-25-07z.123samp.png b/img/cornell.2022-09-29_06-25-07z.123samp.png
new file mode 100644
index 00000000..78321442
Binary files /dev/null and b/img/cornell.2022-09-29_06-25-07z.123samp.png differ
diff --git a/img/cornell.2022-09-29_06-25-07z.124samp.png b/img/cornell.2022-09-29_06-25-07z.124samp.png
new file mode 100644
index 00000000..a0f056d5
Binary files /dev/null and b/img/cornell.2022-09-29_06-25-07z.124samp.png differ
diff --git a/img/cornell.2022-10-03_00-41-07z.1022samp.png b/img/cornell.2022-10-03_00-41-07z.1022samp.png
new file mode 100644
index 00000000..e85324ee
Binary files /dev/null and b/img/cornell.2022-10-03_00-41-07z.1022samp.png differ
diff --git a/img/cornell.2022-10-03_00-41-07z.728samp.png b/img/cornell.2022-10-03_00-41-07z.728samp.png
new file mode 100644
index 00000000..a68d26b6
Binary files /dev/null and b/img/cornell.2022-10-03_00-41-07z.728samp.png differ
diff --git a/img/cornell.2022-10-03_04-42-09z.3108samp.png b/img/cornell.2022-10-03_04-42-09z.3108samp.png
new file mode 100644
index 00000000..d61b54e8
Binary files /dev/null and b/img/cornell.2022-10-03_04-42-09z.3108samp.png differ
diff --git a/img/cornell.2022-10-03_04-42-09z.5000samp.png b/img/cornell.2022-10-03_04-42-09z.5000samp.png
new file mode 100644
index 00000000..ca63fc00
Binary files /dev/null and b/img/cornell.2022-10-03_04-42-09z.5000samp.png differ
diff --git a/img/cornell.2022-10-03_05-51-26z.1203samp.png b/img/cornell.2022-10-03_05-51-26z.1203samp.png
new file mode 100644
index 00000000..b7f3313c
Binary files /dev/null and b/img/cornell.2022-10-03_05-51-26z.1203samp.png differ
diff --git a/img/cornell.2022-10-03_05-51-26z.2518samp.png b/img/cornell.2022-10-03_05-51-26z.2518samp.png
new file mode 100644
index 00000000..de43906a
Binary files /dev/null and b/img/cornell.2022-10-03_05-51-26z.2518samp.png differ
diff --git a/img/cornell.2022-10-03_08-10-45z.252samp.png b/img/cornell.2022-10-03_08-10-45z.252samp.png
new file mode 100644
index 00000000..e41ba60e
Binary files /dev/null and b/img/cornell.2022-10-03_08-10-45z.252samp.png differ
diff --git a/img/cornell.2022-10-03_08-22-15z.616samp.png b/img/cornell.2022-10-03_08-22-15z.616samp.png
new file mode 100644
index 00000000..06c9a328
Binary files /dev/null and b/img/cornell.2022-10-03_08-22-15z.616samp.png differ
diff --git a/img/cornell.2022-10-03_08-28-21z.1112samp.png b/img/cornell.2022-10-03_08-28-21z.1112samp.png
new file mode 100644
index 00000000..18fac8b9
Binary files /dev/null and b/img/cornell.2022-10-03_08-28-21z.1112samp.png differ
diff --git a/img/cornell.2022-10-03_08-55-15z.613samp.png b/img/cornell.2022-10-03_08-55-15z.613samp.png
new file mode 100644
index 00000000..f481d6de
Binary files /dev/null and b/img/cornell.2022-10-03_08-55-15z.613samp.png differ
diff --git a/img/cornell.2022-10-04_06-10-20z.409samp.png b/img/cornell.2022-10-04_06-10-20z.409samp.png
new file mode 100644
index 00000000..92c20190
Binary files /dev/null and b/img/cornell.2022-10-04_06-10-20z.409samp.png differ
diff --git a/img/cornell.2022-10-04_06-13-06z.698samp.png b/img/cornell.2022-10-04_06-13-06z.698samp.png
new file mode 100644
index 00000000..a67f97c5
Binary files /dev/null and b/img/cornell.2022-10-04_06-13-06z.698samp.png differ
diff --git a/img/cornell.2022-10-06_06-51-29z.1689samp.png b/img/cornell.2022-10-06_06-51-29z.1689samp.png
new file mode 100644
index 00000000..ab6b7ead
Binary files /dev/null and b/img/cornell.2022-10-06_06-51-29z.1689samp.png differ
diff --git a/img/cornell.2022-10-07_00-17-27z.838samp.png b/img/cornell.2022-10-07_00-17-27z.838samp.png
new file mode 100644
index 00000000..a1273a05
Binary files /dev/null and b/img/cornell.2022-10-07_00-17-27z.838samp.png differ
diff --git a/img/cornell.2022-10-08_05-56-57z.87samp.png b/img/cornell.2022-10-08_05-56-57z.87samp.png
new file mode 100644
index 00000000..b4f1a8df
Binary files /dev/null and b/img/cornell.2022-10-08_05-56-57z.87samp.png differ
diff --git a/img/cornell.2022-10-08_06-59-29z.1213samp.png b/img/cornell.2022-10-08_06-59-29z.1213samp.png
new file mode 100644
index 00000000..138a8efc
Binary files /dev/null and b/img/cornell.2022-10-08_06-59-29z.1213samp.png differ
diff --git a/img/cornell.2022-10-08_06-59-29z.1832samp.png b/img/cornell.2022-10-08_06-59-29z.1832samp.png
new file mode 100644
index 00000000..3982282a
Binary files /dev/null and b/img/cornell.2022-10-08_06-59-29z.1832samp.png differ
diff --git a/img/cornell.2022-10-08_06-59-29z.1898samp.png b/img/cornell.2022-10-08_06-59-29z.1898samp.png
new file mode 100644
index 00000000..86ab2594
Binary files /dev/null and b/img/cornell.2022-10-08_06-59-29z.1898samp.png differ
diff --git a/img/cornell.2022-10-08_06-59-29z.2596samp.png b/img/cornell.2022-10-08_06-59-29z.2596samp.png
new file mode 100644
index 00000000..d42f9615
Binary files /dev/null and b/img/cornell.2022-10-08_06-59-29z.2596samp.png differ
diff --git a/img/cornell.2022-10-08_06-59-29z.352samp.png b/img/cornell.2022-10-08_06-59-29z.352samp.png
new file mode 100644
index 00000000..8b6c0439
Binary files /dev/null and b/img/cornell.2022-10-08_06-59-29z.352samp.png differ
diff --git a/img/cornell.2022-10-08_06-59-29z.5000samp.png b/img/cornell.2022-10-08_06-59-29z.5000samp.png
new file mode 100644
index 00000000..5360687d
Binary files /dev/null and b/img/cornell.2022-10-08_06-59-29z.5000samp.png differ
diff --git a/img/cornell.2022-10-08_06-59-29z.664samp.png b/img/cornell.2022-10-08_06-59-29z.664samp.png
new file mode 100644
index 00000000..e0051f19
Binary files /dev/null and b/img/cornell.2022-10-08_06-59-29z.664samp.png differ
diff --git a/img/cornell.2022-10-08_20-44-19z.5000samp.png b/img/cornell.2022-10-08_20-44-19z.5000samp.png
new file mode 100644
index 00000000..87c61618
Binary files /dev/null and b/img/cornell.2022-10-08_20-44-19z.5000samp.png differ
diff --git a/img/cornell.2022-10-08_22-12-30z.5000samp.png b/img/cornell.2022-10-08_22-12-30z.5000samp.png
new file mode 100644
index 00000000..c0aa1dd7
Binary files /dev/null and b/img/cornell.2022-10-08_22-12-30z.5000samp.png differ
diff --git a/scenes/antialiasing.txt b/scenes/antialiasing.txt
new file mode 100644
index 00000000..6c5fa416
--- /dev/null
+++ b/scenes/antialiasing.txt
@@ -0,0 +1,147 @@
+// Emissive material (light)
+MATERIAL 0
+RGB 0.992 0.518 0.122
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 5
+
+// Diffuse white
+MATERIAL 1
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse red
+MATERIAL 2
+RGB .8 .8 1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse green
+MATERIAL 3
+RGB .8 .8 1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Specular white
+MATERIAL 4
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 1
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// diffuse white
+MATERIAL 5
+RGB 0.98 .98 .98
+SPECEX 0
+SPECRGB .91 .89 .867
+REFL 0
+REFR 0
+REFRIOR 1.5
+EMITTANCE 0
+
+// Specular white
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Refractive white
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 0
+REFL 1
+REFR 1
+REFRIOR 1.5
+EMITTANCE 0
+
+// Camera
+CAMERA
+RES 1080 1080
+FOVY 45
+ITERATIONS 500
+DEPTH 8
+FILE cornell
+EYE 0.0 5 10.5
+LOOKAT 0 5 0
+UP 0 1 0
+
+
+// Ceiling light
+OBJECT 0
+cube
+material 0
+TRANS 0 10 0
+ROTAT 0 0 0
+SCALE 3 .3 3
+
+// Floor
+OBJECT 1
+cube
+material 1
+TRANS 0 0 0
+ROTAT 0 0 0
+SCALE 10 .01 10
+
+// Ceiling
+OBJECT 2
+cube
+material 1
+TRANS 0 10 0
+ROTAT 0 0 90
+SCALE .01 10 10
+
+// Back wall
+OBJECT 3
+cube
+material 1
+TRANS 0 5 -5
+ROTAT 0 90 0
+SCALE .01 10 10
+
+// Left wall
+OBJECT 4
+cube
+material 2
+TRANS -5 5 0
+ROTAT 0 0 0
+SCALE .01 10 10
+
+// Right wall
+OBJECT 5
+cube
+material 3
+TRANS 5 5 0
+ROTAT 0 0 0
+SCALE .01 10 10
+
+// Sphere
+OBJECT 6
+../scenes/objFiles/cube.obj
+material 5
+TRANS 0 4 0
+ROTAT 0 30 0
+SCALE 4 4 4
\ No newline at end of file
diff --git a/scenes/cornell.txt b/scenes/cornell.txt
index 83ff8202..d85fb763 100644
--- a/scenes/cornell.txt
+++ b/scenes/cornell.txt
@@ -6,7 +6,7 @@ SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
-EMITTANCE 5
+EMITTANCE 10
// Diffuse white
MATERIAL 1
@@ -48,6 +48,26 @@ REFR 0
REFRIOR 0
EMITTANCE 0
+// Specular white
+MATERIAL 5
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Refractive yellow
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 0
+REFL 1
+REFR 1
+REFRIOR 1.5
+EMITTANCE 0
+
// Camera
CAMERA
RES 800 800
@@ -110,8 +130,58 @@ SCALE .01 10 10
// Sphere
OBJECT 6
-sphere
-material 4
-TRANS -1 4 -1
+../scenes/objFiles/wahoo.obj
+material 6
+TRANS 2 4 0
+ROTAT 0 0 0
+SCALE 0.35 0.35 0.35
+
+
+OBJECT 7
+../scenes/objFiles/wahoo.obj
+material 5
+TRANS 0 4 2
+ROTAT 0 0 0
+SCALE 0.35 0.35 0.35
+
+OBJECT 8
+../scenes/objFiles/wahoo.obj
+material 5
+TRANS 2 1 0
+ROTAT 0 0 0
+SCALE 0.35 0.35 0.35
+
+OBJECT 9
+../scenes/objFiles/wahoo.obj
+material 2
+TRANS 0 1 2
+ROTAT 0 0 0
+SCALE 0.35 0.35 0.35
+
+OBJECT 10
+../scenes/objFiles/wahoo.obj
+material 5
+TRANS 3 1 2
+ROTAT 0 0 0
+SCALE 0.35 0.35 0.35
+
+OBJECT 11
+../scenes/objFiles/wahoo.obj
+material 5
+TRANS -2 4 -2
+ROTAT 0 0 0
+SCALE 0.35 0.35 0.35
+
+OBJECT 12
+../scenes/objFiles/Caitlyn.obj
+material 5
+TRANS 1 1 0
+ROTAT 0 0 0
+SCALE 2 2 2
+
+OBJECT 13
+../scenes/objFiles/melina.obj
+material 5
+TRANS -1 1 0
ROTAT 0 0 0
-SCALE 3 3 3
+SCALE 2 2 2
\ No newline at end of file
diff --git a/scenes/refraction.txt b/scenes/refraction.txt
new file mode 100644
index 00000000..ad30f054
--- /dev/null
+++ b/scenes/refraction.txt
@@ -0,0 +1,153 @@
+// Emissive material (light)
+MATERIAL 0
+RGB 0.992 0.518 0.122
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 5
+
+// Diffuse white
+MATERIAL 1
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse red
+MATERIAL 2
+RGB .8 .8 1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse green
+MATERIAL 3
+RGB .8 .8 1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Specular white
+MATERIAL 4
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 1
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// diffuse white
+MATERIAL 5
+RGB 0.98 .98 .98
+SPECEX 0
+SPECRGB .91 .89 .867
+REFL 1
+REFR 1
+REFRIOR 1.2
+EMITTANCE 0
+
+// Specular white
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 1
+REFR 1
+REFRIOR 1.5
+EMITTANCE 0
+
+// Refractive white
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 0
+REFL 1
+REFR 1
+REFRIOR 1.5
+EMITTANCE 0
+
+// Camera
+CAMERA
+RES 1080 1080
+FOVY 45
+ITERATIONS 5000
+DEPTH 8
+FILE cornell
+EYE 0.0 5 10.5
+LOOKAT 0 5 0
+UP 0 1 0
+
+
+// Ceiling light
+OBJECT 0
+cube
+material 0
+TRANS 0 10 0
+ROTAT 0 0 0
+SCALE 3 .3 3
+
+// Floor
+OBJECT 1
+cube
+material 1
+TRANS 0 0 0
+ROTAT 0 0 0
+SCALE 10 .01 10
+
+// Ceiling
+OBJECT 2
+cube
+material 1
+TRANS 0 10 0
+ROTAT 0 0 90
+SCALE .01 10 10
+
+// Back wall
+OBJECT 3
+cube
+material 1
+TRANS 0 5 -5
+ROTAT 0 90 0
+SCALE .01 10 10
+
+// Left wall
+OBJECT 4
+cube
+material 2
+TRANS -5 5 0
+ROTAT 0 0 0
+SCALE .01 10 10
+
+// Right wall
+OBJECT 5
+cube
+material 3
+TRANS 5 5 0
+ROTAT 0 0 0
+SCALE .01 10 10
+
+OBJECT 6
+cube
+material 5
+TRANS -2 4 0
+ROTAT 0 30 0
+SCALE 3 3 3
+
+OBJECT 7
+sphere
+material 6
+TRANS 2 4 0
+ROTAT 0 30 0
+SCALE 3 3 3
\ No newline at end of file
diff --git a/scenes/refractiveDragon.txt b/scenes/refractiveDragon.txt
new file mode 100644
index 00000000..abf5252b
--- /dev/null
+++ b/scenes/refractiveDragon.txt
@@ -0,0 +1,147 @@
+// Emissive material (light)
+MATERIAL 0
+RGB 1 1 1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 5
+
+// Diffuse white
+MATERIAL 1
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse red
+MATERIAL 2
+RGB .85 .35 .35
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse green
+MATERIAL 3
+RGB .35 .85 .35
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Specular white
+MATERIAL 4
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 1
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// rerfractive white
+MATERIAL 5
+RGB 0 .98 .98
+SPECEX 0
+SPECRGB .98 .98 0
+REFL 1
+REFR 1
+REFRIOR 1.5
+EMITTANCE 0
+
+// Specular white
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Refractive white
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 0
+REFL 1
+REFR 1
+REFRIOR 1.5
+EMITTANCE 0
+
+// Camera
+CAMERA
+RES 800 800
+FOVY 45
+ITERATIONS 5000
+DEPTH 8
+FILE cornell
+EYE 0.0 5 10.5
+LOOKAT 0 5 0
+UP 0 1 0
+
+
+// Ceiling light
+OBJECT 0
+cube
+material 0
+TRANS 0 10 0
+ROTAT 0 0 0
+SCALE 3 .3 3
+
+// Floor
+OBJECT 1
+cube
+material 1
+TRANS 0 0 0
+ROTAT 0 0 0
+SCALE 10 .01 10
+
+// Ceiling
+OBJECT 2
+cube
+material 1
+TRANS 0 10 0
+ROTAT 0 0 90
+SCALE .01 10 10
+
+// Back wall
+OBJECT 3
+cube
+material 1
+TRANS 0 5 -5
+ROTAT 0 90 0
+SCALE .01 10 10
+
+// Left wall
+OBJECT 4
+cube
+material 2
+TRANS -5 5 0
+ROTAT 0 0 0
+SCALE .01 10 10
+
+// Right wall
+OBJECT 5
+cube
+material 3
+TRANS 5 5 0
+ROTAT 0 0 0
+SCALE .01 10 10
+
+// Sphere
+OBJECT 6
+../scenes/objFiles/dragon.obj
+material 5
+TRANS 0 4 0
+ROTAT 0 90 0
+SCALE 7.5 7.5 7.5
\ No newline at end of file
diff --git a/scenes/refractiveDragon2.txt b/scenes/refractiveDragon2.txt
new file mode 100644
index 00000000..b6657c82
--- /dev/null
+++ b/scenes/refractiveDragon2.txt
@@ -0,0 +1,147 @@
+// Emissive material (light)
+MATERIAL 0
+RGB 0.992 0.518 0.122
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 5
+
+// Diffuse white
+MATERIAL 1
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse red
+MATERIAL 2
+RGB .8 .8 1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse green
+MATERIAL 3
+RGB .8 .8 1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Specular white
+MATERIAL 4
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 1
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// rerfractive yellow
+MATERIAL 5
+RGB 0.98 .98 .98
+SPECEX 0
+SPECRGB .91 .89 .867
+REFL 0
+REFR 0
+REFRIOR 1.5
+EMITTANCE 0
+
+// Specular white
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Refractive white
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 0
+REFL 1
+REFR 1
+REFRIOR 1.5
+EMITTANCE 0
+
+// Camera
+CAMERA
+RES 1080 1080
+FOVY 45
+ITERATIONS 5000
+DEPTH 8
+FILE cornell
+EYE 0.0 5 10.5
+LOOKAT 0 5 0
+UP 0 1 0
+
+
+// Ceiling light
+OBJECT 0
+cube
+material 0
+TRANS 0 10 0
+ROTAT 0 0 0
+SCALE 3 .3 3
+
+// Floor
+OBJECT 1
+cube
+material 1
+TRANS 0 0 0
+ROTAT 0 0 0
+SCALE 10 .01 10
+
+// Ceiling
+OBJECT 2
+cube
+material 1
+TRANS 0 10 0
+ROTAT 0 0 90
+SCALE .01 10 10
+
+// Back wall
+OBJECT 3
+cube
+material 1
+TRANS 0 5 -5
+ROTAT 0 90 0
+SCALE .01 10 10
+
+// Left wall
+OBJECT 4
+cube
+material 2
+TRANS -5 5 0
+ROTAT 0 0 0
+SCALE .01 10 10
+
+// Right wall
+OBJECT 5
+cube
+material 3
+TRANS 5 5 0
+ROTAT 0 0 0
+SCALE .01 10 10
+
+// Sphere
+OBJECT 6
+../scenes/objFiles/dragon.obj
+material 5
+TRANS 0 4 0
+ROTAT 0 90 0
+SCALE 8.5 8.5 8.5
\ No newline at end of file
diff --git a/scenes/room.txt b/scenes/room.txt
new file mode 100644
index 00000000..89e5ce85
--- /dev/null
+++ b/scenes/room.txt
@@ -0,0 +1,318 @@
+// Emissive material (light)
+MATERIAL 0
+RGB 0.992 0.933 0.863
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 5
+
+// Diffuse orange (couch color)
+MATERIAL 1
+RGB 1 .533 .294
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse light purple (wall color)
+MATERIAL 2
+RGB .8 .8 1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse black (tv color)
+MATERIAL 3
+RGB .1 .1 .1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Specular white (mirror color)
+MATERIAL 4
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 1
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// diffuse white (floor color)
+MATERIAL 5
+RGB .98 .98 0.98
+SPECEX 0
+SPECRGB .98 .98 0.98
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// refraction pink (bunny)
+MATERIAL 6
+RGB 1 .412 .706
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 1
+REFR 1
+REFRIOR 1.5
+EMITTANCE 0
+
+// diffuse wood color
+MATERIAL 7
+RGB .73 .55 .39
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// refraction white (vase)
+MATERIAL 8
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 1
+REFR 1
+REFRIOR 1.03
+EMITTANCE 0
+
+// diffuse coffee (table)
+MATERIAL 9
+RGB .447 .286 .208
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// diffuse Platinum (chair)
+MATERIAL 10
+RGB .91 .89 .867
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// diffuse Platinum (character)
+MATERIAL 11
+RGB .91 .89 .867
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Emissive material (light on the right)
+MATERIAL 12
+RGB 0.882 0.302 0.165
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 5
+
+// Emissive material (light on the left)
+MATERIAL 13
+RGB 0.992 0.518 0.122
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 5
+
+
+
+// Camera
+CAMERA
+RES 1980 1080
+FOVY 45
+ITERATIONS 5000
+DEPTH 8
+FILE cornell
+EYE 0.0 5 10.5
+LOOKAT 0 5 0
+UP 0 1 0
+
+
+// Ceiling light 1
+OBJECT 0
+cube
+material 0
+TRANS -4 12 0
+ROTAT 0 0 0
+SCALE 3 .3 3
+
+// Floor
+OBJECT 1
+cube
+material 5
+TRANS 0 0 0
+ROTAT 0 0 0
+SCALE 20 .01 10
+
+// Ceiling
+OBJECT 2
+cube
+material 5
+TRANS 0 12 0
+ROTAT 0 0 90
+SCALE .01 20 10
+
+// Back wall
+OBJECT 3
+cube
+material 2
+TRANS 0 6 -5
+ROTAT 0 90 0
+SCALE .01 12 20
+
+// Left wall
+OBJECT 4
+cube
+material 2
+TRANS -10 6 0
+ROTAT 0 0 0
+SCALE .01 12 10
+
+// Right wall
+OBJECT 5
+cube
+material 2
+TRANS 10 6 0
+ROTAT 0 0 0
+SCALE .01 12 10
+
+OBJECT 6
+../scenes/objFiles/room/cabinet2.obj
+material 7
+TRANS 0 -0.2 -5
+ROTAT 0 0 0
+SCALE 7 7 7
+
+OBJECT 7
+../scenes/objFiles/room/table.obj
+material 9
+TRANS 6 0 2
+ROTAT -90 0 0
+SCALE 0.05 0.05 0.05
+
+OBJECT 8
+../scenes/objFiles/room/chair.obj
+material 10
+TRANS 6 0 1
+ROTAT -90 0 0
+SCALE 0.035 0.035 0.035
+
+OBJECT 9
+../scenes/objFiles/room/tv.obj
+material 3
+TRANS -3 3.25 -4.5
+ROTAT 90 -90 90
+SCALE 0.1 0.1 0.1
+
+OBJECT 10
+../scenes/objFiles/room/couchPillows.obj
+material 1
+TRANS -4 0 3.5
+ROTAT 0 180 0
+SCALE 3 2.5 2.5
+
+OBJECT 11
+../scenes/objFiles/room/stairs.obj
+material 7
+TRANS -9.5 0 -2
+ROTAT 0 90 0
+SCALE 0.075 0.1 0.075
+
+OBJECT 12
+../scenes/objFiles/room/vaseCeramic.obj
+material 8
+TRANS 8 2.01 2
+ROTAT 0 0 0
+SCALE 0.025 0.03 0.025
+
+OBJECT 13
+../scenes/objFiles/room/vaseCeramic.obj
+material 8
+TRANS 7.8 2.01 1.8
+ROTAT 0 0 0
+SCALE 0.025 0.03 0.025
+
+OBJECT 14
+../scenes/objFiles/melina.obj
+material 11
+TRANS 3 0 -1
+ROTAT 0 0 0
+SCALE 4 4 4
+
+OBJECT 15
+../scenes/objFiles/bunny.obj
+material 6
+TRANS 5 2.41 2
+ROTAT 0 0 0
+SCALE 0.5 0.5 0.5
+
+OBJECT 16
+../scenes/objFiles/cube.obj
+material 4
+TRANS 10 6 0
+ROTAT 0 90 0
+SCALE 4 3 0.01
+
+// Ceiling light 2
+OBJECT 17
+cube
+material 0
+TRANS 4 12 0
+ROTAT 0 0 0
+SCALE 3 .3 3
+
+// Wall light 1
+OBJECT 18
+cube
+material 12
+TRANS 10 10 -1
+ROTAT 0 90 0
+SCALE 3 0.5 .3
+
+// Wall light 2
+OBJECT 19
+cube
+material 12
+TRANS 10 10 3
+ROTAT 0 90 0
+SCALE 3 0.5 .3
+
+// Wall light 3
+OBJECT 20
+cube
+material 13
+TRANS -10 10 -1
+ROTAT 0 -90 0
+SCALE 3 0.5 .3
+
+// Wall light 4
+OBJECT 21
+cube
+material 13
+TRANS -10 10 3
+ROTAT 0 -90 0
+SCALE 3 0.5 .3
\ No newline at end of file
diff --git a/scenes/test.txt b/scenes/test.txt
new file mode 100644
index 00000000..f60c82f2
--- /dev/null
+++ b/scenes/test.txt
@@ -0,0 +1,146 @@
+// Emissive material (light)
+MATERIAL 0
+RGB 0.992 0.518 0.122
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 5
+
+// Diffuse white
+MATERIAL 1
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse red
+MATERIAL 2
+RGB .8 .8 1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Diffuse green
+MATERIAL 3
+RGB .8 .8 1
+SPECEX 0
+SPECRGB 0 0 0
+REFL 0
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// Specular white
+MATERIAL 4
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 1
+REFR 0
+REFRIOR 0
+EMITTANCE 0
+
+// diffuse white
+MATERIAL 5
+RGB 0.98 .98 .98
+SPECEX 0
+SPECRGB .91 .89 .867
+REFL 1
+REFR 1
+REFRIOR 1.2
+EMITTANCE 0
+
+// Specular white
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 .98
+REFL 1
+REFR 1
+REFRIOR 1.5
+EMITTANCE 0
+
+// Refractive white
+MATERIAL 6
+RGB .98 .98 .98
+SPECEX 0
+SPECRGB .98 .98 0
+REFL 1
+REFR 1
+REFRIOR 1.5
+EMITTANCE 0
+
+// Camera
+CAMERA
+RES 800 800
+FOVY 45
+ITERATIONS 5000
+DEPTH 8
+FILE cornell
+EYE 0.0 5 10.5
+LOOKAT 0 5 0
+UP 0 1 0
+
+
+// Ceiling light
+OBJECT 0
+cube
+material 0
+TRANS 0 10 0
+ROTAT 0 0 0
+SCALE 3 .3 3
+
+// Floor
+OBJECT 1
+cube
+material 1
+TRANS 0 0 0
+ROTAT 0 0 0
+SCALE 10 .01 10
+
+// Ceiling
+OBJECT 2
+cube
+material 1
+TRANS 0 10 0
+ROTAT 0 0 90
+SCALE .01 10 10
+
+// Back wall
+OBJECT 3
+cube
+material 1
+TRANS 0 5 -5
+ROTAT 0 90 0
+SCALE .01 10 10
+
+// Left wall
+OBJECT 4
+cube
+material 2
+TRANS -5 5 0
+ROTAT 0 0 0
+SCALE .01 10 10
+
+// Right wall
+OBJECT 5
+cube
+material 3
+TRANS 5 5 0
+ROTAT 0 0 0
+SCALE .01 10 10
+
+OBJECT 6
+../scenes/objFiles/wahoo.obj
+material 1
+TRANS 0 4 0
+ROTAT 0 0 0
+SCALE 1 1 1
diff --git a/src/ThirdPartyLib/tiny_obj_loader.cc b/src/ThirdPartyLib/tiny_obj_loader.cc
new file mode 100644
index 00000000..e57d0444
--- /dev/null
+++ b/src/ThirdPartyLib/tiny_obj_loader.cc
@@ -0,0 +1,2 @@
+#define TINYOBJLOADER_IMPLEMENTATION
+#include "tiny_obj_loader.h"
diff --git a/src/ThirdPartyLib/tiny_obj_loader.h b/src/ThirdPartyLib/tiny_obj_loader.h
new file mode 100644
index 00000000..7d0c3844
--- /dev/null
+++ b/src/ThirdPartyLib/tiny_obj_loader.h
@@ -0,0 +1,3333 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2012-Present, Syoyo Fujita and many contributors.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+//
+// version 2.0.0 : Add new object oriented API. 1.x API is still provided.
+// * Support line primitive.
+// * Support points primitive.
+// * Support multiple search path for .mtl(v1 API).
+// * Support vertex weight `vw`(as an tinyobj extension)
+// * Support escaped whitespece in mtllib
+// * Add robust triangulation using Mapbox earcut(TINYOBJLOADER_USE_MAPBOX_EARCUT).
+// version 1.4.0 : Modifed ParseTextureNameAndOption API
+// version 1.3.1 : Make ParseTextureNameAndOption API public
+// version 1.3.0 : Separate warning and error message(breaking API of LoadObj)
+// version 1.2.3 : Added color space extension('-colorspace') to tex opts.
+// version 1.2.2 : Parse multiple group names.
+// version 1.2.1 : Added initial support for line('l') primitive(PR #178)
+// version 1.2.0 : Hardened implementation(#175)
+// version 1.1.1 : Support smoothing groups(#162)
+// version 1.1.0 : Support parsing vertex color(#144)
+// version 1.0.8 : Fix parsing `g` tag just after `usemtl`(#138)
+// version 1.0.7 : Support multiple tex options(#126)
+// version 1.0.6 : Add TINYOBJLOADER_USE_DOUBLE option(#124)
+// version 1.0.5 : Ignore `Tr` when `d` exists in MTL(#43)
+// version 1.0.4 : Support multiple filenames for 'mtllib'(#112)
+// version 1.0.3 : Support parsing texture options(#85)
+// version 1.0.2 : Improve parsing speed by about a factor of 2 for large
+// files(#105)
+// version 1.0.1 : Fixes a shape is lost if obj ends with a 'usemtl'(#104)
+// version 1.0.0 : Change data structure. Change license from BSD to MIT.
+//
+
+//
+// Use this in *one* .cc
+// #define TINYOBJLOADER_IMPLEMENTATION
+// #include "tiny_obj_loader.h"
+//
+
+#ifndef TINY_OBJ_LOADER_H_
+#define TINY_OBJ_LOADER_H_
+
+#include