Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6331e8a
Finished naive path tracer but buggy
theBoilingPoint Sep 25, 2024
f3ca968
The shadeNaive function is not quite right
theBoilingPoint Sep 26, 2024
812c3b1
Done with naive path tracer but need to optimise
theBoilingPoint Sep 26, 2024
d78d07c
Optimised code structure and implemented sorting paths by material
theBoilingPoint Sep 26, 2024
9d5b4e5
Finished base credit
theBoilingPoint Sep 27, 2024
94ec3a0
Fixed bug in naive shader
theBoilingPoint Sep 27, 2024
c368c81
Optimised code structure
theBoilingPoint Sep 28, 2024
5b3215a
Done with naive mesh loading
theBoilingPoint Sep 30, 2024
230dce7
Written some of MIS
theBoilingPoint Oct 1, 2024
d14473d
Fixed mirror but dielectric is an issue
theBoilingPoint Oct 2, 2024
69d8d45
Fixed dielectric material
theBoilingPoint Oct 2, 2024
5440f7d
Implemented Ruassian roulette
theBoilingPoint Oct 2, 2024
0b00402
Merge branch 'CIS5650-Fall-2024:main' into main
theBoilingPoint Oct 3, 2024
55628b9
Implemented microfacet material
theBoilingPoint Oct 3, 2024
d06883e
Finished mesh loading for GLTF/GLB
theBoilingPoint Oct 4, 2024
c0e2d7f
BVH has segmentation fault
theBoilingPoint Oct 6, 2024
243f588
Fixed segmentation fault for BVH
theBoilingPoint Oct 6, 2024
0e73a37
BVH not working when split depth is > 0
theBoilingPoint Oct 7, 2024
67bf10c
Implemented DOF
theBoilingPoint Oct 7, 2024
29536d2
Done for texture loading
theBoilingPoint Oct 8, 2024
6391e8f
Edited README and final scene file
theBoilingPoint Oct 9, 2024
4ca1936
Finished README
theBoilingPoint Oct 10, 2024
0887ff9
Fixed memory leak bug.
theBoilingPoint Nov 19, 2025
eece3a9
Started implementing BVH.
theBoilingPoint Dec 7, 2025
28fd717
Update to be compatible with CUDA13.x.
theBoilingPoint Jun 7, 2026
d9dafd7
Fix CUDA device busy/unavailable bug.
theBoilingPoint Jun 8, 2026
92a7588
Updated .gitignore.
theBoilingPoint Jun 14, 2026
f81f817
Modify build to use clangd.
theBoilingPoint Jun 14, 2026
7106476
Started on BVH.
theBoilingPoint Jun 16, 2026
9ca1e8e
Implemented building BVH.
theBoilingPoint Jun 22, 2026
984292c
Refactored GLTF/GLB loading code.
theBoilingPoint Jun 25, 2026
9d3ae1f
Implemented BVH construction.
theBoilingPoint Jun 28, 2026
2bec63b
Implemented BVH traversal.
theBoilingPoint Jun 28, 2026
7d75a37
Added OIDN submodule.
theBoilingPoint Jun 28, 2026
3781be8
Refactored code.
theBoilingPoint Jun 28, 2026
2b66f0b
Implement environment lighting (equirectangular HDR)
theBoilingPoint Jun 28, 2026
e9775ce
Fixed BVH bug.
theBoilingPoint Jun 29, 2026
ac9d21c
Fixed mesh black edge issue.
theBoilingPoint Jun 30, 2026
a1aaa07
Implemented MIS.
theBoilingPoint Jul 4, 2026
27830fc
Implemented spectral rendering.
theBoilingPoint Jul 18, 2026
774e7e7
Implemented volumetric rendering.
theBoilingPoint Jul 28, 2026
ac2b745
Fixed volumetric rendering bug.
theBoilingPoint Jul 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BasedOnStyle: LLVM
IndentWidth: 4
33 changes: 33 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# clangd config for this CUDA project.
# compile_commands.json is generated from nvcc command lines, which clangd
# (a clang-based tool) cannot consume directly. We strip nvcc-only flags and
# force clang into CUDA mode pointed at the installed toolkit.
CompileFlags:
Add:
- --cuda-path=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.3
- --cuda-gpu-arch=sm_75
- --no-cuda-version-check
# glm's assert() expands to MSVC's _wassert (a __host__ function), which
# clang rejects when reached from __host__ __device__ code. Defining NDEBUG
# for analysis removes the call at its source (real build is unaffected) and,
# unlike suppressing the diagnostic, keeps genuine host-in-device errors in
# our own code visible.
- -DNDEBUG
Remove:
- -forward-unknown-to-host-compiler
- -Xcompiler*
- -Xcudafe*
- -arch=*
- -rdc=*
- -G
- -src-in-ptx
- --expt-relaxed-constexpr
- -gencode*
- --generate-code*
- --options-file
Diagnostics:
# CUDA 13.3's CCCL headers (cuda/std/string_view) annotate deduction guides
# with __host__, which clang 22's CUDA frontend rejects. nvcc compiles fine;
# this is purely a clang/CCCL version mismatch in a library header.
Suppress:
- deduction_guide_target_attr
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*.vcxproj
*.xcodeproj
build
build_ninja
.claude/

# Created by https://www.gitignore.io/api/linux,osx,sublimetext,windows,jetbrains,vim,emacs,cmake,c++,cuda,visualstudio,webstorm,eclipse,xcode

Expand All @@ -23,7 +25,8 @@ build
.LSOverride

# Icon must end with two \r
Icon
Icon


# Thumbnails
._*
Expand Down Expand Up @@ -251,6 +254,7 @@ bld/

# Visual Studio 2015 cache/options directory
.vs/
.vscode/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

Expand Down Expand Up @@ -389,6 +393,8 @@ AppPackages/
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# except our build cache
.cache/

# Others
ClientBin/
Expand Down
22 changes: 22 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[submodule "libs/tinyobjloader"]
path = libs/tinyobjloader
url = https://github.com/tinyobjloader/tinyobjloader.git

[submodule "libs/tinygltf"]
path = libs/tinygltf
url = https://github.com/syoyo/tinygltf.git
[submodule "libs/ImGui"]
path = libs/ImGui
url = https://github.com/ocornut/imgui
[submodule "libs/glm"]
path = libs/glm
url = https://github.com/g-truc/glm
[submodule "libs/json"]
path = libs/json
url = https://github.com/nlohmann/json
[submodule "libs/stb"]
path = libs/stb
url = https://github.com/nothings/stb
[submodule "libs/oidn"]
path = libs/oidn
url = https://github.com/RenderKit/oidn.git
236 changes: 188 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ 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++11 for host code
set(CMAKE_CXX_STANDARD 11)
# C++20 required for std::span (used by the BVH). CUDA 13.x Thrust supports C++20.
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD 20)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()

Expand All @@ -31,87 +32,188 @@ if(UNIX)
find_package(GLEW REQUIRED)
set(LIBRARIES glfw ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES})
else(UNIX)
set(EXTERNAL "${CMAKE_SOURCE_DIR}/external")
set(PREBUILT "${CMAKE_SOURCE_DIR}/libs/prebuilt")

set(GLFW_ROOT_DIR ${EXTERNAL})
set(GLFW_ROOT_DIR ${PREBUILT})
set(GLFW_USE_STATIC_LIBS ON)
find_package(GLFW REQUIRED)

set(GLEW_ROOT_DIR ${EXTERNAL})
set(GLEW_ROOT_DIR ${PREBUILT})
set(GLEW_USE_STATIC_LIBS ON)
find_package(GLEW REQUIRED)

add_definitions(${GLEW_DEFINITIONS})
include_directories(${GLEW_INCLUDE_DIR} ${GLFW_INCLUDE_DIR})
include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
set(LIBRARIES ${GLEW_LIBRARY} ${GLFW_LIBRARY} ${OPENGL_LIBRARY})
endif(UNIX)

set(GLM_ROOT_DIR "${CMAKE_SOURCE_DIR}/external")
find_package(GLM REQUIRED)
include_directories(${GLM_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/libs/glm)
include_directories(${CMAKE_SOURCE_DIR}/libs/json/single_include)
include_directories(${CMAKE_SOURCE_DIR}/libs/stb)

# CUDA 12+ moved Thrust/CUB into include/cccl/; derive root from nvcc path
get_filename_component(CUDA_BIN_DIR "${CMAKE_CUDA_COMPILER}" DIRECTORY)
get_filename_component(CUDA_ROOT "${CUDA_BIN_DIR}" DIRECTORY)
if(EXISTS "${CUDA_ROOT}/include/cccl")
include_directories("${CUDA_ROOT}/include/cccl")
endif()

set(headers
src/main.h
src/image.h
src/interactions.h
src/intersections.h
src/glslUtility.hpp
src/pathtrace.h
src/scene.h
src/sceneStructs.h
src/preview.h
src/utilities.h
src/core/main.h
src/core/color.h
src/core/utilities.h
src/core/cudaUtil.h
src/scene/scene.h
src/scene/sceneStructs.h
src/scene/meshLoader.h
src/scene/bvh.h
src/render/pathtrace.h
src/render/deviceScene.h
src/render/intersections.h
src/render/bxdf.h
src/render/bsdf.h
src/render/spectral.h
src/render/spectrumData.h
src/render/volume.h
src/render/warp.h
src/display/preview.h
src/display/glslUtility.hpp
src/display/image.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/preview.cpp
src/utilities.cpp
src/core/main.cpp
src/core/utilities.cpp
src/scene/scene.cpp
src/scene/meshLoader.cpp
src/scene/bvh.cpp
src/render/pathtrace.cu
src/render/deviceScene.cu
src/render/intersections.cu
src/render/bxdf.cu
src/render/warp.cu
src/render/bsdf.cu
src/render/spectrumData.cu
src/display/preview.cpp
src/display/glslUtility.cpp
src/display/image.cpp
src/display/stb.cpp
)

set(imgui_headers
src/ImGui/imconfig.h
src/ImGui/imgui.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
libs/ImGui/imconfig.h
libs/ImGui/imgui.h
libs/ImGui/imgui_internal.h
libs/ImGui/imstb_rectpack.h
libs/ImGui/imstb_textedit.h
libs/ImGui/imstb_truetype.h
libs/ImGui/backends/imgui_impl_glfw.h
libs/ImGui/backends/imgui_impl_opengl3.h
libs/ImGui/backends/imgui_impl_opengl3_loader.h
)

set(imgui_sources
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
libs/ImGui/imgui.cpp
libs/ImGui/imgui_demo.cpp
libs/ImGui/imgui_draw.cpp
libs/ImGui/imgui_tables.cpp
libs/ImGui/imgui_widgets.cpp
libs/ImGui/backends/imgui_impl_glfw.cpp
libs/ImGui/backends/imgui_impl_opengl3.cpp
)

set(tinyobj_headers
libs/tinyobjloader/tiny_obj_loader.h
)

set(tinyobj_sources
libs/tinyobjloader/tiny_obj_loader.cc
)

set(tinygltf_headers
libs/tinygltf/tiny_gltf.h
)

set(tinygltf_sources
libs/tinygltf/tiny_gltf.cc
)

# rgb2spec (Jakob & Hanika 2019, "A Low-Dimensional Function Space for
# Efficient Spectral Upsampling", BSD 3-clause, vendored in libs/rgb2spec).
# The C reference implementation is linked into the app for loading the
# coefficient table and unit-checking the GPU port at startup.
set(rgb2spec_headers
libs/rgb2spec/rgb2spec.h
)

set(rgb2spec_sources
libs/rgb2spec/rgb2spec.c
)

list(SORT headers)
list(SORT sources)
list(SORT imgui_headers)
list(SORT imgui_sources)
list(SORT tinyobj_headers)
list(SORT tinyobj_sources)
list(SORT tinygltf_headers)
list(SORT tinygltf_sources)

source_group("Headers" FILES ${headers})
source_group("Sources" FILES ${sources})
source_group("ImGui\\Headers" FILES ${imgui_headers})
source_group("ImGui\\Sources" FILES ${imgui_sources})
source_group("tinyobj\\Headers" FILES ${tinyobj_headers})
source_group("tinyobj\\Sources" FILES ${tinyobj_sources})
source_group("tinygltf\\Headers" FILES ${tinygltf_headers})
source_group("tinygltf\\Sources" FILES ${tinygltf_sources})
source_group("rgb2spec" FILES ${rgb2spec_headers} ${rgb2spec_sources})

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

# ----------------------------------------------------------------------------
# Intel Open Image Denoise (OIDN) — built from the libs/oidn submodule.
# CUDA-only device build: this avoids the ISPC compiler and TBB, which are only
# required by OIDN's CPU device. Needs only the CUDA toolkit + CUTLASS (already
# pulled in as a nested submodule under libs/oidn/external/cutlass).
# Note: the CUTLASS kernels make the first build significantly slower.
# ----------------------------------------------------------------------------
option(USE_OIDN "Enable Intel Open Image Denoise" ON)
if(USE_OIDN)
set(OIDN_DEVICE_CPU OFF CACHE BOOL "" FORCE)
set(OIDN_DEVICE_CUDA ON CACHE BOOL "" FORCE)
set(OIDN_APPS OFF CACHE BOOL "" FORCE)
add_subdirectory(libs/oidn)
endif()

# rgb2spec.c is plain C.
enable_language(C)

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

# ----------------------------------------------------------------------------
# rgb2spec sRGB coefficient table (~9.4 MB), generated once at build time by
# the vendored optimizer (multithreaded, takes about a minute; cached by the
# build system afterwards) and copied next to the executable, where
# initSpectralTables() (src/render/spectrumData.cu) loads it.
# ----------------------------------------------------------------------------
add_executable(rgb2spec_opt libs/rgb2spec/rgb2spec_opt.cpp)
set_target_properties(rgb2spec_opt PROPERTIES FOLDER "tools")

set(RGB2SPEC_TABLE ${CMAKE_BINARY_DIR}/srgb.coeff)
add_custom_command(OUTPUT ${RGB2SPEC_TABLE}
COMMAND rgb2spec_opt 64 ${RGB2SPEC_TABLE} sRGB
DEPENDS rgb2spec_opt
COMMENT "Generating rgb2spec sRGB coefficient table (one-time, ~1 min)")
add_custom_target(rgb2spec_table DEPENDS ${RGB2SPEC_TABLE})
add_dependencies(${CMAKE_PROJECT_NAME} rgb2spec_table)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RGB2SPEC_TABLE}
$<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>
COMMENT "Copying srgb.coeff next to the path tracer")
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
if(CMAKE_VERSION VERSION_LESS "3.23.0")
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES OFF)
Expand All @@ -120,11 +222,49 @@ elseif(CMAKE_VERSION VERSION_LESS "3.24.0")
else()
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES native)
endif()
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/libs ${CMAKE_SOURCE_DIR}/libs/ImGui)
# src subfolders so the project's flat #include "foo.h" resolve regardless of
# which subfolder a file now lives in.
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/scene
${CMAKE_SOURCE_DIR}/src/render
${CMAKE_SOURCE_DIR}/src/display
)
target_link_libraries(${CMAKE_PROJECT_NAME}
${LIBRARIES}
cudadevrt
#stream_compaction # TODO: uncomment if using your stream compaction
stream_compaction # TODO: uncomment if using your stream compaction
)
if(USE_OIDN)
# OpenImageDenoise carries its own INTERFACE include dirs, so
# #include <OpenImageDenoise/oidn.hpp> works without extra paths.
target_link_libraries(${CMAKE_PROJECT_NAME} OpenImageDenoise)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE USE_OIDN)

# OIDN emits its DLLs into its own binary dir (build/libs/oidn), not next to
# the exe. The CUDA device module is built as an ExternalProject and is loaded
# dynamically at runtime (not a link dependency), so force it to build and copy
# all OIDN runtime DLLs next to the path tracer so they're found at launch.
add_dependencies(${CMAKE_PROJECT_NAME} OpenImageDenoise_device_cuda)
if(WIN32)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND}
-DOIDN_BIN_DIR=${CMAKE_BINARY_DIR}/libs/oidn
-DDST_DIR=$<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>
-P ${CMAKE_SOURCE_DIR}/cmake/copy_oidn_dlls.cmake
COMMENT "Copying OIDN runtime DLLs next to the path tracer")
endif()
endif()
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>")
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr>")
if(MSVC)
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/Zc:preprocessor>")
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:/Zc:preprocessor>")
# C++17 introduces std::byte; suppress ambiguity with Windows SDK's byte typedef
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE _HAS_STD_BYTE=0)
# Prevent Windows SDK from defining min/max macros that break std:: and glm:: calls
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE NOMINMAX)
endif()
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${CMAKE_PROJECT_NAME})
Loading