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

Project4: Qiaosen Chen #23

Open
wants to merge 37 commits into
base: base-code
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
52d27fb
add the implementation of scatterRay
giaosame Sep 30, 2020
250ab7a
add basic implementation of pathtrace()
giaosame Sep 30, 2020
0aff978
add first bounce cache
giaosame Sep 30, 2020
6e3cb0a
update first bounce cache implementation
giaosame Sep 30, 2020
543bc2e
add imgs
giaosame Sep 30, 2020
fbf77f0
add material sort inset
giaosame Sep 30, 2020
8c9b46d
add mid-project readme
giaosame Sep 30, 2020
9a13bb4
update mid-project readme
giaosame Sep 30, 2020
9b2d066
add gltf loader
giaosame Oct 6, 2020
b2a027e
add bounding box
giaosame Oct 7, 2020
8ca350a
add gltf mesh bounding volume intersection test
giaosame Oct 7, 2020
7b4b676
refine mesh intersection function and add correct bounding box inters…
giaosame Oct 7, 2020
6055c76
add depth of field
giaosame Oct 7, 2020
21bd9f1
add antialiasing
giaosame Oct 7, 2020
7da9bb1
add refract with Schlick's approximation
giaosame Oct 8, 2020
ddd375f
add stratified sampling
giaosame Oct 8, 2020
fe4b8ad
add direct lighting
giaosame Oct 9, 2020
008d5c7
add motion blur
giaosame Oct 10, 2020
1013ad9
add images
giaosame Oct 10, 2020
32e0edd
add readme
giaosame Oct 10, 2020
d31339e
add readme again
giaosame Oct 10, 2020
f40d513
update gltf transform
giaosame Oct 11, 2020
1b0adef
add implicit surfaces
giaosame Oct 12, 2020
5b96aff
add implicit surfaces
giaosame Oct 12, 2020
1da7042
add texture object binding
giaosame Oct 15, 2020
1efb950
add gltf texture mapping with flaws
giaosame Oct 16, 2020
539581c
add correct gltf texture mapping
giaosame Oct 16, 2020
50ddfd3
add normal texture mapping
giaosame Oct 17, 2020
95df1df
fine-tune gltf mesh loading
giaosame Oct 19, 2020
5be6d88
add denoiser gui
giaosame Oct 20, 2020
d5c2939
add denoising implementation
giaosame Oct 21, 2020
0daaca8
Merge branch 'base-code' into denoiser
giaosame Oct 21, 2020
75d3a0c
Merge pull request #1 from giaosame/denoiser
giaosame Oct 21, 2020
6750359
update scene files
giaosame Oct 21, 2020
4bbdd07
add readme
giaosame Oct 22, 2020
dc8ca41
update readme
giaosame Oct 22, 2020
91ec051
add updated readme
giaosame Oct 22, 2020
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
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ find_package(GLM REQUIRED)
include_directories(${GLM_INCLUDE_DIRS})

set(headers
external/include/json.hpp
external/include/material.h
external/include/mesh.h
external/include/gltf-loader.h
src/main.h
src/image.h
src/interactions.h
Expand All @@ -73,9 +77,13 @@ set(headers
src/sceneStructs.h
src/preview.h
src/utilities.h
src/fresnel.h
src/warpfunctions.h
src/implicitsurface.h
)

set(sources
external/include/gltf-loader.cc
src/main.cpp
src/stb.cpp
src/image.cpp
Expand Down
90 changes: 85 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,91 @@ CUDA Denoiser For CUDA Path Tracer

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

* (TODO) YOUR NAME HERE
* Tested on: (TODO) Windows 22, i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (Moore 2222 Lab)
* Qiaosen Chen
* [LinkedIn](https://www.linkedin.com/in/qiaosen-chen-725699141/), etc.
* Tested on: Windows 10, i5-9400 @ 2.90GHz 16GB, GeForce RTX 2060 6GB (personal computer).

### (TODO: Your README)
## Features

*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.
- A Trous Denoiser
- Gaussian Filter (extra credit)

## Denoised Results

- [Cornell Scene](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell.txt)

![Cornell Scene](./img/cornell_denoised_comparison.png)

- [Cornell_sdf Scene](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell_sdf.txt)

![Cornell_sdf Scene](./img/cornell_sdf_denoised_comparison.png)

## Performance Analysis

### The extra time denoising adds to the renders

| [cornell](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell.txt) | [cornell_ceiling_light](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell_ceiling_light.txt) | [cornell_glassball](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell_glassball.txt) | [cornell_mjolnir](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell_mjolnir.txt) |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![denoised_cornell](./img/denoised_cornell.png) | ![./img/denoised_cornell_ceiling_light](./img/denoised_cornell_ceilling_light.png) | ![denoised_cornell_glassball](./img/denoised_cornell_glassball.png) | ![denoised_cornell_mjolnir](./img/denoised_cornell_mjolnir.png) |

![Running Time of 100 Iterations between Render with and without Denoiser](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/img/Running%20Time%20of%20100%20Iterations%20between%20Render%20with%20and%20without%20Denoiser.png)

As we can see from the above table, the render with denoiser actually takes a little bit more time to run 100 iterations than the render without denoiser. It's reasonable to spend more time to run extra 3 iteration to compute the A Trous filtering, but the difference in running time is very small, so the Edge-Avoiding A-Trous Wavelet Transform algorithm is very efficient.

### The influences of denoiser on the number of iterations

| [cornell](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell.txt) with Denoiser Using 100 Iters | [cornell](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell.txt) with Denoiser Using 300 Iters | [cornell](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell.txt) without Denoiser Using 1000 Iters |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![cornell with Denoiser Using 100 Iters](./img/cornell_denoising_100iters.png) | ![cornell with Denoiser Using 300 Iters](./img/cornell_denoising_300iters.png) | ![cornell without Denoiser Using 1000 Iters](./img/cornell_1000iters.png) |
| [cornell_glassball](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell_glassball.txt) with Denoiser Using 100 Iters | [cornell_glassball](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell_glassball.txt) with Denoiser Using 300 Iters | [cornell_glassball](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell_glassball.txt) without Denoiser Using 1000 Iters |
| ![cornell_glassball with Denoiser Using 100 Iters](./img/cornell_glassball_denoising_100iters.png) | ![cornell_glassball with Denoiser Using 300 Iters](./img/cornell_glassball_denoising_300iters.png) | ![cornell_glassball without Denoiser Using 1000 Iters](./img/cornell_glassball_1000iters.png) |

As the [project Introduction](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/INSTRUCTION.md) pointing out, "acceptably smooth" is subjective. So I choose the images without being denoised as the evaluation standard, although there still exists some noise in those image after 1000 iteration. There are still a lot of blurred area can be seen in the denoised images after 100 iterations. Comparing with the above 2 groups of images, I think the denoised images output by the render after 300 iterations have the best performance and they show the "acceptably smooth" results. Thus, in my point of view, the render with denoiser can take less 70% of iterations than the original render to get smooth output.

### The influences of denoiser on the runtime at different resolutions

![Running Time of 100 Iterations at Different Resolutions](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/img/Running%20Time%20of%20100%20Iterations%20at%20Different%20Resolutions.png)

Apparently, larger resolution means more running time. From the above char, we know that denoiser almost doesn't have any influences on the runtime at different resolutions.

### Effectiveness of denoiser on the different materials

| [cornell_diff_mats](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell_diff_mats.txt) with Denoiser Using 100 Iters | [cornell_diff_mats](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell_diff_mats.txt) with Denoiser Using 300 Iters | [cornell_diff_mats](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/scenes/cornell_diff_mats.txt) without Denoiser Using 1000 Iters |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![cornell_diff_mats_denoised_100iters](./img/cornell_diff_mats_denoised_100iters.png) | ![cornell_diff_mats_denoised_300iters](./img/cornell_diff_mats_denoised_300iters.png) | ![cornell_diff_mats_1000iters](./img/cornell_diff_mats_1000iters.png) |

The denoiser has a great performance on those materials showing a smooth surface, such as specular material and glass material, even the rendered images after running the program 100 iterations shows the "acceptably smooth" surfaces. However, the denoiser doesn't do a good job on the soft shadows on the diffuse material, if the number of iterations is not large enough. Because the filter will blur the surrounding pixels, the soft-shadow effect will also be blurred so that a gradual stratification of shadow cannot be seen very clearly, at this situation, running the denoiser with more iterations, such as 300 iterations, can improve the soft-shadow effect greatly.

![cornell_mjolnir_diff_mat](./img/cornell_mjolnir_diff_mat.png)

However, the smoothing effect brought by denoiser is absolutely a disaster for materials with texture mapping. The details of textures will be blurred so that no interesting texture details can be seen from the denoised images.

### Visual results and performance for varying filter sizes

| 1 x 1 | 5 x 5 | 17 x 17 |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![Denoiser with 1x1 filter](./img/cornell_denoising_100iters_1_1.png) | ![Denoiser with 5x5 filter](./img/cornell_denoising_100iters_5_5.png) | ![Denoiser with 17x17 filter](./img/cornell_denoising_100iters.png) |
| **33 x 33** | **65 x 65** | **129 x 129** |
| ![Denoiser with 33x33 filter](./img/cornell_denoising_100iters_33_33.png) | ![Denoiser with 65x65 filter](./img/cornell_denoising_100iters_65_65.png) | ![Denoiser with 129x129 filter](./img/cornell_denoising_100iters_129_129.png) |

If the filter size is small, for example less than 17 x 17, i.e., use fewer than 3 iterations to call the edge stopping function, the denoising is not effective, the images are still filled with grains, because of the small blurred area. Comparing the usual filter size 17 x 17, those images denoised with larger filter size don't show a great improvement, and from the following chart we can know that the difference in filter size don't have an impact on running time, so it's feasible and reasonable to choose 17 x 17 as the A Trous filter size.

![Runtime of Varying Filter Sizes Rendered in the Basic Cornell Scene](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/img/Runtime%20of%20Varying%20Filter%20Sizes%20Rendered%20in%20the%20Basic%20Cornell%20Scene.png)

### A-Trous filtering and Gaussian filtering Comparison

| A-Trous Filtering Result | Gaussian Filtering Result |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![A-Trous Filtering Result](./img/cornell_denoising_100iters.png) | ![Gaussian Filtering Result](./img/cornell_denoising_100iters_gaussian.png) |
| ![A-Trous Filtering Result of cornell_ceiling_light](./img/denoised_cornell_ceilling_light.png) | ![Gaussian Filtering Result of denoised_cornell_ceilling_light](./img/denoised_cornell_ceilling_light_gaussian.png) |
| ![A-Trous Filtering Result of cornell_glassball](./img/denoised_cornell_glassball.png) | ![Gaussian Filtering Result of cornell_glassball](./img/denoised_cornell_glassball_gaussian.png) |

![A-Trous filtering and Gaussian filtering Comparison in Runtime](https://github.com/giaosame/Project4-CUDA-Denoiser/blob/base-code/img/A-Trous%20filtering%20and%20Gaussian%20filtering%20Comparison%20in%20Runtime.png)

I implemented the basic Gaussian filtering with kernel size 17 x 17 and $\sigma$ = 15, which just simply blurs the image, as we can see. The Gaussian filtering only outputs a blurred images without details and take a little bit more time than A-Trous filtering, so A-Trous definitely outperforms Gaussian filtering.

## References

- [Edge-Avoiding A-Trous Wavelet Transform for fast Global Illumination Filtering](https://jo.dreggn.org/home/2010_atrous.pdf)
- ocornut/imgui - https://github.com/ocornut/imgui
- Gaussian filter - https://en.wikipedia.org/wiki/Gaussian_blur
Loading