Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e7b3995
Diffuse surface ray trace
liunicholas6 Sep 21, 2024
cbbf38d
Added stream compact
liunicholas6 Sep 21, 2024
f787aa4
Perfectly specular refls and stochastic AA
liunicholas6 Sep 21, 2024
33b2ba3
gitignore
liunicholas6 Sep 21, 2024
f7f0c49
Veach scene geometry
liunicholas6 Sep 21, 2024
2b78c1e
Sort materials on emittance
liunicholas6 Sep 21, 2024
d578aad
Added ray query + some setup for MIS
liunicholas6 Sep 25, 2024
a99225b
Use of separate throughput and radiance; some direct lighting setup
liunicholas6 Sep 27, 2024
ea54263
Direct lighting for cubes?
liunicholas6 Sep 28, 2024
655c821
Direct lighting + Refactor to allow access of scene data from GUI
liunicholas6 Sep 28, 2024
240ea5f
Refraction?
liunicholas6 Sep 29, 2024
6f344c0
Refraction
liunicholas6 Sep 29, 2024
34b3cff
Fixed ray jitter
liunicholas6 Sep 29, 2024
c47e697
Moved dof settings to camera json
liunicholas6 Oct 2, 2024
69faf69
Preliminary support of triangles. Reversion of ShadeableIntersection …
liunicholas6 Oct 3, 2024
a813845
Added tinygltf as submodule
liunicholas6 Oct 3, 2024
b98e3f5
tiny_gltf correct integration; model loading started
liunicholas6 Oct 3, 2024
8b7b857
Load triangle mesh json
liunicholas6 Oct 4, 2024
b4dab97
gltf mesh loading finish, triangle fix
liunicholas6 Oct 4, 2024
b1985f6
index-based positions; start of texturing
liunicholas6 Oct 5, 2024
45e48e4
Albedo texturing
liunicholas6 Oct 5, 2024
998f675
Scaled intersection fix, emittance on imput materials, decoupling of …
liunicholas6 Oct 5, 2024
99e9a1b
textures (broken)
liunicholas6 Oct 6, 2024
965a0c1
Mesh intersection hotfix and emissive strength fix
liunicholas6 Oct 6, 2024
af414e5
Texture union
liunicholas6 Oct 6, 2024
e85262f
Support of emissive textures and emissive strength
liunicholas6 Oct 6, 2024
aa8f5cd
Comment out direct lighting
liunicholas6 Oct 6, 2024
7404e6f
Added light material indices to scene
liunicholas6 Oct 6, 2024
21875ee
Material sorting
liunicholas6 Oct 6, 2024
f09a8b2
Fix: emission in json scenes
liunicholas6 Oct 6, 2024
5403d22
Changed ray direction semantics to cohere with pbrt
liunicholas6 Oct 6, 2024
334a564
Microfacet materials attempt
liunicholas6 Oct 7, 2024
c288e91
Fixed direct lighting
liunicholas6 Oct 7, 2024
b9258ad
Images
liunicholas6 Oct 7, 2024
42f7b20
Readme images
liunicholas6 Oct 7, 2024
996a67b
Update README.md
liunicholas6 Oct 11, 2024
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ build
.LSOverride

# Icon must end with two \r
Icon
Icon


# Thumbnails
._*
Expand Down Expand Up @@ -558,3 +559,4 @@ xcuserdata
*.xccheckout
*.moved-aside
*.xcuserstate
.vscode/*
Empty file added .gitmodules
Empty file.
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "CUDA C++: Launch",
"type": "cuda-gdb",
"request": "launch",
"program": "${workspaceFolder}/build/bin/cis565_path_tracer",
"args": ["scenes/cornell.json"],
"cwd": "${workspaceFolder}"
},
]
}
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ set(headers
src/interactions.h
src/intersections.h
src/glslUtility.hpp
src/guiDataContainer.h
src/pathtrace.h
src/scene.h
src/sceneStructs.h
Expand All @@ -68,12 +69,14 @@ set(sources
src/stb.cpp
src/image.cpp
src/glslUtility.cpp
src/guiDataContainer.cpp
src/pathtrace.cu
src/intersections.cu
src/interactions.cu
src/scene.cpp
src/preview.cpp
src/utilities.cpp
src/tiny_gltf.cpp
)

set(imgui_headers
Expand Down Expand Up @@ -109,7 +112,6 @@ 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})
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
Expand All @@ -123,7 +125,6 @@ endif()
target_link_libraries(${CMAKE_PROJECT_NAME}
${LIBRARIES}
cudadevrt
#stream_compaction # TODO: uncomment if using your stream compaction
)
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "$<$<AND:$<CONFIG:Debug,RelWithDebInfo>,$<COMPILE_LANGUAGE:CUDA>>:-G;-src-in-ptx>")
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "$<$<AND:$<CONFIG:Release>,$<COMPILE_LANGUAGE:CUDA>>:-lineinfo;-src-in-ptx>")
Expand Down
51 changes: 46 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,53 @@ CUDA Path Tracer
================

**University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 3**
* Nicholas Liu
* [Linkedin](https://www.linkedin.com/in/liunicholas6/)
* Tested on: Linux Mint 22 Wilma, AMD Ryzen 7 5800X @ 2.512GHz, 32GB RAM, GeForce GTX 1660 Ti

### Background
This project is a path tracer, written in CUDA. It functions by physically simulating the paths of light rays in a scene in order to render objects. For each pixel, many simulated light rays are fired from the camera. The rays intersection with geometry is calculated, bounced probabalistically in a direction dependent on the material hit, and picks up color from the surface hit.

Note that rays are fired from the camera instead of from light sources, as the vast majority of actual photons emitted from an arbitrary light source would not hit the camera and would be wasted computation -- hence tracing the paths in reverse.

### Features
## Material surfaces
The project currently features 4 different types of surfaces: diffuse, reflective, transmissive, and glassy.

Diffuse surfaces disperses light equally in all directions, and give a flat color.

Reflective and transmissive surfaces disperse rays in one particular output direction for a given input direction, following the laws of reflectance and Snell's laws respectively. Reflective surfaces appear as mirrors, while transmissive are see-through with some distortion.

Finally, glassy surfaces reflect some light rays and transmit others, with probability dependent on the incident angle of the incoming light ray.

![](img/Refraction.png)
A glossy reflection

## Depth of field
A thin-lens approximation of a camera is used to generate depth of field, which blurs out objects depending on how close they are to a focal plane a set distance from the camera.

![](img/nodof.png)
![](img/dof.png)

## Direct Lighting
Many rays in the path tracing algorithm will miss light sources. The more rays miss their light sources, the longer it takes for the final image to converge. Another rendering technique, direct lighting, can yield a faster convergence time -- it works by, instead of scattering a ray randomly, picking an arbitrary point on a light source and scattering it in said direction.

Direct lighting notably does not yield correct-looking results for reflective and transmissive materials, but generally gives a usable image faster, especially in cases with small light sources.

The following show a 20 sample image with regular lighting and direct lighting compared and a fairly normal-sized light source

![](img/simple20samp.png)
![](img/direct20samp.png)

The code for direct lighting also lays the groundwork for multiple importance sampling, which functions well in both the scenarios that naive and direct lighting path tracing methods work well for -- I'll be sure to come back to this project with some materials and scenes where direct lighting really shines!

## GLTF loading and texturing
To be able to render more visually interesting scenes without hand-specifying them through code, loading of arbitrary mesh data is supported. Materials that utilize textures for their albedo and emmission maps are supported as well, in order to allow for geometry that isn't just uniform in color.
![](img/AvocadoCornell.png)




* (TODO) YOUR NAME HERE
* Tested on: (TODO) Windows 22, i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (Moore 2222 Lab)

### (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.

Loading