Bary file for OMM

Hello,

I’m wondering if there is a sample code which exports bary files for Opacity Micromaps.

Displacement Micromaps have a counterpart:

I guess that the bary file format is also supposed to save OMM arrays since the repository for the bary file and the source code mentions opacity (The title of README looks like that the format is only for DMM though).

I also wonder what the official field names for GLTF OMM extension are.
DMM looks to have:
“micromap”, “groupIndex”, “directions” and “directionBounds”.
Material from the following notes the fields for DMM (while probably forgetting “directions”) but not for OMM.
“Getting Started with Compressed Micro-Meshes”

Thanks,

Should I ask this question in different area instead of OptiX?

I knew there was a thread I forgot to reply to. Sorry about that.

We do have OMM baking in the OptiX toolkit. Does this help? optix-toolkit/OmmBaking at master · NVIDIA/optix-toolkit · GitHub

I’m pretty sure there are also some Vulkan-based baking tools, but I’ll have to poke for them next week after everyone’s back from the holiday.


David.

Thanks for the reply.
As in my original comment, I’m curious in Bary file + OMM rather than how to implement OMM baker. (Actually I have my own CUDA-based baker while not so complete…)

“Getting Started with Compressed Micro-Meshes”
This material suggests that there is an extension to GLTF for OMM and bary file format looks to have some opacity-related fields. However neither of them are detailed.

For OMM-s there is at least an SDK:

Getting Started with OMM SDK | NVIDIA Developer

and the code samples:
GitHub - NVIDIAGameWorks/Opacity-MicroMap-Samples: Samples repository for the Opacity MicroMap SDK

This project uses the Bary format for I/O of maps with gltf files:

Thanks.
I’m aware of OMM-SDK/Samples for sure, but these don’t export OMM data to a external file like GLTF + bary files like DMM toolkit.
I probably didn’t know the last repository, but is this also for DMM?
I’ll take a look.

The second question in my original post comes from this slide:


What are the official field names for GLTF OMM extension.

Well, this is just NV’s extension, so I can create any my own extension, but I wondered if there is NV’s official scheme here. (and how that is associated to bary file (relates to 1st question))

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).

Thank you very much!
This looks exactly what I look for.