Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8421472
Remove unused freeglut copyrights
shehzan10 Jan 16, 2021
a79ca55
Update CUDA Computes List
shehzan10 Sep 10, 2021
78e028a
Retab
shehzan10 Sep 10, 2021
c03780d
Update instructions for Fall 2021
shehzan10 Sep 18, 2021
80ad206
Add vulkan option
shehzan10 Sep 18, 2021
cc3da39
Add sample readmes for inspiration
shehzan10 Sep 19, 2021
784f5ca
Merge pull request #1 from CIS565-Fall-2021/update-instructions-2021
shehzan10 Sep 21, 2021
6d7e696
Added Imgui Integration Files
codeplay9800 Sep 19, 2022
8462d52
Updated Instruction.md
codeplay9800 Sep 19, 2022
c44fccb
Update Instruction.md
codeplay9800 Sep 19, 2022
7165f5c
Merge branch 'main' into Integrate_Imgui
codeplay9800 Sep 19, 2022
26e8bf3
Imgui Integrated
codeplay9800 Sep 20, 2022
3dac24e
Added GUIDataContainer Class
codeplay9800 Sep 20, 2022
e666e6a
Removed ImGUI Cmake
codeplay9800 Sep 21, 2022
5000086
Update INSTRUCTION.md
shehzan10 Sep 21, 2022
98f098c
Fix a bug that causes MouseOverImGuiWindow() to not work
dw218192 Sep 22, 2022
16d6638
Merge pull request #1 from dw218192/patch-1
codeplay9800 Sep 22, 2022
fa270e5
Update INSTRUCTION.md
HummaWhite Sep 16, 2023
0f1be54
Added a section for optimization
wayne-wu Sep 18, 2023
c5d6523
Update INSTRUCTION.md
HummaWhite Sep 19, 2023
5c4e20e
Backup works
Oct 5, 2023
f0fb0f5
Backup work
Oct 5, 2023
788b1ad
Done basic path tracing
Oct 5, 2023
bfd700a
Backup work
Oct 5, 2023
4a8d35e
Update shading method
Oct 7, 2023
cf69550
Revert "Update shading method"
Oct 7, 2023
03ab9ff
Add specular reflection and antialiasing
Oct 7, 2023
24ee055
Backup works
Oct 8, 2023
aa53ee9
Debug refraction
Oct 8, 2023
9ebb664
Revert "Debug refraction"
Oct 8, 2023
2cf9d93
Backup work
Oct 8, 2023
805549f
Done jittered sampling
Oct 9, 2023
56d5c53
Update refraction
Oct 9, 2023
dacb841
Add README
Oct 10, 2023
31456a5
Add sorting by materials
Oct 10, 2023
b6fac54
Backup README
Oct 12, 2023
50e0567
Complete README
Oct 12, 2023
0b19fd3
setup
Oct 19, 2023
8955568
Done G-Buffers for normals and positions
Oct 19, 2023
dbb31ea
Done A-trous wavelet filter
Oct 20, 2023
8ae4d9d
Backup README
Oct 21, 2023
61819f3
Complete README
Oct 21, 2023
7da055e
Update README
Oct 21, 2023
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
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ set(headers
src/sceneStructs.h
src/preview.h
src/utilities.h
src/ImGui/imconfig.h

src/ImGui/imgui.h
src/ImGui/imconfig.h
src/ImGui/imgui_impl_glfw.h
src/ImGui/imgui_impl_opengl3.h
src/ImGui/imgui_impl_opengl3_loader.h
src/ImGui/imgui_internal.h
src/ImGui/imstb_rectpack.h
src/ImGui/imstb_textedit.h
src/ImGui/imstb_truetype.h
)

set(sources
Expand All @@ -84,6 +95,14 @@ set(sources
src/scene.cpp
src/preview.cpp
src/utilities.cpp

src/ImGui/imgui.cpp
src/ImGui/imgui_demo.cpp
src/ImGui/imgui_draw.cpp
src/ImGui/imgui_impl_glfw.cpp
src/ImGui/imgui_impl_opengl3.cpp
src/ImGui/imgui_tables.cpp
src/ImGui/imgui_widgets.cpp
)

list(SORT headers)
Expand All @@ -92,6 +111,7 @@ list(SORT sources)
source_group(Headers FILES ${headers})
source_group(Sources FILES ${sources})

#add_subdirectory(src/ImGui)
#add_subdirectory(stream_compaction) # TODO: uncomment if using your stream compaction

cuda_add_executable(${CMAKE_PROJECT_NAME} ${sources} ${headers})
Expand Down
382 changes: 131 additions & 251 deletions INSTRUCTION.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="com.nvidia.cuda.ide.debug.cudagdb"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="scenes/sphere.txt"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/cis565_path_tracer"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Project3-CUDA-Path-Tracer"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/cis565_denoiser"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Project4-CUDA-Denoiser"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
<booleanAttribute key="org.eclipse.cdt.launch.use_terminal" value="true"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Project3-CUDA-Path-Tracer"/>
<listEntry value="/Project4-CUDA-Denoiser"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
Expand Down
71 changes: 64 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,70 @@
CUDA Path Tracer
CUDA Denoiser For CUDA Path Tracer
================

**University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 3**
**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)
* Zhiyu Lei
* [LinkedIn](https://www.linkedin.com/in/zhiyu-lei/), [Github](https://github.com/Zhiyu-Lei)
* Tested on: Windows 22, i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (CETS Virtual Lab)

### (TODO: Your README)
![](img/README/output.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.
(This output is generated from the scene in [scenes/customize.txt](scenes/customize.txt))

### Project Features
This project is extended from the [CUDA Path Tracer](https://github.com/Zhiyu-Lei/CIS5650-Project3-CUDA-Path-Tracer) project by implementing the A-trous wavelet filter with and without edge-avoiding technique in order to denoise the path tracer output. The A-trous wavelet filter is introduced in [Dammertz et al.'s paper](https://jo.dreggn.org/home/2010_atrous.pdf). More details are described below:

#### G-Buffers for normals and positions
Since the edge-avoiding technique requires the normal and position of each pixel to detect edges and compute weights of neighboring pixels for filtering, normals and positions are stored as G-Buffers and can be visualized as following:
|Per-pixel normals|Per-pixel positions|
|:---:|:---:|
|![](img/README/normal.png)|![](img/README/position.png)|

#### A-trous kernel and its iterations without weighting, i.e. Gaussian blur
The following two images show a comparison of outputs after 3 iterations between the raw output and the one applied with a 5x5 Gaussian filter. The Gaussian filter has some denoising effect, but it also blurs the output and smooths the sharp edges.
|Raw output|Gaussian filter|
|:---:|:---:|
|![](img/README/cornell.original.3samp.png)|![](img/README/cornell.gaussian.3samp.png)|

#### A-trous kernel and its iterations with weighting
The following two images show a comparison of outputs after 3 iterations between the raw output and the one applied with a 5x5 weighted A-trous kernel. G-Buffers with per-pixel normals and positions are used to perceive edges and weigh neighboring pixels less if they are from different surfaces. This kernel has better denoising effect than the previous Gaussian filter, and it preserves the edges better.
|Raw output|A-trous with weighting|
|:---:|:---:|
|![](img/README/cornell.original.3samp.png)|![](img/README/cornell.denoise.3samp.png)|

### Performance Analysis
#### How much time denoising adds to your renders
Without denoising, the average frame rate is 60 FPS. With the Gaussian filter, the average frame rate reduces to 45 FPS. With the weighted A-trous kernel, the average frame rate further reduces to 20 FPS.

#### How denoising influences the number of iterations needed to get an "acceptably smooth" result
The following two images show the "acceptably smooth" results from the raw output and the one applied with the weighted A-trous kernel, which are obtained after 100 and 5 iterations respectively. In this case, though each iteration takes triple time for the denoised output than the raw output, denoised output requires much less iterations and is thus more efficient.
|Raw output (100 iterations)|A-trous with weighting (5 iterations)|
|:---:|:---:|
|![](img/README/cornell.original.100samp.png)|![](img/README/cornell.denoise.5samp.png)|

#### How denoising at different resolutions impacts runtime
The plot below shows the average frame rate with respect to the resolution for the weighted A-trous kernel with filter size 8. Obviously, larger resolution makes the computation and rendering slower.
![](img/README/FPS-resolution.png)

#### How varying filter sizes affect performance
For the filter size $n$, $n$ iterations are executed in the denoising step, and a maximum of $(1+2\cdot2^n)$ neighboring pixels are weighted for each output pixel.

The plot below shows the average frame rate with respect to the filter size for the weighted A-trous kernel applied on the 800x800 resolution output. Obviously, larger filter size makes the computation and rendering slower.
![](img/README/FPS-filtersize.png)

#### How visual results vary with filter size
The following four images show a comparison of outputs applied with the weighted A-trous kernel with filter sizes 4, 6, 8, and 10 respectively. By eyeballing the outputs, larger filter size tends to slightly improve the denoising but the variation is not significant in fact.
|4/8|6/10|
|:---:|:---:|
|![](img/README/cornell.4filter.10samp.png)|![](img/README/cornell.6filter.10samp.png)|
|![](img/README/cornell.8filter.10samp.png)|![](img/README/cornell.10filter.10samp.png)|

#### How effective/ineffective is this method with different material types
The previous images can somewhat show this denoising method is the most effective with diffuse materials, but not that effective with specular-reflective or refractive materials.

#### How do results compare across different scenes
The following four images show a comparison of outputs between the row output and the one applied with the weighted A-trous kernel for a scene with a large light source ([scenes/cornell_ceiling_light.txt](scenes/cornell_ceiling_light.txt)) and a scene with a small light source ([scenes/cornell.txt](scenes/cornell.txt)). The scene with the larger light source has better denoising effect since more rays can terminate with hitting a light source during path tracing to create the more accurate output.
|Scene|Raw output|A-trous with weighting|
|:---:|:---:|:---:|
|Large light source|![](img/README/cornell.original.3samp.png)|![](img/README/cornell.denoise.3samp.png)|
|Small light source|![](img/README/cornell.original.10samp.png)|![](img/README/cornell.denoise.10samp.png)|
8 changes: 5 additions & 3 deletions cmake/CUDAComputesList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ IF( CUDA_COMPUTE_20
OR CUDA_COMPUTE_70
OR CUDA_COMPUTE_72
OR CUDA_COMPUTE_75
OR CUDA_COMPUTE_80
OR CUDA_COMPUTE_86
)
SET(FALLBACK OFF)
ELSE()
Expand All @@ -70,8 +72,8 @@ LIST(LENGTH COMPUTES_DETECTED_LIST COMPUTES_LEN)
IF(${COMPUTES_LEN} EQUAL 0 AND ${FALLBACK})
MESSAGE(STATUS "You can use -DCOMPUTES_DETECTED_LIST=\"AB;XY\" (semicolon separated list of CUDA Compute versions to enable the specified computes")
MESSAGE(STATUS "Individual compute versions flags are also available under CMake Advance options")
LIST(APPEND COMPUTES_DETECTED_LIST "30" "50" "60" "70")
MESSAGE(STATUS "No computes detected. Fall back to 30, 50, 60 70")
LIST(APPEND COMPUTES_DETECTED_LIST "30" "50" "60" "70" "80")
MESSAGE(STATUS "No computes detected. Fall back to 30, 50, 60, 70, 80")
ENDIF()

LIST(LENGTH COMPUTES_DETECTED_LIST COMPUTES_LEN)
Expand All @@ -90,7 +92,7 @@ MACRO(SET_COMPUTE VERSION)
ENDMACRO(SET_COMPUTE)

# Iterate over compute versions. Create variables and enable computes if needed
FOREACH(VER 20 30 32 35 37 50 52 53 60 61 62 70 72 75)
FOREACH(VER 20 30 32 35 37 50 52 53 60 61 62 70 72 75 80 86)
OPTION(CUDA_COMPUTE_${VER} "CUDA Compute Capability ${VER}" OFF)
MARK_AS_ADVANCED(CUDA_COMPUTE_${VER})
IF(${CUDA_COMPUTE_${VER}})
Expand Down
96 changes: 48 additions & 48 deletions cmake/FindGLFW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,66 +20,66 @@
include(FindPackageHandleStandardArgs)

if (WIN32)
# Find include files
find_path(
GLFW_INCLUDE_DIR
NAMES GLFW/glfw3.h
PATHS
$ENV{PROGRAMFILES}/include
${GLFW_ROOT_DIR}/include
DOC "The directory where GLFW/glfw.h resides")
# Find include files
find_path(
GLFW_INCLUDE_DIR
NAMES GLFW/glfw3.h
PATHS
$ENV{PROGRAMFILES}/include
${GLFW_ROOT_DIR}/include
DOC "The directory where GLFW/glfw.h resides")

# Use glfw3.lib for static library
if (GLFW_USE_STATIC_LIBS)
set(GLFW_LIBRARY_NAME glfw3)
else()
set(GLFW_LIBRARY_NAME glfw3dll)
endif()
# Use glfw3.lib for static library
if (GLFW_USE_STATIC_LIBS)
set(GLFW_LIBRARY_NAME glfw3)
else()
set(GLFW_LIBRARY_NAME glfw3dll)
endif()

# Find library files
find_library(
GLFW_LIBRARY
NAMES ${GLFW_LIBRARY_NAME}
PATHS
$ENV{PROGRAMFILES}/lib
${GLFW_ROOT_DIR}/lib)
# Find library files
find_library(
GLFW_LIBRARY
NAMES ${GLFW_LIBRARY_NAME}
PATHS
$ENV{PROGRAMFILES}/lib
${GLFW_ROOT_DIR}/lib)

unset(GLFW_LIBRARY_NAME)
unset(GLFW_LIBRARY_NAME)
else()
# Find include files
find_path(
GLFW_INCLUDE_DIR
NAMES GLFW/glfw.h
PATHS
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "The directory where GL/glfw.h resides")
# Find include files
find_path(
GLFW_INCLUDE_DIR
NAMES GLFW/glfw.h
PATHS
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "The directory where GL/glfw.h resides")

# Find library files
# Try to use static libraries
find_library(
GLFW_LIBRARY
NAMES glfw3
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
${GLFW_ROOT_DIR}/lib
DOC "The GLFW library")
# Find library files
# Try to use static libraries
find_library(
GLFW_LIBRARY
NAMES glfw3
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
${GLFW_ROOT_DIR}/lib
DOC "The GLFW library")
endif()

# Handle REQUIRD argument, define *_FOUND variable
find_package_handle_standard_args(GLFW DEFAULT_MSG GLFW_INCLUDE_DIR GLFW_LIBRARY)

# Define GLFW_LIBRARIES and GLFW_INCLUDE_DIRS
if (GLFW_FOUND)
set(GLFW_LIBRARIES ${OPENGL_LIBRARIES} ${GLFW_LIBRARY})
set(GLFW_INCLUDE_DIRS ${GLFW_INCLUDE_DIR})
set(GLFW_LIBRARIES ${OPENGL_LIBRARIES} ${GLFW_LIBRARY})
set(GLFW_INCLUDE_DIRS ${GLFW_INCLUDE_DIR})
endif()

# Hide some variables
Expand Down
44 changes: 22 additions & 22 deletions cmake/FindGLM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# Find GLM
#
# Try to find GLM : OpenGL Mathematics.
# This module defines
# This module defines
# - GLM_INCLUDE_DIRS
# - GLM_FOUND
#
# The following variables can be set as arguments for the module.
# - GLM_ROOT_DIR : Root library directory of GLM
# - GLM_ROOT_DIR : Root library directory of GLM
#
# References:
# - https://github.com/Groovounet/glm/blob/master/util/FindGLM.cmake
Expand All @@ -18,34 +18,34 @@
include(FindPackageHandleStandardArgs)

if (WIN32)
# Find include files
find_path(
GLM_INCLUDE_DIR
NAMES glm/glm.hpp
PATHS
$ENV{PROGRAMFILES}/include
${GLM_ROOT_DIR}/include
DOC "The directory where glm/glm.hpp resides")
# Find include files
find_path(
GLM_INCLUDE_DIR
NAMES glm/glm.hpp
PATHS
$ENV{PROGRAMFILES}/include
${GLM_ROOT_DIR}/include
DOC "The directory where glm/glm.hpp resides")
else()
# Find include files
find_path(
GLM_INCLUDE_DIR
NAMES glm/glm.hpp
PATHS
/usr/include
/usr/local/include
/sw/include
/opt/local/include
${GLM_ROOT_DIR}/include
DOC "The directory where glm/glm.hpp resides")
# Find include files
find_path(
GLM_INCLUDE_DIR
NAMES glm/glm.hpp
PATHS
/usr/include
/usr/local/include
/sw/include
/opt/local/include
${GLM_ROOT_DIR}/include
DOC "The directory where glm/glm.hpp resides")
endif()

# Handle REQUIRD argument, define *_FOUND variable
find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIR)

# Define GLM_INCLUDE_DIRS
if (GLM_FOUND)
set(GLM_INCLUDE_DIRS ${GLM_INCLUDE_DIR})
set(GLM_INCLUDE_DIRS ${GLM_INCLUDE_DIR})
endif()

# Hide some variables
Expand Down
27 changes: 0 additions & 27 deletions external/include/GL/Copying.txt

This file was deleted.

Loading