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: Zirui Zang #3

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
da26d10
finished basics
excuice Oct 3, 2021
9354697
finished obj
excuice Oct 4, 2021
e5edcfd
finished sorting
excuice Oct 4, 2021
ec2e437
add some txt
excuice Oct 5, 2021
8e23282
finished defocus
excuice Oct 5, 2021
b848c0a
some error
excuice Oct 5, 2021
3c96f13
finish
excuice Oct 5, 2021
66c3298
Update README.md
zzangupenn Oct 5, 2021
41da814
Update README.md
zzangupenn Oct 5, 2021
c079929
Update README.md
zzangupenn Oct 5, 2021
094c741
Update README.md
zzangupenn Oct 5, 2021
86a9815
Update README.md
zzangupenn Oct 5, 2021
d9d26d8
Update README.md
zzangupenn Oct 5, 2021
77210f6
Update README.md
zzangupenn Oct 5, 2021
b159ce3
Update README.md
zzangupenn Oct 5, 2021
1812e6a
Create README.md
zzangupenn Oct 5, 2021
ad7a99b
Create README.md
zzangupenn Oct 5, 2021
5ac043a
finish
excuice Oct 5, 2021
99e54f5
Merge branch 'main' of github.com:zzangupenn/Project3-CUDA-Path-Tracer
excuice Oct 5, 2021
2923da9
Update README.md
zzangupenn Oct 5, 2021
88bbe8a
Update README.md
zzangupenn Oct 5, 2021
55b7bed
Update README.md
zzangupenn Oct 5, 2021
775d12d
Update README.md
zzangupenn Oct 5, 2021
3e8372d
Update README.md
zzangupenn Oct 5, 2021
3f344a3
Update README.md
zzangupenn Oct 5, 2021
0ceaaec
Update README.md
zzangupenn Oct 5, 2021
852695a
add img
excuice Oct 5, 2021
520af6e
Update README.md
zzangupenn Oct 5, 2021
fe8d05c
Update README.md
zzangupenn Oct 5, 2021
39531dc
Update README.md
zzangupenn Oct 5, 2021
64fbe37
Update README.md
zzangupenn Oct 5, 2021
3556298
add img
excuice Oct 6, 2021
cd7660d
Update README.md
zzangupenn Oct 6, 2021
c2447e8
Update README.md
zzangupenn Oct 6, 2021
2d7b944
Update README.md
zzangupenn Oct 6, 2021
257a053
add img
excuice Oct 6, 2021
9724bbb
Update README.md
zzangupenn Oct 6, 2021
34ef371
Update README.md
zzangupenn Oct 6, 2021
0481f8b
Update README.md
zzangupenn Oct 6, 2021
01d9a85
Update README.md
zzangupenn Oct 6, 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
54 changes: 49 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,55 @@ 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)
* Zirui Zang
* [LinkedIn](https://www.linkedin.com/in/zirui-zang/)
* Tested on: Windows 10, AMD Ryzen 7 3700X @ 3.60GHz 32GB, RTX2070 SUPER 8GB (Personal)

### (TODO: Your README)
## Photorealistic Rendering by Tracing Rays

*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.
In real life, rays come from light source, bounce between object surfaces before entering our eyes. Each bounce off an object surface carries information of that surface. In ray-tracing rendering, we can start from the eye (image plane), trace backwards through each pixel to the world and eventually to the light source. Such ray-tracing is repeated thousands of times and color information is averaged to give photorealistic effects.

<p align="center">
<img src="img/cornell.2021-10-05_21-17-44z.5000samp.png"
alt="deer"
width="600"/>
</p>

<p align="center">
<img src="img/cornell.2021-10-05_17-10-50z.5000samp.png"
alt="wolf"
width="600"/>
</p>



### Surface Scattering

Below list the 3 separate scattering surfaces implemented in this renderer. To make refracgive surface seen more realistic, schlicks approximation is used to make the surface the effect of Frenel reflections. Objects in the seen can use a combination of these 3 properties based on the bidirectional scattering distribution function (BSDF) of the surface.

| Lambertian | Reflective | Refractive | with Color |
| ------------ | ----------- | ----------- | ----------- |
| ![](scenes/cornell.2021-10-03_23-27-37z.3488samp.png) | ![](scenes/cornell.2021-10-03_23-34-37z.4309samp.png) | ![](scenes/cornell.2021-10-03_23-43-33z.1964samp.png) | ![](scenes/cornell.2021-10-04_00-14-05z.1925samp.png) |

## Features

### Depth of Field
Depth of Field is created by sampling with a non-zero aperture size.

| Close Focus | Far Focus |
| ------------- | ----------- |
| ![](img/cornell.2021-10-05_19-34-14z.1858samp.png) | ![](img/cornell.2021-10-05_21-11-55z.5000samp.png) |


### Anti-Aliasing
Anti-Aliasing is implemented by sub-pixel sampling.

| with Anti-Aliasing | without Anti-Aliasing |
| ------------- | ----------- |
| ![](img/aa1.png) | ![](img/aa0.png) |

### Other Features
1. .obj Mesh Import
2. Toggleable option to cache the first bounce intersections for re-use across all subsequent iterations, when not using anti-aliasing. Is is not used because AA is a must.
3. Elimiating terminated rays with Stream Compaction. This method definitely reduces empty thread launches and improves performance.
4. Efficient attempt to sort the ray by the material type before shading. No efficient improvement is seen with this method.
Binary file added img/aa0.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/aa1.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-05_17-10-50z.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-05_19-34-14z.1858samp.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-05_21-11-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 img/cornell.2021-10-05_21-17-44z.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 scenes/cornell.2021-10-03_23-27-37z.3488samp.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 scenes/cornell.2021-10-03_23-34-37z.4309samp.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 scenes/cornell.2021-10-03_23-43-33z.1964samp.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 scenes/cornell.2021-10-04_00-14-05z.1925samp.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 scenes/cornell.2021-10-04_19-03-52z.2097samp.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 scenes/cornell.2021-10-04_23-22-45z.3294samp.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 scenes/cornell.2021-10-05_01-11-01z.5000samp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
219 changes: 219 additions & 0 deletions scenes/deer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
// Emissive material (light)
MATERIAL 0
RGB 0.965, 0.933, 0.835
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 100

// Diffuse white
MATERIAL 1
RGB 0.933, 0.788, 0.612
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Diffuse navy blue
MATERIAL 2
RGB 0.039, 0.255, 0.345
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Diffuse green
MATERIAL 3
RGB 0.004, 0.227, 0.125
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

// deer
MATERIAL 5
RGB 0.98, 0.91, 0.878
SPECEX 0
SPECRGB 1, 0.761, 0.78
REFL 0.1
REFR 0.8
REFRIOR 1.2
EMITTANCE 0

// Diffuse orange
MATERIAL 6
RGB 0.38, 0.239, 0.035
SPECEX 0
SPECRGB 0.788, 0.71, 0.565
REFL 0.5
REFR 0
REFRIOR 0
EMITTANCE 0

// cloud
MATERIAL 7
RGB 0.847, 0.949, 1
SPECEX 0
SPECRGB 0.847, 0.949, 1
REFL 0
REFR 0.2
REFRIOR 1
EMITTANCE 0

// rock
MATERIAL 8
RGB 0.404, 0.404, 0.404
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// grass
MATERIAL 9
RGB 0.004, 0.227, 0.125
SPECEX 0
SPECRGB 0 0 0
REFL 0
REFR 0
REFRIOR 0
EMITTANCE 0

// Camera
CAMERA
RES 740 400
FOVY 37
ITERATIONS 5000
DEPTH 10
FILE cornell
EYE 2 5 11
LOOKAT 0 5 0
UP 0 1 0


// moon
OBJECT 0
sphere
material 0
TRANS -5 10 9
ROTAT 0 0 0
SCALE 3 3 3

// Floor
OBJECT 1
cube
material 1
TRANS 0 0 0
ROTAT 0 0 0
SCALE 30 .01 30


// wall 0
OBJECT 2
cube
material 3
TRANS 10 10 0
ROTAT 0 90 0
SCALE 20 20 0.1

// wall 1
OBJECT 3
cube
material 3
TRANS -10 10 0
ROTAT 0 90 0
SCALE 20 20 0.1

// wall 2
OBJECT 4
cube
material 2
TRANS 0 10 -10
ROTAT 0 0 0
SCALE 20 20 0.1

// wall 3
OBJECT 5
cube
material 2
TRANS 0 10 13
ROTAT 0 0 0
SCALE 20 20 0.1

// wall 4
OBJECT 4
cube
material 2
TRANS 0 10 -10
ROTAT 0 0 0
SCALE 20 20 0.1

// wall 5
OBJECT 4
cube
material 6
TRANS 10 5 -3
ROTAT 0 -45 0
SCALE 12 15 0.1

// wall 6
OBJECT 4
cube
material 6
TRANS -10 5 -3
ROTAT 0 45 0
SCALE 12 15 0.1



OBJECT 5
mesh ./cloud1.obj
material 7
TRANS -5 8 0
ROTAT 0 0 0
SCALE 0.5 0.3 0.5


OBJECT 5
mesh ./rock.obj
material 8
TRANS 10.5 -7 -7
ROTAT 0 0 0
SCALE 1 1 1

OBJECT 5
mesh ./grass.obj
material 9
TRANS 4 0 -2
ROTAT 0 0 0
SCALE 3 3 3


OBJECT 5
mesh ./deer.obj
material 5
TRANS -1 0 2
ROTAT 0 -30 0
SCALE 1.2 1.2 1.2



Loading