Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,18 @@
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Project4-CUDA-Denoiser.null.511728241" name="Project4-CUDA-Denoiser"/>
<project id="Project3-CUDA-Path-Tracer.null.511728241" name="Project3-CUDA-Path-Tracer"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/Project4-CUDA-Denoiser"/>
<resource resourceType="PROJECT" workspacePath="/Project3-CUDA-Path-Tracer"/>
</configuration>
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/Project4-CUDA-Denoiser"/>
<resource resourceType="PROJECT" workspacePath="/Project3-CUDA-Path-Tracer"/>
</configuration>
</storageModule>
</cproject>
2 changes: 1 addition & 1 deletion .project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Project4-CUDA-Denoiser</name>
<name>Project3-CUDA-Path-Tracer</name>
<comment></comment>
<projects>
</projects>
Expand Down
42 changes: 22 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.1)

project(cis565_denoiser)
project(cis565_path_tracer)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

Expand Down 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,35 +95,26 @@ set(sources
src/scene.cpp
src/preview.cpp
src/utilities.cpp
)

set(imgui
imgui/imconfig.h
imgui/imgui.cpp
imgui/imgui.h
imgui/imgui_draw.cpp
imgui/imgui_internal.h
imgui/imgui_widgets.cpp
imgui/imgui_demo.cpp
imgui/imgui_impl_glfw.cpp
imgui/imgui_impl_glfw.h
imgui/imgui_impl_opengl2.cpp
imgui/imgui_impl_opengl2.h
imgui/imgui_impl_opengl3.cpp
imgui/imgui_impl_opengl3.h

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)
list(SORT sources)
list(SORT imgui)

source_group(Headers FILES ${headers})
source_group(Sources FILES ${sources})
source_group(imgui FILES ${imgui})

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

cuda_add_executable(${CMAKE_PROJECT_NAME} ${sources} ${headers} ${imgui})
cuda_add_executable(${CMAKE_PROJECT_NAME} ${sources} ${headers})
target_link_libraries(${CMAKE_PROJECT_NAME}
${LIBRARIES}
#stream_compaction # TODO: uncomment if using your stream compaction
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RelWithDebugInfo: build


run:
build/cis565_denoiser scenes/sphere.txt
build/cis565_path_tracer scenes/sphere.txt

build:
mkdir -p build
Expand Down
375 changes: 244 additions & 131 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_denoiser"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Project4-CUDA-Denoiser"/>
<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"/>
<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="/Project4-CUDA-Denoiser"/>
<listEntry value="/Project3-CUDA-Path-Tracer"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
Expand Down
81 changes: 73 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,78 @@
CUDA Denoiser For CUDA Path Tracer
==================================
CUDA Path Tracer
================

**University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 4**
**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)
* Guanlin Huang
* [LinkedIn](https://www.linkedin.com/in/guanlin-huang-4406668502/), [personal website](virulentkid.github.io/personal_web/index.html)
* Tested on: Windows 11, i9-10900KF CPU @ 5.0GHz 32GB RAM, RTX3080 10GB; Compute Capability: 8.6

### (TODO: Your README)
## Result

*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.
### Denoised image
By include the weights' influence in the convolution, we should see a "denoised" image.
A desirable result is produced by tuning the settings.
Original | Blur with Edge-Avoiding (Final Result)
:-------------------------:|:-----------:
![](img/ori_10.png) | ![](img/denoi_10.png)

### G-buffer
The normal and position data per-pixel are kept in the G-buffer for edge-avoiding weights.
Normal | Position | Z-Depth
:-------------------------:|:-------------------------:|:-----------:
![](img/gb_nor.png) | ![](img/gb_pos.png) | ![](img/gb_z.png)

## Performance Analysis

### How much time denoising adds to your renders
The additional time from denoising is independent of the number of path tracing iterations as the denoising kernel is only executed once during the final iteration. Roughly, the denoising procedure adds **0.81ms** to the path tracer in release mode.
![](img/denoi_time.png)

### How denoising influences the number of iterations needed to get an "acceptably smooth" result
With only 10 iterations and denoising, we can get a decently "smooth" result comparing to the 5000 iteration "ground truth"
10 iterations | denoised | 5000 iterations (ground truth)
:-------------------------:|:-------------------------:|:-----------:
![](img/ori_10.png) | ![](img/denoi_10.png) | ![](img/5000.png)

### How denoising at different resolutions impacts runtime
The denoising time increases in a approximately linear fashion as image resolution increases.
![](img/diff_res.png)


### How varying filter sizes affect performance
With bigger filters, it takes longer to denoise. Expanding the kernel to encompass the filter/blur size requires additional passes and iterations as the filter size grows.

![](img/diff_filter.png)

### Z-depth and oct-encoding normal VS original implementation
The z-depth doesn't display a significant performance upgrade, and the oct-encoding normal actually worsen the performance. It might be the fact that the encoding process actually takes more time than leaving the original normal. A much more complicated scene might make use of this feature.
![](img/extra.png)


## Visual Analysis
### How visual results vary with filter size -- does the visual quality scale uniformly with filter size?

We can observe from the images below that the visual quality gets better as the filter size increases.
They do not, however, scale consistently. The transition from 5x5 to 30x30 is obvious. From 30x30 to 60x60, the difference is more negligible, and from 60x60 to 100x100, it is scarcely perceptible.

5x5 |30x30 | 60x60 | 100x100
:-----:|:-------------------------:|:-------------------------:|:-----------:
![](img/5x5.png)|![](img/30x30.png) | ![](img/60x60.png) | ![](img/100x100.png)

### How effective/ineffective is this method with different material types

The approach works well with diffuse materials but less well with reflecting ones.
The denoised result for the diffuse scene is more alike as the actual version, as seen below.
However, there are observable blurring in the reflected surface in the specular scene.

Material Type | Original | Denoised
:------------:|:------------------:|:-------------------------:
Diffuse |![](img/dif.png) | ![](img/denoi_dif.png)
Specular |![](img/ori_10.png) | ![](img/denoi_10.png)

### How do results compare across different scenes? Does one scene produce better denoised results? Why or why not?

The path traced output after 10 iterations for the basic Cornell scenario with a lower light volume will make the denoise artifact more conspicuous, but generally good enough.
10 iterations | denoised | 5000 iterations (ground truth)
:-------------------------:|:-------------------------:|:-----------:
![](img/bad_light_ori.png) | ![](img/bad_light_denoi.png) | ![](img/bad_light_5000.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
Loading