Class EXTOpacityMicromap

java.lang.Object
org.lwjgl.vulkan.EXTOpacityMicromap

public class EXTOpacityMicromap extends Object
When adding transparency to a ray traced scene, an application can choose between further tessellating the geometry or using an any-hit shader to allow the ray through specific parts of the geometry. These options have the downside of either significantly increasing memory consumption or adding runtime overhead to run shader code in the middle of traversal, respectively.

This extension adds the ability to add an opacity micromap to geometry when building an acceleration structure. The opacity micromap compactly encodes opacity information which can be read by the implementation to mark parts of triangles as opaque or transparent. The format is externally visible to allow the application to compress its internal geometry and surface representations into the compressed format ahead of time. The compressed format subdivides each triangle into a set of subtriangles, each of which can be assigned either two or four opacity values. These opacity values can control if a ray hitting that subtriangle is treated as an opaque hit, complete miss, or possible hit, depending on the controls described in Ray Opacity Micromap.

This extension provides:

  • a VkMicromapEXT structure to store the micromap,
  • functions similar to acceleration structure build functions to build the opacity micromap array, and
  • a structure to extend VkAccelerationStructureGeometryTrianglesDataKHR to attach a micromap to the geometry of the acceleration structure.
Reference Code

 uint32_t BarycentricsToSpaceFillingCurveIndex(float u, float v, uint32_t level)
 {
     u = clamp(u, 0.0f, 1.0f);
     v = clamp(v, 0.0f, 1.0f);
 
     uint32_t iu, iv, iw;
 
     // Quantize barycentric coordinates
     float fu = u * (1u << level);
     float fv = v * (1u << level);
 
     iu = (uint32_t)fu;
     iv = (uint32_t)fv;
 
     float uf = fu - float(iu);
     float vf = fv - float(iv);
 
     if (iu >= (1u << level)) iu = (1u << level) - 1u;
     if (iv >= (1u << level)) iv = (1u << level) - 1u;
 
     uint32_t iuv = iu + iv;
 
     if (iuv >= (1u << level))
         iu -= iuv - (1u << level) + 1u;
 
     iw = ~(iu + iv);
 
     if (uf + vf >= 1.0f && iuv < (1u << level) - 1u) --iw;
 
     uint32_t b0 = ~(iu ^ iw);
     b0 &= ((1u << level) - 1u);
     uint32_t t = (iu ^ iv) & b0;
 
     uint32_t f = t;
     f ^= f >> 1u;
     f ^= f >> 2u;
     f ^= f >> 4u;
     f ^= f >> 8u;
     uint32_t b1 = ((f ^ iu) & ~b0) | t;
 
     // Interleave bits
     b0 = (b0 | (b0 << 8u)) & 0x00ff00ffu;
     b0 = (b0 | (b0 << 4u)) & 0x0f0f0f0fu;
     b0 = (b0 | (b0 << 2u)) & 0x33333333u;
     b0 = (b0 | (b0 << 1u)) & 0x55555555u;
     b1 = (b1 | (b1 << 8u)) & 0x00ff00ffu;
     b1 = (b1 | (b1 << 4u)) & 0x0f0f0f0fu;
     b1 = (b1 | (b1 << 2u)) & 0x33333333u;
     b1 = (b1 | (b1 << 1u)) & 0x55555555u;
 
     return b0 | (b1 << 1u);
 }
Name String
VK_EXT_opacity_micromap
Extension Type
Device extension
Registered Extension Number
397
Revision
2
Extension and Version Dependencies
VK_KHR_acceleration_structure and VK_KHR_synchronization2 or Version 1.3
SPIR-V Dependencies
Contact
Extension Proposal
VK_EXT_opacity_micromap
Other Extension Metadata
Last Modified Date
2022-08-24
Interactions and External Dependencies
Contributors
  • Christoph Kubisch, NVIDIA
  • Eric Werness, NVIDIA
  • Josh Barczak, Intel
  • Stu Smith, AMD