Skip to content

Opacity Micromaps and framework for simple engine courses#385

Open
gpx1000 wants to merge 13 commits into
KhronosGroup:mainfrom
gpx1000:opacity-micromaps-advanced-chapter
Open

Opacity Micromaps and framework for simple engine courses#385
gpx1000 wants to merge 13 commits into
KhronosGroup:mainfrom
gpx1000:opacity-micromaps-advanced-chapter

Conversation

@gpx1000

@gpx1000 gpx1000 commented May 30, 2026

Copy link
Copy Markdown
Contributor

Add Opacity Micromaps course
Add framework for new special complex topics for simple engine.

Add four SVG diagrams illustrating shadow concepts (hard shadows, soft shadows, foliage alpha-testing problem, shadow ray lifecycle, and triangle subdivision) and create the introduction chapter for the Opacity Micromaps course explaining the performance problem with alpha-tested geometry in ray-traced shadows.

gpx1000 added 3 commits May 30, 2026 02:02
Add four SVG diagrams illustrating shadow concepts (hard shadows, soft shadows, foliage alpha-testing problem, shadow ray lifecycle, and triangle subdivision) and create the introduction chapter for the Opacity Micromaps course explaining the performance problem with alpha-tested geometry in ray-traced shadows.
… people should use.

At time of writing, Vulkan 3.4.350 sdk isn't yet available. so I'll hold back the changes to the source code example.  That one will stay on EXT until the sdk that can support this has been released.
@gpx1000

gpx1000 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

The CI will fail until LunarG updates the VulkanSDK to 1.4.351. The release that has KHR version of the extension. Currently 1.4.350 is the most released version and we use the LunarG sdk in CI.

…ated the CMake to automatically grab Vulkan_hpp when local SDK doesn't have the KHR OMM.
@SaschaWillems

Copy link
Copy Markdown
Collaborator

Can we merge #388 and then update this branch from master? I'm seeing the same issues as during my review of the glTF PR that stop me from building the code part of this PR.

Comment thread attachments/simple_engine/renderer.h
@SaschaWillems

Copy link
Copy Markdown
Collaborator

Still going through the tutorial, but one thing I'm missing: There doesn't seem to be any mention of how to build the actual code in the tutorial. Could that be added?

@SaschaWillems SaschaWillems self-requested a review June 13, 2026 09:29
@@ -0,0 +1,120 @@
= Simple Engine — Course Modules

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing from the navigation and as such inaccessible to readers. It also looks to be in the wrong folder (source instead of documentation).


The right choice depends on the texture content and the performance targets of the application. Content with sharp, high-contrast alpha masks (like a chain-link fence with near-binary alpha) benefits greatly from even low subdivision levels because the boundaries are crisp. Content with soft, gradual alpha transitions (like hair cards or feathers) may require higher subdivision levels to keep the unknown fraction small.

== Building the Micromap: A One-Time Investment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be expanded with some more details? Like how do you actually build a micromap at runtime, and how (if possible) to offline create those?


This is the complete description of an **Opacity Micromap**: a data structure, attached to a triangle mesh in the GPU's acceleration structure, that subdivides each triangle into a regular grid of smaller triangles and assigns each one a pre-computed opacity state. The word "micro" is used precisely: these are not additional geometric triangles that the ray tracer has to traverse. They are sub-triangle classifications that the traversal hardware reads as metadata, using them to accelerate the decision of whether a given ray-triangle intersection represents an actual hit.

== Three States, Not Two

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's true for the KHR extension. It supports a 2 and 4 state format, but none with three states.

@SaschaWillems

Copy link
Copy Markdown
Collaborator

Could you do a documentation pass to check if everything has properly been updated to the KHR extensions? I noticed a few things that sound like they apply to the EXT one, and not the (significantly changed) KHR one.

layout(constant_id = N) gl_EnableOpacityMicromapExt;
----

where `N` is a specialisation constant ID. This is a one-line addition to the shader — not a logical change — but without it, the hardware silently ignores all micromap data during ray query traversal and falls back to the full any-hit shader path on every intersection, as if no micromaps were attached at all. This was a deliberate design change from `VK_EXT_opacity_micromap`, where the optimisation was implicit for ray queries. The explicit declaration makes the hardware intent unambiguous and allows compilers to reason about it correctly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...silently ignores all micromap data...

Is that true? The description of OpacityMicromapIdKHR in the SPIR-V spec sounds different:

If ray query traversal uses acceleration structures with opacity micromaps, this execution mode must be specified with a value of true; otherwise, undefined behavior results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants