DirectX Raytracing Tutorials in C++
The main references of this tutorial are CSharpDirectXRaytracing and Nvidia tutorial. If not mentioned in the code, the tutorials from 01-07 are reconstructed from Nvidia tutorial, the 15-19 are ported from CSharpDirectXRaytracing. Part of the shader code in GI is modified from SIGGRAPH 2018 Course. All of those are awesome and useful resources to read.
The tutorial is served as the reconstruction and extension work of the Nvidia tutorial. The refactoring of the code is aiming at a eaiser understanding of DXR, and easier for the learners to extend. Unlike Falcor, the code doesn't has abstraction on the CPU host side.
The GI solution is packaged in release for win64 system.
Windows SDK 10.0.18362.0
Visual Studio 2019
GTX 1070 GPU Card (You can find if your graphics card supports DXR here)
The image shot of each sub-project, the projects can easily be run by clicking CppDirectXRayTracing.sln. Note the 7-14 is blank just because the tutorials diverged from the original nv turotials and I was too lazy to rename them.
Shader for ray-traced triangle
Pass vertex buffer and index bufer to shader instead of hand-made triangles.
The geometry construction is under Primitives.
Simple Phong lighting. Most of the changes are in the shader.
How to pass multiply geometry in to shader. This one combined the geometry into one vertex and index buffer, which is not practical, but doable.
The second way for passing multiple geometry.
The spheres are sent by index buffer and vertex buffer, the normals of the plane are tricky, specified in shader.
How to cast shadow ray and third way for passing multiple geometry. This is the same approach as Nvidia tutorial.
Bind primitive to different BLAS, each of the primitive has its own closest shader. Also instances of the spheres are binded to TLAS.
The aliasing of the shadow is potentially a bug in this way of sending geometry.
Reflections with Phong lighting. Shoot the reflection rays. Also see shaders in CSharpDirectXRaytracing
From now on, we stick to the second way of sending the geometry, which works best.
Set scene constant buffer and primitive constant buffer. This is useful for setting different materials.
How to do full global illumination in DXR. This tutorial implemented naive recursive ray tracer with Lambertian and GGX model. This sub-project is packaged as an win64-exe in release
Use keyboard number 1 to switch between Lambertian GI and AO with direct lighting.
Use keyboard number 2 to open GGX shading.
Use keyboard number 3 to open dynamic lighting.
You are very welcomed to submit issues, extend the tutorial (e.g. better GI solution with less noise, techniques in Ray Tracing Gem), code quality improvements, code comment improvements, etc.
The Nvidia tutorial has a code walk through document, make sure to check it.
SIGGRAPH 2018 Course Good explanation of how to integrate the shader for global illumination.
Ray Tracing in One Weekend The basic theory of GI. The first among the series introduced the basics of ray tracing, the third among the series introduces the Monte Carlo strategy.