A CUDA ray-tracer that demonstrates 10 levels of rendering, from textbook ray-casting to a path-traced + denoised final image. Live X11 display, key-bound level switching.
| Key | Level | What's added |
|---|---|---|
| 1 | Ray casting | Hit/miss, colour = surface normal |
| 2 | Lambert diffuse | One bounce of direct light, no shadows |
| 3 | Hard shadows | Shadow rays toward each point light |
| 4 | Specular | Blinn-Phong highlights |
| 5 | Reflections | Recursive mirror bounces |
| 6 | Refraction | Glass spheres, Snell + Schlick Fresnel |
| 7 | Path traced | Monte Carlo GI with cosine-weighted hemisphere sampling, next-event estimation, Russian roulette |
| 8 | Denoised | Level 7 + edge-aware À-Trous wavelet filter |
| 9 | OptiX | Stub — requires the NVIDIA OptiX SDK. Falls back to level 5 with a banner. |
| 0 | Mesh | Same scene but spheres are 20-triangle icosahedra (160 tris total), brute-force ray-triangle |
| Key | Action |
|---|---|
| 1–9, 0 | Switch level |
| Space | Pause/resume camera animation (lets path tracing accumulate) |
| R | Reset path-trace accumulation |
| Esc / Q | Quit |
The window title shows the current level and, in path-tracing mode, the accumulated samples-per-pixel.
- NVIDIA GPU with CUDA support
nvidia-cuda-toolkit(providesnvcc)libx11-dev
nvcc raytracer.cu -O3 -arch=sm_86 -use_fast_math -lX11 \
-Xcompiler '-Wall -Wextra -Ofast' -std=c++14 -o raytracer
./raytracer
Adjust -arch=sm_XX to match your GPU's compute capability if it is not Ampere.