Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project 3: Chhavi Sharrma #20

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
aca4e00
basic path tracer
Sep 26, 2019
58b501c
implemented refraction, first bounce cache, material type sort
Sep 27, 2019
3e64fd0
AntiAliasing, Refraction, MotionBlur(faulty)
Sep 28, 2019
e74c8f9
Work Efficient Stream Comapction - standalone
Sep 29, 2019
421cd10
stream comapction work efficient(shared mem) standalone
Sep 29, 2019
f0dd90d
stream comapction work efficient(shared mem) standalone
Sep 29, 2019
d8e43cc
stream comapction work efficient(shared mem) standalone
Sep 29, 2019
43ca107
merge stream comapction work efficient | memory limitation (works upt…
Sep 29, 2019
0bb9025
merge stream comapction work efficient | memory limitation (works upt…
Sep 29, 2019
108e922
Images, Plots, Statistics
Sep 30, 2019
bc04519
final changes
Sep 30, 2019
e6faac9
final changes
Sep 30, 2019
e2adc2e
update readme
chhavisharma Sep 30, 2019
4da7b36
final changes
Sep 30, 2019
688b8b8
Merge branch 'master' of https://github.com/chhavisharma/Project3-CUD…
Sep 30, 2019
8277317
final changes
Sep 30, 2019
fc42ae6
update readme
chhavisharma Sep 30, 2019
4f3e784
update readme
chhavisharma Sep 30, 2019
20269df
final changes
Sep 30, 2019
c18bc7e
final changes
Sep 30, 2019
5b70e28
update readme
Sep 30, 2019
046a427
update readme
chhavisharma Sep 30, 2019
be34f2a
update readme
Sep 30, 2019
a4e79d6
Merge branch 'master' of https://github.com/chhavisharma/Project3-CUD…
Sep 30, 2019
06ee502
update readme
chhavisharma Sep 30, 2019
16eed17
update readme
Sep 30, 2019
6297e4a
Merge branch 'master' of https://github.com/chhavisharma/Project3-CUD…
Sep 30, 2019
2eb077b
update readme
chhavisharma Sep 30, 2019
4519d21
update readme
Sep 30, 2019
58cabb5
Merge branch 'master' of https://github.com/chhavisharma/Project3-CUD…
Sep 30, 2019
cbf745f
update readme
chhavisharma Sep 30, 2019
65ac9b2
Motion Blur Images
Sep 30, 2019
34d4a8c
Merge branch 'master' of https://github.com/chhavisharma/Project3-CUD…
Sep 30, 2019
3d9c8b0
update readme
chhavisharma Sep 30, 2019
2a51ad0
update readme
chhavisharma Sep 30, 2019
c04659c
update readme
chhavisharma Sep 30, 2019
1c51424
Motion Blur Images
Sep 30, 2019
5899d58
Merge branch 'master' of https://github.com/chhavisharma/Project3-CUD…
Sep 30, 2019
8f647b9
update readme
chhavisharma Sep 30, 2019
79982d6
update readme
chhavisharma Sep 30, 2019
54bdcd9
update readme
chhavisharma Sep 30, 2019
cdafe85
Motion Blur Images
Sep 30, 2019
552b702
Merge branch 'master' of https://github.com/chhavisharma/Project3-CUD…
Sep 30, 2019
8a1c459
Images
Sep 30, 2019
4e92975
update readme
chhavisharma Sep 30, 2019
5c8e0ac
update readme
chhavisharma Sep 30, 2019
78fd70b
update readme
chhavisharma Sep 30, 2019
569f9c8
update readme
chhavisharma Sep 30, 2019
ce2c4dd
Final Cleanup
Sep 30, 2019
438aa82
Merge branch 'master' of https://github.com/chhavisharma/Project3-CUD…
Sep 30, 2019
797440c
update readme
chhavisharma Sep 30, 2019
d670f25
update readme
chhavisharma Sep 30, 2019
e8bae0c
update readme
chhavisharma Sep 30, 2019
5931de6
update readme
chhavisharma Sep 30, 2019
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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ set(headers
src/sceneStructs.h
src/preview.h
src/utilities.h
src/common.h
src/efficient.h
)

set(sources
Expand All @@ -84,6 +86,8 @@ set(sources
src/scene.cpp
src/preview.cpp
src/utilities.cpp
src/common.cu
src/efficient.cu
)

list(SORT headers)
Expand Down
149 changes: 144 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,152 @@
<p align="center">
<img src="build/cornell_coverpic2.png">
</p>

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)

### (TODO: Your README)
* Author: Chhavi Sharma ([LinkedIn](https://www.linkedin.com/in/chhavi275/))
* Tested on: Windows 10, Intel Core(R) Core(TM) i7-6700 CPU @ 3.40GHz 16GB,
NVIDIA Quadro P1000 4GB (MOORE100B-06)

### Index

- [Introduction]( https://github.com/chhavisharma/Project3-CUDA-Path-Tracer/blob/master/README.md#introduction )
- [Implementation Details]( https://github.com/chhavisharma/Project3-CUDA-Path-Tracer/blob/master/README.md#implementation-details )
- [Features](https://github.com/chhavisharma/Project3-CUDA-Path-Tracer/blob/master/README.md#features )
- [Description]( https://github.com/chhavisharma/Project3-CUDA-Path-Tracer/blob/master/README.md#description )
- [Analysis]( https://github.com/chhavisharma/Project3-CUDA-Path-Tracer/blob/master/README.md#analysis )
- [Some More Results and Bloopers](https://github.com/chhavisharma/Project3-CUDA-Path-Tracer/blob/master/README.md#more-rsults-and-bloopers)

### Introduction

Path tracing is a computer graphics method of rendering digital 3D images such that the global illumination is as close as possible to reality. Path Tracing is similar to ray tracing in which rays are cast from a virtual camera and traced through a simulated scene by random sampling to incrementally compute a final image. The random sampling process makes it possible to render some complex phenomena which are not handled in regular ray tracing such as multiple reflections.

### Implementation Details
We implement an estimation of the Bidirectional Scattering Distribution Function to compute the an estimated illumination per pixel in the image over several iterations. In reality: Rays leave light sources -> bounce around a scene and change color/intensity based on the scene’s materials -> some hit pixels in a camera/ our eyes. Our implementation simulations this phenomnenon in reverse where a ray is launched from our camera thorugh each pixel of the image, and it's subequent intersections and bounces in the scene are traced upto a certain depth to compute the final color of the pixel.
This is implemented by computing a single bounce at each time-step for all the rays in the image parallely to get maximum throughput.

The ray starts with an identity color which is modified multiplicatively as it hits differnet materials in the scene.
The bounce direction and colour intensity depend on various material properties and the angle of incidence. We simulate four types of materials i.e. Emissive, Diffused, Reflective, Refractive and their combinations.

### Features

#### Basic Features
- [x] BSDF Shading (Diffused, Reflective, Emissive)
- [x] Basic Stream Compaction to remove dead rays
- [x] Material type sort
- [x] First bounce intersection caching
#### Advance Features
- [x] BSDF Shading (Refractive, Percentage Combinations)
- [x] Stochasitc Sampled Anti Aliasing
- [x] Work Efficient Stream Compaction usnig Shared Memory
- [x] Motion Blur
- [ ] Depth of Field
- [ ] Loading OBJ files

Most features have been implemented with toggleable options.

### Description


- Shading using [BSDF](https://en.wikipedia.org/wiki/Bidirectional_scattering_distribution_function)
- Diffuse Reflection: Reflects all rays randomly in the normal facing semi-sphere.
- Specular Reflection: Reflects the incoming ray about the normal where angle of incidence is equal to the angle of relection (mirror like behaviour).
- Refraction: Allows ray to pass through the media based on the ratio of the refractive index of the two mediums [snell's law](https://en.wikipedia.org/wiki/Snell%27s_law)
- Emissive Media: Rays in our computation terminate at these materials since they emit light.
- Percentage combinations/Probabiltiy splits between properties.


<p align="center">
Refraction | Reflection | Diffuese
</p>
<p align="center">
<img src="build/cornell_refraction.png" width="260" alt="Refraction" />
<img src="build/cornell_reflection.png" width="260" alt="Reflection"/>
<img src="build/cornell_diffuese.png" width="260" alt="Diffuese"/>
</p>


<p align="center">
Refract-Reflect-50-50 | Emmisive | Refract-Reflect-30-70
</p>
<p align="center">
<img src="build/cornell_Refract-Reflect-50-50.png" width="260" alt="Refract-Reflect-50-50" />
<img src="build/cornell_emmisive.png" width="260" alt="Emmisive" />
<img src="build/cornell_70-30_ref_rel.png" width="260" alt="Refract-Reflect-30-70" />
</p>


- Stream Compaction: We reorganise the rays that have terminated, either by hitting a source of light, or reaching maximum depth, by using stream compaction so that more cuda aprs can exit early when they find all theri theireads terminated. This reduces unnecessary compute per bounce operation and in turn speeds up the rendering.
- We also sort the rays by material type in order to allow continous memory access.
- First Bounce Intersection caching speeds up each iteration trememdously. Since there is no uncertanility in the first ray intersection computation we can cache the intersections at the begining of the first iteration and use it for all successive iterations. The first iteration als has the maximum number of rays therefore caching then at iter 0 shows drastic speedup for the rest of the iterations.

<p align="center">
<img src="img/FBC.png" width="600"/>
</p>



- AntiALiasing: We use anti-aliasing, a technique used to add greater realism to a digital image by smoothing jagged edges on curved lines and diagonals. We do this by randomly shifting the ray location per pixel instead of the center.

<p align="center">
<img src="img/aa.PNG" width="600"/>
</p>


- Motion Blur: We implemtned motion blur by adding a veolity to an object of choice. As a result at each iteration, the object was rendered at a slightly translated location appearing giving the motion blur effect.


Motion Blur Screen Captures

<p align="center">
<img src="build/mb11.png" width="420"/>
<img src="build/mb22.png" width="420"/>
</p>

<p align="center">
<img src="img/mb1.PNG" width="420" height="420"/>
<img src="img/mb4.PNG" width="420" height="420" />
</p>


### Analysis

- Stream compaction helps most after a few bounces. We show the contrast in runtime and number ofrays processed with and without stream comapction in the following figures. These clearly show that stream comapction speeds up the rendering.

<p align="center">
<img src="img/plots.PNG"/>
</p>

- Opening up the scene by removing two walls allows more light to escape. Stream compaction in a closed scene senario would not help much if there aren't many premature terminated rays. In case of more open scenes, stream comaption allows more warps of threads to exit and not idle.

<p align="center">
<img src="img/CLosedOpen.png" width="600"/>
</p>

<p align="center">
<img src="img/cornell.2019-09-30_04-21-28z.5000samp.png" width="300"/>
<img src="img/cornell.2019-09-30_04-28-55z.5000samp.png" width="300"/>
</p>

### More Rsults and Bloopers

1. Bloopers (Mostly motion blur)
<p align="center">
<img src="img/cornell.2019-09-28_03-45-01z.232samp.png" width="260"/>
<img src="img/cornell.2019-09-28_05-00-15z.2959samp.png" width="260"/>
<img src="img/cornell.2019-09-28_05-15-10z.5000samp.png" width="260"/>
</p>

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

2. Additional Results

<p align="center">
<img src="build/cornell.2019-09-30_05-12-34z.4512samp.png"/>
</p>
<p align="center">
<img src="build/cornell_coverpic.png">
</p>
Binary file added Stats.xlsx
Binary file not shown.
Binary file added build/cornell.2019-09-28_00-10-41z.4965samp.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 build/cornell.2019-09-28_00-10-41z.5000samp.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 build/cornell.2019-09-28_00-34-07z.5000samp.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 build/cornell.2019-09-28_00-46-49z.5000samp.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 build/cornell.2019-09-28_02-04-11z.5000samp.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 build/cornell.2019-09-28_03-16-00z.5000samp.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 build/cornell.2019-09-28_03-45-01z.232samp.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 build/cornell.2019-09-28_05-00-15z.2959samp.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 build/cornell.2019-09-28_05-00-15z.3530samp.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 build/cornell.2019-09-28_05-00-15z.3568samp.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 build/cornell.2019-09-28_05-15-10z.434samp.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 build/cornell.2019-09-28_05-15-10z.5000samp.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 build/cornell.2019-09-28_05-15-10z.702samp.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 build/cornell.2019-09-28_05-34-43z.3007samp.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 build/cornell.2019-09-28_05-38-08z.3011samp.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 build/cornell.2019-09-28_05-48-01z.3006samp.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 build/cornell.2019-09-29_10-15-46z.2846samp.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 build/cornell.2019-09-29_23-13-09z.5000samp.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 build/cornell.2019-09-29_23-59-06z.2318samp.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 build/cornell.2019-09-29_23-59-06z.2393samp.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 build/cornell.2019-09-30_03-16-41z.5000samp.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 build/cornell.2019-09-30_04-21-28z.5000samp.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 build/cornell.2019-09-30_04-28-55z.5000samp.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 build/cornell.2019-09-30_04-31-03z.3441samp.png
Binary file added build/cornell.2019-09-30_04-31-03z.3767samp.png
Binary file added build/cornell.2019-09-30_05-12-34z.4512samp.png
Binary file added build/cornell.2019-09-30_05-12-34z.4540samp.png
Binary file added build/cornell.2019-09-30_05-12-34z.4555samp.png
Binary file added build/cornell.2019-09-30_05-25-56z.3141samp.png
Binary file added build/cornell.2019-09-30_05-25-56z.3160samp.png
Binary file added build/cornell_70-30_ref_rel.png
Binary file added build/cornell_Refract-Reflect-50-50.png
Binary file added build/cornell_coverpic.png
Binary file added build/cornell_coverpic2.png
Binary file added build/cornell_diffuese.png
Binary file added build/cornell_emmisive.png
Binary file added build/cornell_reflection.png
Binary file added build/cornell_refraction.png
Binary file added build/mb11.png
Binary file added build/mb22.png
Binary file added img/CLosedOpen.png
Binary file added img/FBC.png
Binary file added img/aa.PNG
Binary file added img/cornell.2019-09-28_00-10-41z.4965samp.png
Binary file added img/cornell.2019-09-28_00-10-41z.5000samp.png
Binary file added img/cornell.2019-09-28_00-34-07z.5000samp.png
Binary file added img/cornell.2019-09-28_00-46-49z.5000samp.png
Binary file added img/cornell.2019-09-28_02-04-11z.5000samp.png
Binary file added img/cornell.2019-09-28_03-16-00z.5000samp.png
Binary file added img/cornell.2019-09-28_03-45-01z.232samp.png
Binary file added img/cornell.2019-09-28_05-00-15z.2959samp.png
Binary file added img/cornell.2019-09-28_05-00-15z.3530samp.png
Binary file added img/cornell.2019-09-28_05-00-15z.3568samp.png
Binary file added img/cornell.2019-09-28_05-15-10z.434samp.png
Binary file added img/cornell.2019-09-28_05-15-10z.5000samp.png
Binary file added img/cornell.2019-09-28_05-15-10z.702samp.png
Binary file added img/cornell.2019-09-28_05-34-43z.3007samp.png
Binary file added img/cornell.2019-09-28_05-38-08z.3011samp.png
Binary file added img/cornell.2019-09-28_05-48-01z.3006samp.png
Binary file added img/cornell.2019-09-29_10-15-46z.2846samp.png
Binary file added img/cornell.2019-09-29_23-13-09z.5000samp.png
Binary file added img/cornell.2019-09-29_23-59-06z.2318samp.png
Binary file added img/cornell.2019-09-29_23-59-06z.2393samp.png
Binary file added img/cornell.2019-09-30_03-16-41z.5000samp.png
Binary file added img/cornell.2019-09-30_04-21-28z.5000samp.png
Binary file added img/cornell.2019-09-30_04-28-55z.5000samp.png
Binary file added img/cornell.2019-09-30_04-31-03z.3441samp.png
Binary file added img/cornell.2019-09-30_04-31-03z.3767samp.png
Binary file added img/cornell_cover.png
Binary file added img/graph1_withoutSC_time.pmg
Binary file not shown.
Binary file added img/graph1_withoutSC_time.png
Binary file added img/graph2_thrustSC_rays.png
Binary file added img/graph2_thrustSC_time.png
Binary file added img/graph3_WESC_rays.png
Binary file added img/graph3_WESC_time.png
Binary file added img/mb1.PNG
Binary file added img/mb2.PNG
Binary file added img/mb3.PNG
Binary file added img/mb4.PNG
Binary file added img/plots.PNG
23 changes: 21 additions & 2 deletions scenes/cornell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,21 @@ MATERIAL 4
RGB .98 .98 .98
SPECEX 0
SPECRGB .98 .98 .98
REFL 1
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Specular white
MATERIAL 5
RGB .98 .98 .98
SPECEX 0
SPECRGB .524 .80 .92.2
REFL 0.8
REFR 0.2
REFRIOR 1.66
EMITTANCE 0

// Camera
CAMERA
RES 800 800
Expand Down Expand Up @@ -111,7 +121,16 @@ SCALE .01 10 10
// Sphere
OBJECT 6
sphere
material 4
material 5
TRANS -1 4 -1
ROTAT 0 0 0
SCALE 3 3 3


// Ceiling light 2
OBJECT 7
cube
material 0
TRANS 0 10 4
ROTAT 0 0 0
SCALE 5 .2 1
Loading