This sample demonstrates the implementation of Opacity Micro-Maps in Vulkan for efficient ray tracing.
- Encodes visibility for triangle sub-regions
- Triangle classification: opaque (blue), transparent unknown (red), transparent (invisible)
- Selective AnyHit shader invocation based on opacity state
4^subdivisiontriangles per subdivision level- Barycentric coordinate mapping using
BirdCurveHelper::micro2bary - World position projection for radius-based classification
- Value Buffer: 2-state (1-bit) or 4-state (2-bit) opacity encoding
VkMicromapTriangleKHRBuffer: Maps triangles to value buffer data- Index Buffer: Continuous array for
VkMicromapTriangleKHRindexing - Micromap object:
VkMicromapEXT(EXT path) orVkAccelerationStructureKHR(KHR path)
- EXT path:
VkAccelerationStructureTrianglesOpacityMicromapEXTchained viapNext - KHR path:
VkAccelerationStructureTrianglesOpacityMicromapKHRchained viapNext
The sample supports both VK_EXT_opacity_micromap (original NV extension) and VK_KHR_opacity_micromap (the promoted KHR standard). At startup the sample requests both; KHR is preferred when available, with EXT as a fallback for drivers that do not yet expose the KHR extension.
The two extensions differ fundamentally in how the micromap object is built and referenced:
VK_EXT_opacity_micromap |
VK_KHR_opacity_micromap |
|
|---|---|---|
| Micromap handle | VkMicromapEXT |
VkAccelerationStructureKHR |
| Create function | vkCreateMicromapEXT |
vkCreateAccelerationStructure2KHR |
| Build function | vkCmdBuildMicromapsEXT |
vkCmdBuildAccelerationStructuresKHR |
| Geometry type | (dedicated API) | VK_GEOMETRY_TYPE_MICROMAP_KHR |
| AS type | (dedicated API) | VK_ACCELERATION_STRUCTURE_TYPE_OPACITY_MICROMAP_KHR |
| Geometry data | VkMicromapBuildInfoEXT |
VkAccelerationStructureGeometryMicromapDataKHR via pNext |
| BLAS attachment | VkAccelerationStructureTrianglesOpacityMicromapEXT |
VkAccelerationStructureTrianglesOpacityMicromapKHR |
When using the KHR build path, several rules differ from a regular BLAS build:
VK_KHR_device_address_commandsmust also be requested — it is a required dependency ofVK_KHR_opacity_micromap.vkGetAccelerationStructureBuildSizesKHR:pMaxPrimitiveCountsmust beNULL(size is derived from the usage counts on the geometrypNextchain).vkCreateAccelerationStructure2KHR(notvkCreateAccelerationStructureKHR) is required forVK_ACCELERATION_STRUCTURE_TYPE_OPACITY_MICROMAP_KHR; it takes aVkDeviceAddressRangeKHRinstead of aVkBuffer.vkCmdBuildAccelerationStructuresKHR:ppBuildRangeInfosmust be a valid pointer, butppBuildRangeInfos[i]must beNULLfor micromap geometry entries.- Input buffers (
data,triangleArray) must be created withVK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR, not only the EXT micromap bit.
- Automated asset conversion for ray tracing optimization
- Texture and geometry analysis
- Runtime or offline processing capabilities
- CPU and GPU conversion options
- Compatible with various ray tracing applications
- Flexible API for pipeline integration
- Supports diverse hardware and software configurations


