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: Lindsay Smith #25

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
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
308435b
beginning
lsmith24 Oct 5, 2021
36573a1
hover
lsmith24 Oct 6, 2021
f5fba29
basic shading
lsmith24 Oct 7, 2021
684543a
anti aliasing and refraction
lsmith24 Oct 7, 2021
a716138
mesh loading start
lsmith24 Oct 10, 2021
e8ff22d
initial photos
lsmith24 Oct 10, 2021
e6fe78d
rename
lsmith24 Oct 10, 2021
d4fc4b9
Update README.md
lsmith24 Oct 10, 2021
83beaa9
obj loading fixed
lsmith24 Oct 10, 2021
7797a98
better dof
lsmith24 Oct 10, 2021
3952389
Merge branch 'day4'
lsmith24 Oct 11, 2021
dcbf89f
images
lsmith24 Oct 11, 2021
88cbace
Update README.md
lsmith24 Oct 11, 2021
498c98f
direct lighting
lsmith24 Oct 11, 2021
e0a148d
Merge branch 'main' of https://github.com/lsmith24/Project3-CUDA-Path…
lsmith24 Oct 11, 2021
5f11103
Update README.md
lsmith24 Oct 11, 2021
0f46d4f
cow image
lsmith24 Oct 11, 2021
df386aa
Merge branch 'main' of https://github.com/lsmith24/Project3-CUDA-Path…
lsmith24 Oct 11, 2021
d5b6b5f
Update README.md
lsmith24 Oct 11, 2021
1b961a4
direct light img
lsmith24 Oct 11, 2021
35c73fc
Merge branch 'main' of https://github.com/lsmith24/Project3-CUDA-Path…
lsmith24 Oct 11, 2021
73b298f
Update README.md
lsmith24 Oct 11, 2021
a0b5d6e
nice images
lsmith24 Oct 12, 2021
8e08031
Merge branch 'main' of https://github.com/lsmith24/Project3-CUDA-Path…
lsmith24 Oct 12, 2021
03028d9
more images
lsmith24 Oct 12, 2021
994db58
Update README.md
lsmith24 Oct 12, 2021
4185944
Update README.md
lsmith24 Oct 12, 2021
f959db0
better cow
lsmith24 Oct 12, 2021
7a199ed
Merge branch 'main' of https://github.com/lsmith24/Project3-CUDA-Path…
lsmith24 Oct 12, 2021
923d9ab
pics
lsmith24 Oct 12, 2021
0e0a8ab
Update README.md
lsmith24 Oct 12, 2021
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
60 changes: 55 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,61 @@ 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)
* Lindsay Smith
* [LinkedIn](https://www.linkedin.com/in/lindsay-j-smith/), [personal website](https://lindsays-portfolio-d6aa5d.webflow.io/).
* Tested on: Windows 10, i7-11800H 144Hz 16GB RAM, GeForce RTX 3060 512GB SSD (Personal Laptop)

### (TODO: Your README)
![](img/anti_aliasing_cover.png)

*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
* Basic pathtracer
* Refractive, Reflective, and Diffused surfaces
* Anti-Aliasing
* OBJ Loading
* Depth of Field
* Direct Lighting

This pathtracer utilized [Physically Based Rendering](https://pbr-book.org/) for reference

### Materials
There are three different types of materials that I implemented.

![](img/materials.png)

### Anti-Aliasing
In the left photo we can see the step-like edge of the sphere, but in the right one where anti-aliasing has been implemented it appears more smooth. This was implemented by slightly jittering the ray origin when calculating the direction. This provides the slight blur that we see around the edges of the box.
![](img/anti_aliasing_cover_2-01.png)


### OBJ Loading
The OBJ loader allows for .obj files to be uploaded to the pathtracer. It utilizes a Triangle geom type and reads the OBJ file to determine where the triangles and points on the triangles should exist. I used [tinyObj](https://github.com/tinyobjloader/tinyobjloader) to implement this.

![](img/cornell.2021-10-12_05-09-13z.5000samp.png)
![](img/new_cow.png)

### Depth of Field
For the depth of field we want to be able to shift the focus of our camera so that only certain parts of the image appear in focus. The first photo has no depth of field effect for reference. In the second photo we can see that the front sphere looks blurred due to the larger focal distance (13). With a lower value for the focal distance (8) the back sphere/background gets blurred.

![](img/no_dof.png)
![](img/dof_2.png)
![](img/dof_4.png)

### Direct Lighting
To get a direct lighting effect in our images we want to make the last bounce of each ray hit a light source. We do this by randomly selecting a point on a randomly selected light and setting the direction of the ray to that point. The first image is without direct lighting, and the second one we can see is overall brighter with the direct lighting enabled.

![](img/no_direct_lighting_cube.png)
![](img/direct_light_cube.png)

### Bloopers
A bit too much depth of field

![](img/cornell.2021-10-07_14-28-06z.344samp.png)


Cube OBJ is just a triangle?

![](img/sphere.2021-10-10_02-54-37z.165samp.png)

Lighting mishap

![](img/dodecahedron_blooper.png)
Binary file added img/anti_aliasing_cover.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/anti_aliasing_cover_2-01.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/basic 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/basic specular.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/better_anti_aliasing.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/blue_glass.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/clear_glass.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/cornell.2021-10-07_03-43-35z.332samp.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/cornell.2021-10-07_03-58-40z.1782samp.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/cornell.2021-10-07_04-01-39z.1466samp.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/cornell.2021-10-07_04-06-49z.429samp.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/cornell.2021-10-07_05-22-34z.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 img/cornell.2021-10-07_10-26-56z.2214samp.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/cornell.2021-10-07_10-31-08z.2285samp.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/cornell.2021-10-07_10-31-08z.3067samp.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/cornell.2021-10-07_14-28-06z.344samp.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/cornell.2021-10-07_14-38-56z.1190samp.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/cornell.2021-10-07_14-47-26z.2215samp.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/cornell.2021-10-07_14-50-24z.2950samp.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/cornell.2021-10-07_15-00-46z.4229samp.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/cornell.2021-10-10_02-31-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 img/cornell.2021-10-10_03-06-02z.453samp.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/cornell.2021-10-12_05-09-13z.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 img/cover.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/cow.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/diffuse.png
Binary file added img/direct_light_cube.png
Binary file added img/direct_lighting.png
Binary file added img/dodecahedron.png
Binary file added img/dodecahedron_blooper.png
Binary file added img/dof_1.png
Binary file added img/dof_2.png
Binary file added img/dof_3.png
Binary file added img/dof_4.png
Binary file added img/dof_none.png
Binary file added img/materials.png
Binary file added img/new_cow.png
Binary file added img/no_anti_aliasing.png
Binary file added img/no_direct_lighting_cube.png
Binary file added img/no_dof.png
Binary file added img/some_anti_aliasing.png
Binary file added img/sphere.2021-10-10_02-54-37z.165samp.png
Binary file added img/sphere.2021-10-10_03-14-14z.57samp.png
214 changes: 187 additions & 27 deletions scenes/cornell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,86 @@ REFR 0
REFRIOR 0
EMITTANCE 0

// Glass
MATERIAL 5
RGB 1.0 1.0 1.0
SPECEX 0
SPECRGB 1.0 1.0 1.0
REFL 0
REFR 1
REFRIOR 1.5
EMITTANCE 0

// Blue Glass
MATERIAL 6
RGB .98 .98 .98
SPECEX 0
SPECRGB .85 .85 .98
REFL 0
REFR 1
REFRIOR 1.65
EMITTANCE 0

// Diffuse Blue
MATERIAL 7
RGB .35 .85 .85
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Diffuse Purple
MATERIAL 8
RGB .8 .6 1.0
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Specular yellow
MATERIAL 9
RGB 1.0 .8 0
SPECEX 0
SPECRGB 1.0 .8 0
REFL 1
REFR 0
REFRIOR 0
EMITTANCE 0

// Diffuse Pink
MATERIAL 10
RGB 1.0 .6 .8
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Specular blue
MATERIAL 11
RGB .6 .8 1.0
SPECEX 0
SPECRGB .6 .8 1.0
REFL 1
REFR 0
REFRIOR 0
EMITTANCE 0

// Diffuse yellow
MATERIAL 12
RGB 1 1 .6
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Camera
CAMERA
RES 800 800
Expand All @@ -59,59 +139,139 @@ 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
//OBJECT 0
//cube
//material 0
//TRANS 0 17 0
//ROTAT 0 0 0
//SCALE 10 .3 10

// Floor
OBJECT 1
OBJECT 0
cube
material 1
material 2
TRANS 0 0 0
ROTAT 0 0 0
SCALE 10 .01 10
SCALE 20 .01 20

// Ceiling
OBJECT 2
OBJECT 1
cube
material 1
TRANS 0 10 0
material 0
TRANS 0 20 0
ROTAT 0 0 90
SCALE .01 10 10

// Wall Light
OBJECT 2
cube
material 0
TRANS 2 10 -9.5
ROTAT 0 90 0
SCALE .01 7 7

// Back wall
OBJECT 3
cube
material 1
TRANS 0 5 -5
material 8
TRANS 0 10 -10
ROTAT 0 90 0
SCALE .01 10 10
SCALE .01 20 20

// Left wall
// Wall Light
OBJECT 4
cube
material 2
TRANS -5 5 0
ROTAT 0 0 0
SCALE .01 10 10
material 0
TRANS -9.5 10 2
ROTAT 90 0 0
SCALE .01 7 7

// Right wall
// Left wall
OBJECT 5
cube
material 3
TRANS 5 5 0
material 7
TRANS -10 10 0
ROTAT 0 0 0
SCALE .01 10 10
SCALE .01 20 20

// Sphere
OBJECT 6
sphere
material 4
TRANS -1 4 -1
material 5
TRANS -5 8 -1
ROTAT 0 0 0
SCALE 3 3 3

// Sphere 2
OBJECT 7
sphere
material 6
TRANS -3 6 5
ROTAT 0 0 0
SCALE 3 3 3

// Sphere 3
OBJECT 8
sphere
material 9
TRANS 3 3 6
ROTAT 0 0 0
SCALE 1 1 1

// Sphere 4
OBJECT 9
sphere
material 11
TRANS 0 9 -2
ROTAT 0 0 0
SCALE 2 2 2

// Cube
OBJECT 10
cube
material 3
TRANS 0 4 5
ROTAT 45 45 0
SCALE 1 1 1

// Cube
OBJECT 11
cube
material 10
TRANS 5 7 -1
ROTAT 45 45 0
SCALE 2 2 2

// Cube
OBJECT 12
cube
material 2
TRANS -5 11 2
ROTAT 45 20 45
SCALE 2 2 2

// Sphere 4
OBJECT 13
sphere
material 8
TRANS 3 3 -5
ROTAT 0 0 0
SCALE 3 3 3

// Rectangle
OBJECT 14
cube
material 12
TRANS 3 2 0
ROTAT 0 30 0
SCALE 3 1 2

// OBJ
OBJECT 15
../obj/dodecahedron.obj
material 6
FILENAME ../obj/dodecahedron.obj
TRANS 0 4 0
ROTAT 0 0 0
SCALE 2 2 2
Loading