Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
b03f94e
add .clang-format file, format files
aczw Sep 21, 2025
82babd0
look at checkitout comments
aczw Sep 21, 2025
d92d4a0
begin `scatter_ray`
aczw Sep 22, 2025
6216a7f
rename pathtrace to path_trace
aczw Sep 22, 2025
c7065b7
many changes
aczw Sep 22, 2025
2d3b2e9
update clang-format
aczw Sep 22, 2025
0e0b558
delete outdated comments
aczw Sep 22, 2025
f47c61f
more adjustments to prepare for actual shading
aczw Sep 22, 2025
bdb52a0
add radiance, rename `color` to `throughput`
aczw Sep 22, 2025
f4685fb
lambertian material, cosine-weighted sampling
aczw Sep 23, 2025
dd4c08e
add cosine weighted sampling
aczw Sep 23, 2025
5c6fdc3
some code cleanup
aczw Sep 23, 2025
4b5345a
cmake changes, more clean up
aczw Sep 23, 2025
3bdedf1
update readme w/ progress
aczw Sep 23, 2025
e610759
clean up utilities.cu/cuh
aczw Sep 23, 2025
af8d587
cmake: update to C++20
aczw Sep 23, 2025
2a5e8e2
use <numbers> instead of <cuda/std/numbers>
aczw Sep 23, 2025
0c80ef9
clang-format: return to 80 chars
aczw Sep 24, 2025
db70f13
standardize execution configuration, make everything 1d
aczw Sep 24, 2025
bb8bd38
make `PathTracer` a class
aczw Sep 24, 2025
53fa3d3
add `divide_ceil`
aczw Sep 24, 2025
dd869a6
rm comment
aczw Sep 24, 2025
50f036c
rename some stuff, plan some stuff
aczw Sep 24, 2025
7477440
better clang-format
aczw Sep 24, 2025
4a89546
separate out `Ray` class
aczw Sep 24, 2025
5403385
delete `multiply_mat4_vec4`
aczw Sep 24, 2025
9ee5d02
revert back to monke (rm `KernExecConfig`)
aczw Sep 24, 2025
660f2ff
clang-format: go back to 100 because i have nothing else to do
aczw Sep 24, 2025
25e4d66
better intersection test logic
aczw Sep 24, 2025
9854b53
rename many things
aczw Sep 24, 2025
eed43e7
represent an intersection as a ADT
aczw Sep 24, 2025
b377fb6
discard oob intersections
aczw Sep 24, 2025
4e99cd6
discard light intersections after sampling
aczw Sep 24, 2025
850f973
add stream compaction test
aczw Sep 25, 2025
2e07465
make `material_id` a char, sort by it
aczw Sep 25, 2025
1bf89c4
update readme
aczw Sep 25, 2025
9ebe8ca
prep for gui changes
aczw Sep 25, 2025
3ada2e4
make `GuiData` non-global
aczw Sep 25, 2025
f09cf16
delete global scene and gui_data
aczw Sep 25, 2025
c97adc6
move cuda error check fn out of path_tracer.cu
aczw Sep 25, 2025
c78965f
add gui toggle for sorting paths by materials
aczw Sep 25, 2025
f45de35
gui: discard paths toggles
aczw Sep 25, 2025
dbefe11
delete old fake shade kernel
aczw Sep 25, 2025
6d53ff4
stochastic sampling + gui toggle for it
aczw Sep 25, 2025
1020e85
modernize codebase
aczw Sep 25, 2025
85248c0
remove io pointer
aczw Sep 25, 2025
6ab5b48
fix compilation on TA's computer, rm global GL variables
aczw Sep 25, 2025
066cb0f
move constant data out of loop
aczw Sep 26, 2025
c7993f4
scuffed tone mapping
aczw Sep 26, 2025
5041eda
separate gui into tabs
aczw Sep 26, 2025
63739d2
add features to readme
aczw Sep 26, 2025
ed686fc
add blooper
aczw Sep 27, 2025
cb85d40
perfectly specular test scene
aczw Sep 27, 2025
3446d56
fix bugs, prep for new materials
aczw Sep 27, 2025
aaad227
test sceness
aczw Sep 27, 2025
700e7cb
h
aczw Sep 27, 2025
0065c41
fix bug
aczw Sep 27, 2025
bf60e14
ray
aczw Sep 27, 2025
49378d1
rework interesction logic
aczw Sep 27, 2025
0be7aaf
new materials system
aczw Sep 27, 2025
747b1a7
perfecctly specular?
aczw Sep 27, 2025
b47d786
add heads up to readme
aczw Sep 27, 2025
3bd57ea
perfectly transmissive materials
aczw Sep 28, 2025
462e497
get my terms right
aczw Sep 28, 2025
bc78a63
gui updates, use std::filesystem
aczw Sep 28, 2025
92df72b
rm `FILE` key from scene file
aczw Sep 29, 2025
d9f861b
return early if scene file DNE
aczw Sep 29, 2025
e15c0e4
scene: fix path_discarding
aczw Sep 29, 2025
af35e14
move `sample_material` to source file
aczw Sep 29, 2025
a105003
perfectly specular, glass scenes
aczw Sep 29, 2025
629a41b
add real fresnel calculation
aczw Sep 29, 2025
38fbb8a
add back color term to perf spec
aczw Sep 29, 2025
9fade57
fix perf spec
aczw Sep 29, 2025
1b3c1a8
refactor: convert `Intersection` to a simple struct
aczw Sep 29, 2025
4e698ee
refactor: convert `Material` to simple struct
aczw Sep 29, 2025
8ba0b7f
return early in kernels, rewrite operations
aczw Sep 30, 2025
14a1487
simply thrust::device_ptr usage, reset end iterator
aczw Sep 30, 2025
2d94dc6
joever
aczw Sep 30, 2025
a7ad7c5
perf_spec: finish (mostly), create new scene
aczw Sep 30, 2025
61c8fbd
scene: classic cornell boxes
aczw Sep 30, 2025
d58db2c
DOF, readme, gui dark style
aczw Sep 30, 2025
00b4fd4
add `tiny_gltf` and get it to compile
aczw Oct 4, 2025
28497d8
make `geometry_list` store heap-allocated `Geometry` structs
aczw Oct 4, 2025
0f5f2c8
extend scene to begin parsing for gltf, add blender cube scene
aczw Oct 4, 2025
999c597
convert raw gltf pos data to index and triangle buffer
aczw Oct 4, 2025
415cad9
make geometry populate global list of tri/pos data, and index into that
aczw Oct 4, 2025
6eb40d2
pass mesh data to cuda
aczw Oct 4, 2025
a3652b0
basic gltf intersect implementation, add suzanne
aczw Oct 4, 2025
9603724
get normals data from gltf, use glm::intersectRayTriangle correctly
aczw Oct 4, 2025
a667e09
don't.... normalize normals?
aczw Oct 4, 2025
cbb414c
only take the minimum t value
aczw Oct 4, 2025
f97a0b7
update readme
aczw Oct 4, 2025
ed8122f
stanford bunny res4
aczw Oct 4, 2025
4587bdd
some clean up
aczw Oct 5, 2025
935fd98
add avocado, update readme
aczw Oct 5, 2025
56b865c
separate parsing into diff helpers, begin AABB class
aczw Oct 5, 2025
392c286
build bounding box for built-in geom
aczw Oct 5, 2025
fb4a598
aabb ray intersection test, add toggle to gui
aczw Oct 5, 2025
fdac06c
build bbox for gltf models, add stanford_bunny_res3
aczw Oct 5, 2025
fdce211
fix AABB isect logic
aczw Oct 5, 2025
b330962
more bvh setup
aczw Oct 5, 2025
c62890a
implement `bvh::split`, send data to gpu
aczw Oct 5, 2025
a92d9e9
`bvh::split`: always get fresh reference to parent, other changes
aczw Oct 5, 2025
790c73e
separate out triangle list isect logic
aczw Oct 5, 2025
04c58fe
don't split node if it has no triangles
aczw Oct 6, 2025
b62267f
bvh isect fn
aczw Oct 6, 2025
a0174fa
add toggle to gui
aczw Oct 6, 2025
bd7e033
speed up bbox isect test
aczw Oct 6, 2025
fa9f0dc
FIX STUPID BVH SPLIT BUG ADJLQWJDQWJDQJWDJKQWLKJDQLWJKDJKLQWJDLQWJDQJDLK
aczw Oct 6, 2025
a8d0235
precomputing inverse of ray dir
aczw Oct 6, 2025
dffa48d
bvh: only split children if both have triangles
aczw Oct 6, 2025
221f137
bvh optimizations, run regular stanford bunny
aczw Oct 6, 2025
65b64bd
add stanford dragon
aczw Oct 6, 2025
c84b6ce
meausre time to parse gltf data
aczw Oct 6, 2025
b6d0c3d
dramatically, dramatically, dramatically speed up gltf parsing
aczw Oct 6, 2025
b5cbcce
add more models, update readme
aczw Oct 6, 2025
f405b41
gltf: import all meshes from a file
aczw Oct 6, 2025
73a02a2
pbr roughness
aczw Oct 6, 2025
bf36cb5
add one-way plane
aczw Oct 6, 2025
5692528
pbr test scene
aczw Oct 6, 2025
dac6936
maybe get fake pbr working maybe?
aczw Oct 6, 2025
6b16b18
increase stack size
aczw Oct 6, 2025
0bebfb3
rm pbr stuff
aczw Oct 7, 2025
e5b3fe8
update readme
aczw Oct 7, 2025
1084124
readme: work on introduction
aczw Oct 7, 2025
7f9d3f5
readme: finish introduction
aczw Oct 8, 2025
7d2b5cd
readme: finish introduction and program structure, add toc
aczw Oct 8, 2025
2e68aaa
readme: some small adjustments throughout, update footnotes
aczw Oct 8, 2025
1c33965
readme: add diffuse shading model renders
aczw Oct 8, 2025
213894d
readme: use markdown table format
aczw Oct 8, 2025
12d8f3a
readme: finish lambertian brdf
aczw Oct 8, 2025
db97275
readme: finish pure refl/trans
aczw Oct 8, 2025
4c396fd
readme: roughness
aczw Oct 8, 2025
b3972e8
readme: fresnel refl term, add table of data
aczw Oct 8, 2025
d7cb9ef
readme: finish materials
aczw Oct 8, 2025
34c1010
readme: finish anti-aliasing
aczw Oct 8, 2025
a9b47f8
readme: use html table so small images can expand
aczw Oct 8, 2025
6c0c46b
readme: finish dof
aczw Oct 8, 2025
2b6a63f
readme: flesh out isects, rearrange sections
aczw Oct 9, 2025
f331275
readme: add cover render
aczw Oct 9, 2025
538e120
readme: finish triangle loading section
aczw Oct 9, 2025
ab76e1b
readme: pre-computing ray inverse
aczw Oct 9, 2025
70357f3
readme: add isect culling graph
aczw Oct 9, 2025
b9cbee1
Merge branch 'main' of https://github.com/aczw/cuda-path-tracer
aczw Oct 9, 2025
1c85e8a
readme: finish bvh
aczw Oct 9, 2025
596e501
readme: add bloopers
aczw Oct 9, 2025
0197d00
readme: fix typo
aczw Oct 9, 2025
631255c
Post-homework (#1)
aczw Oct 23, 2025
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
19 changes: 19 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
BasedOnStyle: Chromium

ColumnLimit: 100
InsertNewlineAtEOF: true
AllowShortIfStatementsOnASingleLine: WithoutElse
WrapNamespaceBodyWithEmptyLines: Always
SeparateDefinitionBlocks: Always

# Local includes, then CCCL libraries, then 3rd party libraries, then standard library
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^".*"'
Priority: 1
- Regex: '^<(cuda|thrust|cub)/?.*>'
Priority: 2
- Regex: '^<(glm|stb|GL|GLFW|tiny_gltf)/?.*>'
Priority: 3
- Regex: '^<.*>'
Priority: 4
198 changes: 0 additions & 198 deletions .cproject

This file was deleted.

27 changes: 0 additions & 27 deletions .project

This file was deleted.

56 changes: 34 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,25 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Enable C++17 for host code
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CUDA_STANDARD 20)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)

# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

find_package(OpenGL REQUIRED)
include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")

if(UNIX)
include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
find_package(glfw3 REQUIRED)
find_package(GLEW REQUIRED)
set(GL_LIBRARIES glfw ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES})
else(UNIX)
else()
set(EXTERNAL "${CMAKE_SOURCE_DIR}/external")

set(GLFW_ROOT_DIR ${EXTERNAL})
Expand All @@ -42,33 +41,47 @@ else(UNIX)
add_definitions(${GLEW_DEFINITIONS})
include_directories(${GLEW_INCLUDE_DIR} ${GLFW_INCLUDE_DIR})
set(GL_LIBRARIES ${GLEW_LIBRARY} ${GLFW_LIBRARY} ${OPENGL_LIBRARY})
endif(UNIX)
endif()

set(GLM_ROOT_DIR "${CMAKE_SOURCE_DIR}/external")
find_package(GLM REQUIRED)
include_directories(${GLM_INCLUDE_DIRS})

set(headers
src/image.h
src/interactions.h
src/intersections.h
src/image.hpp
src/glslUtility.hpp
src/pathtrace.h
src/scene.h
src/sceneStructs.h
src/utilities.h
src/path_tracer.hpp
src/sample.hpp
src/scene.hpp
src/intersection.hpp
src/window.hpp
src/render_context.hpp
src/camera.hpp

src/tone_mapping.cuh
src/material.hpp
src/path_segment.hpp
src/utilities.cuh
src/ray.hpp
src/bvh.hpp
src/aabb.hpp
src/geometry.hpp
src/mesh.hpp
)

set(sources
src/main.cpp
src/stb.cpp
src/image.cpp
src/glslUtility.cpp
src/pathtrace.cu
src/intersections.cu
src/interactions.cu
src/path_tracer.cu
src/sample.cu
src/scene.cpp
src/utilities.cpp
src/intersection.cu
src/window.cpp
src/render_context.cpp
src/camera.cpp

src/main.cpp
src/external.cpp
)

set(imgui_headers
Expand Down Expand Up @@ -118,4 +131,3 @@ target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "$<$<AND:$<CONFIG:Debug,Rel
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "$<$<AND:$<CONFIG:Release>,$<COMPILE_LANGUAGE:CUDA>>:-lineinfo;-src-in-ptx>")

set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${CMAKE_PROJECT_NAME})

34 changes: 0 additions & 34 deletions GNUmakefile

This file was deleted.

8 changes: 3 additions & 5 deletions INSTRUCTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The core renderer is left for you to implement. Finally, note that, while this b

* `src/` C++/CUDA source files.
* `scenes/` Example scene description JSON files.
* `img/` Renders of example scene description files. (These probably won't match precisely with yours.)
* `renders/` Renders of example scene description files. (These probably won't match precisely with yours.)
* `external/` Includes and static libraries for 3rd party libraries.

## Running the code
Expand Down Expand Up @@ -62,7 +62,7 @@ You will need to implement the following features:

* A shading kernel with BSDF evaluation for:
* Ideal diffuse surfaces (using provided cosine-weighted scatter function, see below.) [PBRTv4 9.2](https://pbr-book.org/4ed/Reflection_Models/Diffuse_Reflection)
* After you have a [basic pathtracer up and running](img/REFERENCE_cornell.5000samp.png),
* After you have a [basic pathtracer up and running](renders/REFERENCE_cornell.5000samp.png),
implement a means of making rays/pathSegments/intersections contiguous in memory by material type. This should be easily toggleable.
* Consider the problems with coloring every path segment in a buffer and performing BSDF evaluation using one big shading kernel: different materials/BSDF evaluations within the kernel will take different amounts of time to complete.
* Sort the rays/path segments so that rays/paths interacting with the same material are contiguous in memory before shading. How does this impact performance? Why?
Expand Down Expand Up @@ -334,9 +334,7 @@ In addition:

* Stream compaction helps most after a few bounces. Print and plot the effects of stream compaction within a single iteration (i.e. the number of unterminated rays after each bounce) and evaluate the benefits you get from stream compaction.
* Compare scenes which are open (like the given cornell box) and closed (i.e. no light can escape the scene). Again, compare the performance effects of stream compaction! Remember, stream compaction only affects rays which terminate, so what might you expect?
* For optimizations that target specific kernels, we recommend using stacked bar graphs to convey total execution time and improvements in individual kernels. For example:

![Clearly the Macchiato is optimal.](img/stacked_bar_graph.png)
* For optimizations that target specific kernels, we recommend using stacked bar graphs to convey total execution time and improvements in individual kernels.

Timings from NSight should be very useful for generating these kinds of charts.

Expand Down
22 changes: 0 additions & 22 deletions Project3-CUDA-Path-Tracer.launch

This file was deleted.

Loading