Hi @shocker.0x15! I’m putting together some sample code to show this more clearly, but here’s a textual description of how to store OMMs in .bary files and use them in glTF.
.bary
We support OMMs in .bary files! The gist of it is it’s pretty similar to storing a DMM in a .bary file:
The only standard properties you’ll need are eValues
, eGroups
, and eTriangles
. Basically, eValues
is a byte buffer, each group points to a range of triangles, and each triangle specifies a subdivision level, subformat, and points to values.
There are a few optional properties that you don’t need to specify, but can make your app faster or help your content workflow in other ways if you can make use of them. Mip properties can help rasterizers (if you’re writing a custom OMM rasterizer that needs to handle LOD), the histogram properties can save you a small amount of time when building (so you don’t need to compute the number of OMMs with a given subdivision level at runtime), and eMeshPositions
and eMeshTriangleIndices
are there for debugging in case you have a .bary file but can’t find the mesh it was for. The other properties like eTriangleMinMaxs
and eMeshDisplacementDirections
are only useful for DMMs.
glTF
The proposed extension for OMMs in glTF is NV_opacity_micromap
; you can find the specification for it in the pull request here or using GitHub’s formatting here!
The core of the extension is pretty straightforward: you can point a glTF primitive
to a micromap (.bary file), and then optionally tell it to use a specific .bary group (if there are multiple groups of data in a .bary file) or adjust or override the OMM index each triangle uses. In the example, we use the first .bary file in the micromaps
array, and override the triangle → OMM mapping:
"meshes": [
{
"primitives": [
{
"indices": 0,
"material": 0,
"attributes": {
"POSITION": 1,
"NORMAL": 2,
"TEXCOORD_0": 3,
"TANGENT": 4
},
"extensions": {
"NV_opacity_micromap": {
"micromap": 0,
"mapIndices": 5
}
}
}
]
}
]
You’ll also need a glTF reader that can read these extensions. If you’re using tinygltf
, you can check for the extension in tinygltf::Primitive::extensions
(here’s some helper code for working with tinygltf and DMMs that can be adapted to working with OMMs).