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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -557,3 +557,4 @@ xcuserdata
*.xccheckout
*.moved-aside
*.xcuserstate

47 changes: 38 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,49 @@ set(GLM_ROOT_DIR "${CMAKE_SOURCE_DIR}/external")
find_package(GLM REQUIRED)
include_directories(${GLM_INCLUDE_DIRS})

# TinyGLTF library
add_library(tinygltf STATIC
external/include/tinygltf/tiny_gltf.h
external/include/tinygltf/tiny_gltf.cc
)

target_include_directories(tinygltf PUBLIC
${CMAKE_SOURCE_DIR}/external/include
${CMAKE_SOURCE_DIR}/external/include/tinygltf

)


set(headers
src/image.h
src/interactions.h
src/intersections.h
src/glslUtility.hpp
src/pathtrace.h
src/scene.h
src/sceneStructs.h
src/utilities.h
src/PathTrace/pathtrace.h
src/PathTrace/interactions.h
src/PathTrace/intersections.h
src/PathTrace/bsdf.h
src/PathTrace/light.h
src/PathTrace/sampleWarping.h
src/PathTrace/pathTraceUtils.h
src/bvh.h
)

set(sources
src/main.cpp
src/stb.cpp
src/image.cpp
src/glslUtility.cpp
src/pathtrace.cu
src/intersections.cu
src/interactions.cu
src/scene.cpp
src/utilities.cpp
src/PathTrace/pathtrace.cu
src/PathTrace/intersections.cu
src/PathTrace/interactions.cu
src/PathTrace/bsdf.cu
src/PathTrace/light.cu
src/PathTrace/sampleWarping.cu
src/PathTrace/pathTraceUtils.cu
src/bvh.cpp
)

set(imgui_headers
Expand Down Expand Up @@ -98,17 +120,24 @@ list(SORT sources)
list(SORT imgui_headers)
list(SORT imgui_sources)

source_group("Headers" FILES ${headers})
source_group("Sources" FILES ${sources})
# source_group("Headers" FILES ${headers})
# source_group("Sources" FILES ${sources})
source_group(TREE ${CMAKE_SOURCE_DIR}/src PREFIX src FILES ${sources} ${headers})
source_group("ImGui\\Headers" FILES ${imgui_headers})
source_group("ImGui\\Sources" FILES ${imgui_sources})

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

add_executable(${CMAKE_PROJECT_NAME} ${sources} ${headers} ${imgui_sources} ${imgui_headers})

target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
${CMAKE_SOURCE_DIR}/src
)

target_link_libraries(${CMAKE_PROJECT_NAME}
${GL_LIBRARIES}
tinygltf
#stream_compaction # TODO: uncomment if using your stream compaction
)
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
Expand Down
82 changes: 77 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,83 @@ 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)
- Zhanbo Lin
- [LinkedIn](https://www.linkedin.com/in/zhanbo-lin)
- Tested on: Windows 10, i5-10400F @ 2.90GHz 48GB, RTX-3080 10GB (Personal)
- GPU Compute Capability: 8.6

## Renders ##
![](./img/results/ShowCase1.png)

## Project Description ##
In this project, I implemented a GPU-based path tracer using CUDA.

## Usage
### Initialization
- To load a json scene: -j SCENEFILE.json

- To load a gltf model, it needs to load a defualt scene to properly initialize: -ld JSONSCENE.json -g GLTFMODEL.gltf

### Camera Control

- Press W, A, S, D to move horizontally, Q and E to move vertically.

- Press middle mouse button to change movement speed.

- Hold right mouse button to adjust yaw and pitch.

### Other
- Press P to save current render to disk.


## Features


### Shading kernel with BSDF evaluation (diffuse, perfect specular surfaces)
![](./img/results/diffuse_specular.png)


## Visual Improvements


### Arbitrary mesh import using gltf

![](./img/results/gltf_mesh_loading.png)


### Stochastic Sampled Antialiasing + Stratified Sampling

Randomly jitter ray samples within each pixel to alleviate aliasing.

Jitter disabled | Jitter enabled
:-------------------------:|:-------------------------:
![](./img/results/jitter/no-jitter.png) | ![](./img/results/jitter/jitter-aa.png)



## Performance Improvements

### BVH Acceleration
BVH enabled (25.4 FPS) | Naive per triangle intersection (3.5 FPS)
:-------------------------:|:-------------------------:
![](./img/results/bvh/bvh.png) | ![](./img/results/bvh/no_bvh.png)


### Material Sorting

It actually slows the render when enabled, might work better if we have more materials.
Material sorting disabled (32.8 FPS) | Material sorting enabled (14.8 FPS)
:-------------------------:|:-------------------------:
![](./img/results/material_sort/no_sort.png) | ![](./img/results/material_sort/sort.png)

### Early-Out for Missed or Light Intersections

It also actually slows the render when enabled, might work better in an opened scene.

Early-out disabled (43 FPS) | Early-out enabled (35.1FPS)
:-------------------------:|:-------------------------:
![](./img/results/early_out/no_early_out.png) | ![](./img/results/early_out/early_out.png)


### (TODO: Your README)

*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.

Empty file added doc/notes.txt
Empty file.
Loading