Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ set(headers
src/sceneStructs.h
src/preview.h
src/utilities.h
src/tiny_obj_loader.h
)

set(sources
Expand Down
77 changes: 72 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,78 @@ 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)
* Xiao Wei
* Tested on: Windows 10, i7-9750h @ 2.6GHz 16.0GB, RTX 2070 with MAX-Q Design, 16GB
* 1 late day applied



Feature
======================
* Ideal Diffuse surfaces
* Perfectly specular-reflective (mirrored) surfaces
* Path continuation/termination using Stream Compaction
* Caching the first bounce intersections for re-use
* Mesh Loading with bounding volume intersection culling
* Refraction
* Stochastic Sampled Antialiasing
* Physically-based depth-of-field

Rendering Results
======================

## Ideal Diffuse
![noanti](https://user-images.githubusercontent.com/66859615/136673557-24e26ab2-9a1e-4304-9a09-87f7eda68cd4.png)


## Perfect specular with mesh loaded teapot
![specular teapot](https://user-images.githubusercontent.com/66859615/136673548-8e275359-bb45-43e5-81a6-0187debafab5.png)

## Refractions
Refraction with Frensel effects using Schlick's approximation
![refract1](https://user-images.githubusercontent.com/66859615/136673533-ad4f9364-603a-4293-9254-7dec0bc53e96.png)
![refract2](https://user-images.githubusercontent.com/66859615/136673535-7ea1c7bd-6c9f-42db-adea-fe298c5158f4.png)
## Antialiasing
For Antialiasing, I divided the pixels into grids and the points from which the rays are shoot is generated randomly inside that grid, and at each iteration we will choose one grid to use and we will use all of them one by one. The first picture is rendered WITHOUT antialiasing and the second is rendered with antialiasing. You can notice the aliasing on the left and right edge of red box is significantly mitigated in the second picture.

![noanti](https://user-images.githubusercontent.com/66859615/136673564-f1e90853-cc2a-48ee-9a18-244e4d9cbc1a.png)
![anti](https://user-images.githubusercontent.com/66859615/136674065-54fc0d35-4b73-4e92-a2ad-589e69bccf32.png)


## Depth of Field
Depth of Field is implemented according to PBRT
![dof](https://user-images.githubusercontent.com/66859615/136673562-edfa4ca5-fdf3-4232-97e9-73670eaf3749.png)

Performance analysis
======================
## Mesh Bounding Box
Time Comparison of rendering the following teapot with and without Bounding Box (200 iterations and depth)

![cornell 2021-10-09_21-32-53z 200samp](https://user-images.githubusercontent.com/66859615/136674312-d80bf5ed-e48a-42f9-a7fb-046a63027de3.png)

Without Bounding Box | With Bounding Box
------------ | -------------
1min 42sec 68ms | 1min 13sec 43ms

As you can see, we can get about 28.4% performance improvement with bounding box in my case

## Material sort and First Bounce Cache

The performance of Material sort is measured with the following rendering with 300 iterations
![cornell 2021-10-09_21-52-39z 300samp](https://user-images.githubusercontent.com/66859615/136674721-4458c1b5-3075-49b3-b070-305caf1342b7.png)


![20211009100655](https://user-images.githubusercontent.com/66859615/136674835-3b092577-49b1-427e-9404-091a65b3d408.png)


Surprisingly, the material sort actually makes the performance worse in my case. I think it is mostly because there are not so many materials in the scene and the sorting consumes more time than what we save from the better memory placement.

## First Bounce Cache
The performance of Cache Bounce is measured with the following rendering with 300 iterations

![cornell 2021-10-09_22-20-37z 300samp](https://user-images.githubusercontent.com/66859615/136675214-58feb48e-1778-4efd-bfa5-bef7797c01e7.png)
![20211009102803](https://user-images.githubusercontent.com/66859615/136675217-966a761f-1298-473e-a147-2927bd79a540.png)
With no surprise, by caching the first bounce, we improved the performance a lot. I initially used some simple scene to test but the improvement was not obvious because the first bounce doesn't take much time. Then I switched to this scene with mesh.

### (TODO: Your README)

*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.

20 changes: 15 additions & 5 deletions scenes/cornell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ FOVY 45
ITERATIONS 5000
DEPTH 8
FILE cornell
EYE 0.0 5 10.5
EYE 0.0 5 4.5
LOOKAT 0 5 0
UP 0 1 0

Expand Down Expand Up @@ -108,10 +108,20 @@ TRANS 5 5 0
ROTAT 0 0 0
SCALE .01 10 10

// Sphere
// front wall
OBJECT 6
sphere
cube
material 1
TRANS 0 5 5
ROTAT 0 90 0
SCALE .01 10 10


// TEAPOT
OBJECT 7
mesh
../mesh/teapot_s1.obj
material 4
TRANS -1 4 -1
TRANS 0 0 0
ROTAT 0 0 0
SCALE 3 3 3
SCALE 15 15 15
173 changes: 173 additions & 0 deletions scenes/dof.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
// 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


// glass white
MATERIAL 5
RGB .98 .98 .98
SPECEX 1
SPECRGB .98 .98 .98
REFL 1
REFR 1
REFRIOR 3
EMITTANCE 0

// Diffuse blue
MATERIAL 6
RGB .35 .35 .85
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0


// Diffuse pink
MATERIAL 7
RGB .81 .13 .94
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Camera
CAMERA
RES 800 800
FOVY 45
ITERATIONS 5000
DEPTH 8
FILE cornell
EYE 0.0 5 4.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

// front wall
OBJECT 6
cube
material 1
TRANS 0 5 5
ROTAT 0 90 0
SCALE .01 10 10


OBJECT 7
sphere
material 3
TRANS 1 3 2
ROTAT 0 0 0
SCALE 2 2 2

OBJECT 8
sphere
material 7
TRANS 3 3 4
ROTAT 0 0 0
SCALE 2 2 2

OBJECT 9
sphere
material 2
TRANS 0 3 1
ROTAT 0 0 0
SCALE 2 2 2


Loading