This is the code example for CEDEC 2024 "Easy Start with GPU Ray Tracing! From GPU Programming Basics to ReSTIR".
Please also refer to the slides used during the presentation.
- AMD GPU or NVIDIA GPU
- CUDA SDK (>= 12.2) (For NVIDIA GPU users)
First, download the dependent libraries.
git submodule update --init --recursive
Run Premake to create Visual Studio solution files.
./premake5.exe vs2022
For NVIDIA users, add --nvidia
option when running premake.
./premake5.exe --nvidia vs2022
Open build/CEDEC_2024_RT.sln
in Visual Studio and build.
Run Premake to create a Makefile.
./premake5 gmake2
For NVIDIA users, add --nvidia
option when running premake.
./premake5.exe --nvidia gmake2
Execute the build using make
in the build
directory.
cd build
make
Mode | CPU Code Optimization | GPU Code Optimization |
---|---|---|
Debug | ✔ | |
DebugGpu | ||
RelWithDebInfo | ✔ | ✔ |
There are 10 implementation examples, ranging from very simple ones to ReSTIR implementation.
Mouse Operation | Description |
---|---|
LMB |
Rotate camera |
RMB |
Zoom in/out camera |
MMB |
Move camera |
An example that simply fills pixels with a gradient.
An example of displaying a triangle using ray tracing.
An example of displaying a Cornell box using ray tracing. It directly displays the color of the triangle hit by the ray from the camera.
An example of calculating ambient occlusion using ray tracing in a simple Cornell box scene.
Calculates ambient occlusion in a more complex scene. It's slightly faster as it terminates calculations early using AABBs. You can see the performance of brute-force calculation by using #define ENABLE_AABB_CULLING 0
in 05_ao_boundingbox.cu.
Advanced Tips
Using #define ENABLE_AABB_WARP_LEVEL_CULLING 1
performs an additional level of hierarchical culling with AABBs that group 32 together.
A version that uses HIPRT for ray-scene intersection tests. Calculation becomes overwhelmingly faster on both NVIDIA and AMD GPUs. Especially for AMD GPUs, it can utilize hardware ray tracing capabilities.
An example of path tracing.
Operation | Description |
---|---|
A |
Toggle Accumulation On/Off |
S |
Save screenshot |
An example implementing Next Event Estimation. Compared to naive path tracing, it has a higher chance of reaching light sources, thus reducing noise.
Operation | Description |
---|---|
A |
Toggle Accumulation On/Off |
S |
Save screenshot |
An implementation example of Resampled Importance Sampling (RIS).
Operation | Description |
---|---|
1 |
Toggle RIS On/Off |
2 |
Include/Exclude Visibility in Target function evaluation |
A |
Toggle Accumulation On/Off |
S |
Save screenshot |
An implementation example of ReSTIR DI.
Operation | Description |
---|---|
1 |
Toggle Temporal Resampling On/Off |
2 |
Toggle Spatial Resampling On/Off |
3 |
Include/Exclude Visibility in Target function evaluation |
4 |
Toggle Visibility reuse On/Off |
A |
Toggle Accumulation On/Off |
S |
Save screenshot |
If you have any questions about the code or slide content, please contact:
Name | Address |
---|---|
Kenta Eto | Kenta.Eto@amd.com |
Atsushi Yoshimura | Atushi.Yoshimura@amd.com |