Featured Article

Mastering Vulkan Ray Tracing: Step-by-Step Pipeline Example

Cynthia Jul 13, 2026

The advent of ray tracing has revolutionized graphics rendering, bringing cinematic-quality visuals to real-time applications. Vulkan, the cross-platform 3D graphics and computing API, has embraced this technology, offering developers a powerful pipeline for integrating ray tracing into their applications. Let's delve into the Vulkan ray tracing pipeline, exploring its key components and provide practical examples to illustrate its functionalities.

Ray Tracing, Lumen and Path Tracing Explained | For Beginners By TUF – The Unreal Forge
Ray Tracing, Lumen and Path Tracing Explained | For Beginners By TUF – The Unreal Forge

Vulkan's approach to ray tracing is built upon extensions that augment the core API, providing a flexible and extensible framework for developers. The Vulkan Ray Tracing Pipeline (VK_KHR_ray_tracing_pipeline) extension is pivotal, enabling the creation of ray tracing pipelines that can be ["instanced`](https://www.khronos.org/files/vulkanRAYTRACING.pdf) and dynamically updated, much like Vulkan's graphics pipelines.

From Ray Tracing FTW to VidViz: How a Labs Experiment Became a Unified Pipeline | Christopher Nichols
From Ray Tracing FTW to VidViz: How a Labs Experiment Became a Unified Pipeline | Christopher Nichols

The Vulkan Ray Tracing Pipeline

The Vulkan ray tracing pipeline is designed to be extensible, allowing developers to evolve their shading and intersection tests as their needs grow. At its core, it consists of three main stages: hit groups,_acceleration structures, and ray tracing shaders.

NVIDIA DLSS 4 Multi Frame Generation and New RTX Technologies Coming To 75 Games and Apps At Launch
NVIDIA DLSS 4 Multi Frame Generation and New RTX Technologies Coming To 75 Games and Apps At Launch

The VK_KHR_ray_tracing_pipeline extension introduces three new shader stages: closest hit, any hit, and miss. These stages$resultant shaders`run in response to intersections between rays and acceleration structures, or when no intersection is found.

Hit Groups and Shaders

volcano diagram with labeled parts labelled in black and white, including the main ventils
volcano diagram with labeled parts labelled in black and white, including the main ventils

Hit groups in Vulkan serve as containers for ray tracing shaders, allowing developers to associate specific shaders with different object types or materials. The closest hit and any hit shaders run when a ray intersects with an object, providing opportunities to shaded the intersection and contribute to the final image.

consider a simple example where we have two hit groups: one for a reflective material and another for a diffuse material. In this case, a ray may intersect with both materials within a single trace, calling for different shaders in each hit group to handle the shading for each intersection respectively:

```c VkRayTracingPipelineInterfaceCreateInfoKHR interfaceCreateInfo = {...}; VkPipelineInterstageHitKHR hit = { /* ... */ }; VkPipelineInterstageMissKHR miss = { /* ... */ }; VkPipelineLayoutCreateInfo layoutInfo = {...}; layoutInfo.pushConstantRangeCount = 0; VkRayTracingPipelineLayoutKHR pipelineLayout; vkCreateRayTracingPipelineLayoutKHR(device, &layoutInfo, nullptr, &pipelineLayout); VkRayTracingPipelineCreateInfoKHR pipelineInfo = {...}; vkCreateRayTracingPipelinesKHR(device, VK_NULL_HANDLE, pipelineInfo, nullptr, &rayTracingPipelines); ```

Acceleration Structures and Tracing Rays

an article in the usgs on volcano hazard
an article in the usgs on volcano hazard

Acceleration structures in Vulkan are used to accelerate ray tracing performance by organizing and representing geometric data in a way that facilitates efficient intersection tests. The VK_KHR_acceleration_structure extension provides APIs for building these structures and tracing rays against them.

To create an acceleration structure, developers must first build a top-level acceleration structure (TLAS) and one or more bottom-level acceleration structures (BLAS). The TLAS represents the scene graph, while BLAS represent instances of geometry. Here's a simplified example of creating a BLAS:

```c VkAccelerationStructureBuildGeometryFlagsKHR buildFlags = (VK_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_OPAQUE_BIT_KHR | VK_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_ALLOW_COMPACTION_BIT_KHR); VkAccelerationStructureGeometryDataKHR geometryData = {...}; VkAccelerationStructureBuildGeometryInfoKHR buildGeometryInfo = {...}; vkBuildAccelerationStructureGeometryKHR(device, &buildGeometryInfo, &geometry); VkAccelerationStructureGeometryAccelerationStructureInfoKHR accelerationStructureInfo = {...}; vkBuildAccelerationStructureGeometryAABBsKHR(device, &accelerationStructureInfo, &promotedIndices); ```

Integrating Ray Tracing into Vulkan Applications

the layers of an active volcano are labeled in this diagram, including lava and ash
the layers of an active volcano are labeled in this diagram, including lava and ash

Incorporating ray tracing into existing Vulkan applications involves several steps: enabling the required extensions, implementing the application's command buffer recording and submission logic, creating acceleration structures, and implementing ray tracing shaders.

Firstly, developers must enable the necessary ray tracing extensions. This can be done using the `VK_EXT_enable_extension` method, which declares support for specific extensions:

an image of the inside of a volcano
an image of the inside of a volcano
the diagram shows how to make a volcano in this graphic workbook, which includes instructions for
the diagram shows how to make a volcano in this graphic workbook, which includes instructions for
the structure of an active volcano
the structure of an active volcano
VOLCANES: Partes de un volcán
VOLCANES: Partes de un volcán
the structure of a volcano is shown in this graphic above it's main features
the structure of a volcano is shown in this graphic above it's main features
the cross section through a volcano is labeled in red and white text, with arrows pointing to different locations
the cross section through a volcano is labeled in red and white text, with arrows pointing to different locations
the cross section of a volcano
the cross section of a volcano
an image of the inside of a volcano with its layers labeled in english and spanish
an image of the inside of a volcano with its layers labeled in english and spanish
Tutorial: Time-Lapse HDRI Skies in V-Ray 3 - Hyperfocal Design
Tutorial: Time-Lapse HDRI Skies in V-Ray 3 - Hyperfocal Design

```c VkEnableExtensionEXTEnableEXT info = {...}; vkEnableExtensionEXT(device, &info); ```

Next, developers must implement the command buffer recording and submission logic. This involves creating command pools, allocating command buffers, and recording commands to build and trace acceleration structures, as well as dispatching rays.

Finally, developing ray tracing shaders using the SPIR-V language and integrating them into the application's pipeline cache complete the process. These shaders perform the actual shading computations during a ray tracing pass.

The integration of ray tracing into Vulkan applications opens up a world of possibilities, enabling developers to create photorealistic and visually stunning effects that were once the exclusive domain of offline renderers. As the technology continues to evolve, we can expect to see even more advanced and innovative use cases emerge, pushing the boundaries of real-time rendering.