The focus of this repository and the provided code is to showcase a basic integration of
ray tracing within an existing Vulkan sample, using the
VK_KHR_ray_tracing
extension.
To be able to compile and run those examples, please follow the setup instructions. Find more over nvpro-samples
The first tutorial starts from a very simple Vulkan application. It loads a OBJ file and use the rasterizer to render it. The tutorial is adding, step-by-step, all what is needed to be able to ray traced the scene.
Ray Tracing Tutorial -> Start <-
All other tutorials starts from the end of the first ray tracing tutorial and provides also step-by-step instructions to modify, add methods and functions for that extra section.
Tutorial | Details |
---|---|
Any Hit Shader Implements transparent materials by adding a new shader to the Hit group and using the material information to discard hits over time. Adding anyhit (.ahit) to the ray tracing pipeline. Randomly letting the ray hit or not which is making simple transparency. |
|
Jitter Camera Anti-aliases the image by accumulating small variations of rays over time. Random ray direction generation. Read/write/accumulate final image |
|
Thousands of Objects The current example allocates memory for each object, each of which has several buffers. This shows how to get around Vulkan's limits on the total number of memory allocations by using a memory allocator. Extend the limit of 4096 memory allocations. Using memory allocators: DMA, VMA |
|
Reflections Reflections can be implemented by shooting new rays from the closest hit shader, or by iteratively shooting them from the raygen shader. This example shows the limitations and differences of these implementations. Calling traceRayEXT() from the closest hit shader (recursive). Adding more data to the ray payload to continue the ray from the raygen shader. |
|
Multiple Closest Hits Shader and Shader Records Multiple Closest Hits Shader and Shader Records. Explains how to add more closest hit shaders, choose which instance uses which shader, and add data per SBT that can be retrieved in the shader, and more. One closest hit shader per object. Sharing closest hit shaders for some object.Passing shader record to closest hit shader. |
|
Animation This tutorial shows how animating the transformation matrices of the instances (TLAS) and animating the vertices of an object (BLAS) in a compute shader, could be done. Refit of top level acceleration structure. Refit of bottom level acceleration structure. |
|
Intersectiom Shader Adding thousands of implicit primitives and using an intersection shader to render spheres and cubes. The tutorial explains what is needed to get procedural hit group working. Intersection Shader. Sphere intersection. Axis aligned bounding box intersection. |
|
Callable Shader Replacing if/else by callable shaders. The code to execute the lighting is done in separate callable shaders instead of been part of the code. Adding multiple callable shaders. Calling ExecuteCallableEXT from the closest hit shader. |
|
Ray Query Invoking ray intersection queries directly from the fragment shader to cast shadow rays. Ray tracing directly from the fragment shader. |
|
glTF Scene Instead of loading separated OBJ objects, the example was modified to load glTF scene files containing multiple objects. This example is not about shading, but using more complex data than OBJ. |
|
Advance An example combining most of the above samples in a single application. |