Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ae2caa6
Diffuse working(?)
zedward23 Sep 27, 2022
7dafb92
specular working yay
zedward23 Sep 28, 2022
73a95c5
first cache
zedward23 Sep 28, 2022
5aa82a7
Memsort
zedward23 Sep 29, 2022
c29ba9d
Tiny Obj Triangles working
zedward23 Oct 3, 2022
06d26a0
ray not making out of glass
zedward23 Oct 4, 2022
be60f72
refractive working
zedward23 Oct 5, 2022
05fb304
Anti alias, Strat Samp, and failed SSS
zedward23 Oct 6, 2022
24b86f5
dof
zedward23 Oct 6, 2022
033b0b1
Add header
zedward23 Oct 7, 2022
9fc20a3
References
zedward23 Oct 7, 2022
1fec50a
Outlining features
zedward23 Oct 7, 2022
93bd4c8
brief edit
zedward23 Oct 7, 2022
c7d88d9
writeup
zedward23 Oct 7, 2022
3475fc1
imgs
zedward23 Oct 7, 2022
53890b3
Merge branch 'main' of https://github.com/zedward23/Project3-CUDA-Pat…
zedward23 Oct 7, 2022
faa65f4
rough images
zedward23 Oct 7, 2022
f38123a
add more imgs
zedward23 Oct 7, 2022
dd9e4d8
images lol
zedward23 Oct 9, 2022
dc64d87
Add images and charts
zedward23 Oct 9, 2022
dc9ad5a
moar charts
zedward23 Oct 9, 2022
8f46f70
renamed
zedward23 Oct 9, 2022
27e6cbe
renamed
zedward23 Oct 9, 2022
7b9265c
amogus
zedward23 Oct 9, 2022
b8b68a1
update readme
zedward23 Oct 9, 2022
664c32c
update readme
zedward23 Oct 9, 2022
240608a
more imgs
zedward23 Oct 9, 2022
7dfea73
finishing up
zedward23 Oct 9, 2022
56a2433
rename
zedward23 Oct 9, 2022
6576463
Merge branch 'main' of https://github.com/zedward23/Project3-CUDA-Pat…
zedward23 Oct 9, 2022
d51a3e1
update img
zedward23 Oct 9, 2022
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
131 changes: 126 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,132 @@ 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)
* Edward Zhang
* https://www.linkedin.com/in/edwardjczhang/
* https://zedward23.github.io/personal_Website/

* Tested on: Windows 10 Home, i7-11800H @ 2.3GHz, 16.0GB, NVIDIA GeForce RTX 3060 Laptop GPU

### (TODO: Your README)
## Background
The Cuda Path Tracer Project - The Big Boi

*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.
## Representative Render
![](img/amogus.png)

### Requirements Fulfilled
#### Core Features
- Ideal Diffuse
- Specular (perfect and imperfect)
- Ray Termination using Stream Compaction
- Contiguous Memory Usage for Difference Materials
- Caching the first ray bounce
#### Additional Features
- OBJ Loading (with bounding box) (2)
- Refraction using Schlick approximation (2)
- Physically based Depth of Field effect (2)
- Antialiasing (2)
- Stratified Random Hemisphere Sampling (3)

## Ideal Diffuse


An ideal diffuse material shows the characteristics of being a perfectly smooth matte surface; approximated by lambertian shading in rasterization but it only judged by multiplicative color accumilation in this path tracer.
## Specular
Specular materials showcase the characteristics of being polished or shiny. Reflective in nature, meaning that rays that interact with this surface are reflected away from the surface in a more focused manner.

### Perfect
![](img/depthOfField.png)

Perfectly specular materials are like mirrors since reflection angles are deterministic.
### Imperfect
![](img/imperfSpec100ex[.png)

Specular Exponent: 100 (As the exponent increases, the surface gets closer and closer to being perfectly specular.

Imperfectly specular materials are just shiny since reflection angles are, while more focused than diffuse materials, nondeterministic.
## Stream Compaction
![](img/RayTerminationChart.png)

Remove all rays that hit nothing in the scene; this significantly improved performance as maximum iteration depth was increased; this is likely because there were less rays to process the deeper into the iteration we had to go when we had stream compaction active.

Numbers taken with material sort inactive, but with ray cache active.

## Material Sorting in Memory
![](img/MaterialSortChart.png)

Sort all ray intersections by the materials they hit with the intent of enabling memory coalescence for bsdf interactions based on different materials. This did not pan out to be an optimization; the sort employed by thrust sort seems to only have added a constant lump sum runtime for the actual runtime of the employed sorting algorithm.

Numbers taken with with ray cache and ray terminiation active.

## Ray Caching
![](img/RayCacheChart.png)

The first rays cast into the scene are deterministic based on the camera's position; thus there is no need to recalculate their interactions and intersections for each iteration that the Pathtracer renders. This offered a marginal improvement in runtime that gradually widened as max iteration depth was increased; this is likely because the increased depths allowed for more work saved by ray caching.

## OBJ Loading
![](img/basicObjTest.png)
Tested this implementation against importing a basic cube that was stored as an OBJ.

Implemented functionaltiy loads in an arbitrary, but untextured mesh. Implemented bounding box acceleration data structure as well.

![](img/ObjPerformance.png)
Performance is significantly improved when loading the Low Poly Among Us Crewmate obj into the scene as shown in chart above. This is because the triangles inside of the bounding box did not need to be individually tested for intersection unless the ray was actually inside of that bounding box of the object itself.

## Refractive
![](img/Transmissive.png)

Refractive materials like glass both refract and reflect light. Using schlick approximation, we nondeterministically have some rays get refracted into the object while other rays are reflected away.

## Depth of Field
![](img/realDOF.png)
Focal Dist of 12
Lens Radius of 1

Lenses in real life have radii and focal distances (based on their concavity) which bend light rays in a way that only certain objects a certain distance away are actually in focus. This is approximated using random disk sampling to artificially bend cameras cast into screen space.

## Antialiasing

Sending out multiple rays approximated by small scale directional jitter per camera ray per pixel to get sub-pixel values.

![](img/AAClose.png)

Close up of a sphere with Anti Aliasing applied.

![](img/withoutAAClose.png)

Close up of a sphere without Anti Aliasing applied.

A closer look:

![](img/noAA.png)

Less iterations but smoother.

![](img/yesAA.png)

More iterations but more jagged edges.

## Stratified Sampling
Improve random hemisphere sampling by using a grid to stratify the portions of the hemisphere upon which we sample ray directions.
![](img/StratSampling.png)

Random ray bounces employing stratified random hemisphere sampling.

![](img/RandomSampling.png)

Standard random ray bounces used for random hemisphere sampling.

The shadows are slightly different in terms of noise levels, though they converge to very similar results.

## References

* [PBRT] Physically Based Rendering, Second Edition: From Theory To Implementation. Pharr, Matt and Humphreys, Greg. 2010.
* Antialiasing and Raytracing. Chris Cooksey and Paul Bourke, http://paulbourke.net/miscellaneous/aliasing/
* [Sampling notes](http://graphics.ucsd.edu/courses/cse168_s14/) from Steve Rotenberg and Matteo Mannino, University of California, San Diego, CSE168: Rendering Algorithms

## Bloopers
![](img/blooper.png)
![](img/GlassBlooper.png)
![](img/GlassBlooper1.png)

These are my most visually interesting bloopers; I got lots of black and white screens. Most of my obj loading bloopers were just the object not showing up in the scene.
Binary file added img/AAClose.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/BasicDiffuseCornell.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/DOF.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/DOF5.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/GlassBlooper.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/GlassBlooper1.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/ImperfSpec1.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/MaterialSortChart.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/NotAA.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/ObjPerformance.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/RandomSampling.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/RayCacheChart.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/RayTerminationChart.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/StratSampling.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/Transmissive.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/amogus.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/basicObjTest.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/blooper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added img/diffuse.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/imperfSpec.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/imperfSpec100ex[.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/noAA.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/objInitialTest.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/perfectSpecular.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/perfspec.png
Binary file added img/realDOF.png
Binary file added img/refractive.png
Binary file added img/withAA.png
Binary file added img/withoutAAClose.png
Binary file added img/yesAA.png
6 changes: 6 additions & 0 deletions scenes/amogus.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
newmtl initialShadingGroup
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
37 changes: 33 additions & 4 deletions scenes/cornell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ REFL 0
REFR 0
REFRIOR 0
EMITTANCE 5
ABSORPTION 0

// Diffuse white
MATERIAL 1
Expand All @@ -17,6 +18,7 @@ REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0
ABSORPTION 0

// Diffuse red
MATERIAL 2
Expand All @@ -27,6 +29,7 @@ REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0
ABSORPTION 0

// Diffuse green
MATERIAL 3
Expand All @@ -37,16 +40,40 @@ REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0
ABSORPTION 0

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

// Refractive
MATERIAL 5
RGB .98 .98 .98
SPECEX 0
SPECRGB .98 .98 .98
REFL 1
REFR 1
REFRIOR 1.5
EMITTANCE 0
ABSORPTION 0

// SSS
MATERIAL 6
RGB .98 .98 .98
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 1.35
EMITTANCE 0
ABSORPTION .03

// Camera
CAMERA
Expand All @@ -55,6 +82,8 @@ FOVY 45
ITERATIONS 5000
DEPTH 8
FILE cornell
FOCAL 0
LENS_LEN 0
EYE 0.0 5 10.5
LOOKAT 0 5 0
UP 0 1 0
Expand Down Expand Up @@ -111,7 +140,7 @@ SCALE .01 10 10
// Sphere
OBJECT 6
sphere
material 4
TRANS -1 4 -1
material 1
TRANS 0 4 0
ROTAT 0 0 0
SCALE 3 3 3
SCALE 4 4 4
6 changes: 6 additions & 0 deletions scenes/cubeobj.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
newmtl initialShadingGroup
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
Loading