Turn an alpha mask into traversal data

After you identify a suitable asset, you need to describe its opacity in a form that ray traversal can use. Opacity Micromaps (OMM) do this by dividing each original triangle into smaller regions called microtriangles. Each microtriangle records whether its part of the alpha mask is opaque, transparent, or still uncertain.

A microtriangle changes the OMM data, not the mesh. It doesn’t add polygons to the source model or to the bottom-level acceleration structure (BLAS). You can think of it as placing a finer decision grid over the original triangle.

Image Alt Text:Diagram showing a leaf alpha mask covered by microtriangles. Opaque cells fill the leaf, transparent cells cover empty space, and unknown cells follow the boundary where shader evaluation can still be needed.Microtriangle states follow the leaf's alpha boundary

The figure keeps the two original triangles and overlays a finer OMM grid. Opaque regions cover the inside of the leaf. Transparent regions cover empty parts of the quad. Unknown regions follow the detailed edge. The closer the grid follows that edge, the more opacity decisions traversal can make without shader help.

Choose a subdivision level

The subdivision level controls the resolution of the OMM grid. A low level uses a few large regions. A higher level uses many smaller regions and can follow a curved or detailed alpha boundary more closely.

This extra detail has a cost: each step up creates four times as many microtriangles. For level N, the number in each original triangle is:

    

        
        
microtriangle count = 4^N = 2^(2N)

    
LevelMicrotriangles per original triangleTypical use
01One state for the complete triangle
14A coarse cutout
216Large silhouette changes
364Curved alpha edges
4256Fine detail with higher data cost

Choose the level by comparing the size of the source triangle with the detail in its alpha mask. Also consider the intended level of detail (LOD) and viewing distance. Don’t map the subdivision level directly to screen pixels because the same triangle can appear at many sizes on screen.

Choose a state format

The subdivision level decides how small the regions are. The state format decides what each region can say about its opacity.

The VK_KHR_opacity_micromap extension defines 2-state and 4-state formats. A 2-state OMM must call every region opaque or transparent. A 4-state OMM can also leave a region unknown, allowing the existing shader path to resolve difficult edges at runtime.

FormatStateNormal traversal actionIf forced to 2-state
2-stateFully transparentIgnore the hit.No change
2-stateFully opaqueHandle the region as opaque.No change
4-stateFully transparentIgnore the hit.No change
4-stateFully opaqueHandle the region as opaque.No change
4-stateUnknown-transparentKeep shader-side evaluation available.Treat the region as transparent.
4-stateUnknown-opaqueKeep shader-side evaluation available.Treat the region as opaque.

During normal 4-state traversal, both unknown values mean that more evaluation is needed. The transparent and opaque variants produce different results only when a ray or instance forces the OMM into 2-state evaluation.

This gives you two practical starting strategies:

StrategyOMM setupMain tradeoff
Shader-assisted edge detail4-state with low or moderate subdivisionSmaller OMM data, but unknown edges retain some shader-side work
Hardware-resolved binary detail2-state with higher subdivisionNo unknown states, but more microtriangles and possible silhouette error

Use the 2-state strategy only when you can classify every region without damaging the image. Marking visible detail as transparent can remove a valid hit. Marking empty space as opaque can create false shadows or reflections.

Classify sample microtriangles

You can practice classification without OMM-capable hardware. Classify using an alpha cutoff of 0.5. Values less than the cutoff are transparent, while values greater than or equal to it are opaque.

Each row contains representative samples from one microtriangle. Classify each region as opaque, transparent, or unknown:

RegionRepresentative alpha samples
A1.00, 0.92, 0.87
B0.00, 0.08, 0.14
C0.05, 0.62, 0.91
D0.42, 0.45, 0.48
E0.49, 0.50, 0.51

After classifying each region, calculate the raw state payload for one level-2 triangle. Level 2 contains 16 microtriangles. The 2-state format uses one bit per microtriangle, while the 4-state format uses two bits.

Check your classification and payload calculation

Compare your answers with the following classifications:

RegionClassificationReason
AOpaqueEvery sample is on the visible side of the cutoff.
BTransparentEvery sample is below the cutoff.
CUnknownThe region crosses the cutoff.
DTransparentEvery sample is below the cutoff.
EUnknownThe region lies on both sides of the cutoff.

A level-2 triangle needs 16 bits, or 2 bytes, of raw 2-state data. It needs 32 bits, or 4 bytes, of raw 4-state data. These values describe only the state payload. Record metadata, alignment, and implementation-specific storage can increase the final size.

Interpret the result

The result should contain large areas of opaque and transparent microtriangles, with a narrow band of unknown regions around the alpha boundary. If much of the triangle remains unknown, traversal still needs shader help for many hits.

A wide unknown band can mean the following:

  • The subdivision level is too low
  • There’s a mismatch in filtering or cutoff
  • The texture detail is too fine for the grid
  • There’s material logic that the baker can’t reproduce

What you’ve accomplished and what’s next

You’ve classified opacity regions and compared the accuracy and storage implications of the two formats.

Next, you’ll connect the baked representation to the Mali G2-Ultra NX traversal path.

Back
Next