Building the BLAS and TLAS
As we mentioned in the previous section, ray tracing pipelines require geometry to be organized into Acceleration Structures to speed up the ray traversal of the scene. In this section, we are going to explain how to accomplish this in Vulkan.
We start by creating a list of VkAccelerationStructureGeometryKHR
when parsing our scene. For each mesh, this data structure is defined as follows:
VkAccelerationStructureGeometryKHR geometry{ VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR }; geometry.geometryType = VK_GEOMETRY_TYPE_TRIANGLES_KHR; geometry.flags = mesh.is_transparent() ? 0 : VK_GEOMETRY_OPAQUE_BIT_KHR;
Each geometry structure can define three types of entries: triangles, AABBs, and instances. We are going to use triangles here, as that’s how our meshes are defined. We are going to use instances later when defining the TLAS.
The following code demonstrates how the triangles...