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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.vcxproj
*.xcodeproj
build
build2015

# Created by https://www.gitignore.io/api/linux,osx,sublimetext,windows,jetbrains,vim,emacs,cmake,c++,cuda,visualstudio,webstorm,eclipse,xcode

Expand Down
115 changes: 107 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,112 @@
CUDA Path Tracer
================
CUDA Path tracer
======================

**University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 3**
**University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 2**

* (TODO) YOUR NAME HERE
* Tested on: (TODO) Windows 22, i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (Moore 2222 Lab)
* Akshay Shah
* Tested on: Windows 10, i7-5700HQ @ 2.70GHz 16GB, GTX 970M 6GB (Personal Computer)

### (TODO: Your README)
### GPU Path Tracer

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

The below analysis and results have been performed on a scene with the cornell box that has all the material types and two light sources.

![](renders/cornell.2016-10-10_03-15-15z.1024samp.png)

![](img/cuda_summary.PNG)

Most of the time was spent in the main path trace loop to check intersection after a ray was shot. `shadeMaterial` captures the next highest device time due to the computation of refraction and other complex materials types such as the Oren-Nayar microfacet and Blinn Microfacet Model. The `launch_closure_by_value` function is part of thrust's `remove_if` stream compaction. The amount of time that is spent in here(stream compaction) is well received in terms of total time saved.

![](img/cuda_summary1.PNG)

The above image indicates the total time spent in each device function with corresponding number of launches. To reduce the total time spent in `shadeMaterial`, separate BRDF function calls could be made to avoid branches inside `shadeMaterial` itself and let class definitions do their job.

Analysis
--------

![](img/total_time.png)

The above image shows a comparison of time taken in the `computeIntersection` function with different techniques
- No caching first ray bounce
- Caching first ray bounce
- Sorting the rays and intersections by material type

The reason for a longer time for sorting could be that, there are not enough materials in the scene (and the scene is also not large enough. Maybe a scene as large as at least 1000 objects) that the rays show a significant change by sorting them by material.

![](img/streamcompact.png)

The above image shows a comparison of time taken with and without stream compaction. There is a significant change when `thrust::remove_if` is used to weed out rays that have finished bouncing in the scene i.e., rays that have `remainingBounces` 0 will be removed from the pool of "threads".

Output
------

Anti-Aliasing
-------------
The following image shows an example of stochastic anti-aliasing that was used in the path tracer to clean out the jaggies.

![](img/StochasticAA.PNG)

REFRACTION
----------

The refractive indices of the glass spheres are 1.5
Each of them has also been approximated for glass using Schlick's method.

![](renders/cornell.2016-10-10_03-19-06z.1490samp.png)

DOF (Depth of Field)
--------------------

![](renders/cornell.2016-10-10_03-01-09z.1125samp.png)

![](renders/cornell.2016-10-10_02-51-02z.1871samp.png)

MATERIALS
---------
The following image shows a material comparison between two diffuse materials:
- Lambertian diffuse
- Oren-Nayar diffuse

The Oren-Nayar diffuse material in the render below has a roughness value of 20

![](renders/cornell.2016-10-10_02-27-37z.5000sampCopy.png)

MIRROR
------

![](renders/cornell.2016-10-05_18-18-36z.1024samp.png)

Blinn Microfacet
----------------

The following render displays the Blinn Microfacet model with an exponent of 10 in this particular example.
![](renders/cornell.2016-10-10_03-55-56z.5000samp.png)


Just things
-----------
A render of UFO looking saucers with refractive properties. >.<

![](renders/cornell.2016-10-10_03-25-17z.1701samp.png)

<br />
<br />
<br />

##### BLOOPERS

When trying to add Stratified sampling to sample diffuse hemispheres.

![](renders/cornell.2016-10-06_18-53-26z.1024samp.png)

When trying to add Halton sequences to sample diffuse hemispheres.

![](renders/cornell.2016-10-06_16-00-42z.273samp.png)

![](renders/cornell.2016-10-06_16-00-42z.1024samp.png)

Trying to add refraction

![](renders/cornell.2016-10-05_07-35-47z.1024samp.png)
Binary file added img/StochasticAA.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/cuda_summary.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/cuda_summary1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/streamcompact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/total_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_14-38-00z.1024samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_14-38-00z.512samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_14-39-40z.1024samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_14-39-40z.512samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_14-46-16z.1024samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_14-46-16z.1536samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_14-46-16z.512samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_15-40-22z.1samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_15-40-35z.3samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_18-08-15z.512samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_18-08-52z.512samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_18-10-56z.1024samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_18-10-56z.1536samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_18-10-56z.512samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_18-21-53z.1024samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_18-21-53z.512samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_18-27-24z.512samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_18-28-40z.1024samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_18-28-40z.512samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added renders/cornell.2016-10-04_19-04-04z.1024samp.png
Binary file added renders/cornell.2016-10-04_19-04-04z.512samp.png
Binary file added renders/cornell.2016-10-04_19-14-36z.1024samp.png
Binary file added renders/cornell.2016-10-04_19-14-36z.512samp.png
Binary file added renders/cornell.2016-10-04_19-27-36z.512samp.png
Binary file added renders/cornell.2016-10-04_19-30-09z.1024samp.png
Binary file added renders/cornell.2016-10-04_19-30-09z.512samp.png
Binary file added renders/cornell.2016-10-04_19-31-53z.1024samp.png
Binary file added renders/cornell.2016-10-04_19-31-53z.1536samp.png
Binary file added renders/cornell.2016-10-04_19-31-53z.512samp.png
Binary file added renders/cornell.2016-10-04_19-43-00z.11samp.png
Binary file added renders/cornell.2016-10-04_19-44-20z.512samp.png
Binary file added renders/cornell.2016-10-04_19-51-57z.512samp.png
Binary file added renders/cornell.2016-10-04_19-51-57z.680samp.png
Binary file added renders/cornell.2016-10-04_20-16-53z.59samp.png
Binary file added renders/cornell.2016-10-04_20-17-41z.512samp.png
Binary file added renders/cornell.2016-10-04_20-18-29z.76samp.png
Binary file added renders/cornell.2016-10-04_20-26-18z.512samp.png
Binary file added renders/cornell.2016-10-04_20-31-24z.512samp.png
Binary file added renders/cornell.2016-10-04_20-33-10z.1024samp.png
Binary file added renders/cornell.2016-10-04_20-33-10z.512samp.png
Binary file added renders/cornell.2016-10-04_20-37-27z.1024samp.png
Binary file added renders/cornell.2016-10-04_20-37-27z.512samp.png
Binary file added renders/cornell.2016-10-04_21-14-03z.49samp.png
Binary file added renders/cornell.2016-10-04_21-21-56z.17samp.png
Binary file added renders/cornell.2016-10-04_21-23-30z.73samp.png
Binary file added renders/cornell.2016-10-05_00-23-42z.14samp.png
Binary file added renders/cornell.2016-10-05_07-35-47z.1024samp.png
Binary file added renders/cornell.2016-10-05_07-35-47z.512samp.png
Binary file added renders/cornell.2016-10-05_08-21-29z.512samp.png
Binary file added renders/cornell.2016-10-05_18-11-09z.512samp.png
Binary file added renders/cornell.2016-10-05_18-15-50z.512samp.png
Binary file added renders/cornell.2016-10-05_18-17-34z.512samp.png
Binary file added renders/cornell.2016-10-05_18-18-36z.1024samp.png
Binary file added renders/cornell.2016-10-05_18-18-36z.512samp.png
Binary file added renders/cornell.2016-10-05_22-28-18z.512samp.png
Binary file added renders/cornell.2016-10-05_22-28-18z.619samp.png
Binary file added renders/cornell.2016-10-06_15-23-53z.1024samp.png
Binary file added renders/cornell.2016-10-06_15-23-53z.512samp.png
Binary file added renders/cornell.2016-10-06_15-29-53z.512samp.png
Binary file added renders/cornell.2016-10-06_15-31-38z.1024samp.png
Binary file added renders/cornell.2016-10-06_15-31-38z.512samp.png
Binary file added renders/cornell.2016-10-06_15-33-06z.512samp.png
Binary file added renders/cornell.2016-10-06_15-33-59z.512samp.png
Binary file added renders/cornell.2016-10-06_15-36-10z.512samp.png
Binary file added renders/cornell.2016-10-06_15-39-49z.275samp.png
Binary file added renders/cornell.2016-10-06_15-40-38z.512samp.png
Binary file added renders/cornell.2016-10-06_15-41-51z.1024samp.png
Binary file added renders/cornell.2016-10-06_15-41-51z.1536samp.png
Binary file added renders/cornell.2016-10-06_15-41-51z.512samp.png
Binary file added renders/cornell.2016-10-06_15-51-49z.1024samp.png
Binary file added renders/cornell.2016-10-06_15-51-49z.512samp.png
Binary file added renders/cornell.2016-10-06_15-54-47z.146samp.png
Binary file added renders/cornell.2016-10-06_15-55-55z.103samp.png
Binary file added renders/cornell.2016-10-06_16-00-42z.273samp.png
Binary file added renders/cornell.2016-10-06_16-00-42z.512samp.png
Binary file added renders/cornell.2016-10-06_16-26-29z.512samp.png
Binary file added renders/cornell.2016-10-06_16-29-38z.512samp.png
Binary file added renders/cornell.2016-10-06_18-41-30z.512samp.png
Binary file added renders/cornell.2016-10-06_18-43-11z.186samp.png
Binary file added renders/cornell.2016-10-06_18-43-21z.90samp.png
Binary file added renders/cornell.2016-10-06_18-45-21z.512samp.png
Binary file added renders/cornell.2016-10-06_18-46-31z.434samp.png
Binary file added renders/cornell.2016-10-06_18-48-40z.1024samp.png
Binary file added renders/cornell.2016-10-06_18-48-40z.1033samp.png
Binary file added renders/cornell.2016-10-06_18-48-40z.512samp.png
Binary file added renders/cornell.2016-10-06_18-53-26z.512samp.png
Binary file added renders/cornell.2016-10-10_02-17-23z.1389samp.png
Binary file added renders/cornell.2016-10-10_02-19-17z.1391samp.png
Binary file added renders/cornell.2016-10-10_02-22-22z.1386samp.png
Binary file added renders/cornell.2016-10-10_02-27-37z.5000samp.png
Binary file added renders/cornell.2016-10-10_02-39-08z.5000samp.png
Binary file added renders/cornell.2016-10-10_02-51-02z.1871samp.png
Binary file added renders/cornell.2016-10-10_03-01-09z.1125samp.png
Binary file added renders/cornell.2016-10-10_03-05-09z.171samp.png
Binary file added renders/cornell.2016-10-10_03-08-31z.708samp.png
Binary file added renders/cornell.2016-10-10_03-09-50z.1702samp.png
Binary file added renders/cornell.2016-10-10_03-12-52z.1899samp.png
Binary file added renders/cornell.2016-10-10_03-15-15z.1024samp.png
Binary file added renders/cornell.2016-10-10_03-19-06z.1490samp.png
Binary file added renders/cornell.2016-10-10_03-22-14z.184samp.png
Binary file added renders/cornell.2016-10-10_03-25-17z.1701samp.png
Binary file added renders/cornell.2016-10-10_03-55-56z.5000samp.png
Binary file added renders/custom.2016-10-05_18-36-41z.512samp.png
Binary file added renders/custom.2016-10-05_18-39-01z.512samp.png
Binary file added renders/custom.2016-10-10_02-48-09z.87samp.png
65 changes: 62 additions & 3 deletions scenes/cornell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 5
EMITTANCE 10

// Diffuse white
MATERIAL 1
Expand Down Expand Up @@ -43,11 +43,52 @@ MATERIAL 4
RGB .98 .98 .98
SPECEX 0
SPECRGB .98 .98 .98
REFL 0
REFR 1
REFRIOR 2.5
EMITTANCE 0

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

// microfacet white
MATERIAL 6
RGB .4 0 .98
SPECEX 0
SPECRGB 1 1 1
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0
ROUGH 300

// diffuse not white
MATERIAL 7
RGB .4 0 .98
SPECEX 0
SPECRGB .98 .98 .98
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// blinn phong?
MATERIAL 8
RGB .4 0 .98
SPECEX 10.2
SPECRGB .98 .98 .98
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Camera
CAMERA
RES 800 800
Expand All @@ -58,6 +99,8 @@ FILE cornell
EYE 0.0 5 10.5
LOOKAT 0 5 0
UP 0 1 0
LENSRADIUS 0.2
FOCALDIST 5


// Ceiling light
Expand Down Expand Up @@ -111,7 +154,23 @@ SCALE .01 10 10
// Sphere
OBJECT 6
sphere
material 4
TRANS -1 4 -1
material 7
TRANS 2 4 -1.5
ROTAT 0 0 0
SCALE 3 3 3

// Sphere
OBJECT 7
sphere
material 8
TRANS -2 4 -1.5
ROTAT 0 0 0
SCALE 3 3 3

// Sphere
OBJECT 8
sphere
material 0
TRANS 0 2 4
ROTAT 0 0 0
SCALE 3 3 3
Loading