This implementation demonstrates the use of VK_KHR_ray_tracing_position_fetch
extension in Vulkan. It enables raytracing using only the acceleration structure data, without additional vertex buffers.
Key aspects:
- Positions are fetched directly from the acceleration structure
- Geometric normals are calculated from retrieved positions
- All buffers used for acceleration structure creation are deleted pre-rendering
- Results in a lightweight rendering process
For detailed information: Vulkan Ray Tracing Position Fetch Extension
// Add to bottom acceleration structure
VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DATA_ACCESS_KHR
VkPhysicalDeviceRayTracingPositionFetchFeaturesKHR fetchFeatures{
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_POSITION_FETCH_FEATURES_KHR
};
spec.vkSetup.addDeviceExtension(
VK_KHR_RAY_TRACING_POSITION_FETCH_EXTENSION_NAME,
false,
&fetchFeatures
);
In the closest hit shader (raytrace.chit
):
vec3 vertex = gl_HitTriangleVertexPositionsEXT[n];