• Stars
    star
    125
  • Rank 284,669 (Top 6 %)
  • Language
    C++
  • License
    Other
  • Created over 1 year ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NVIDIA Displacement Micro-Map Toolkit

This toolkit provides libraries, samples and tools to create and view displaced micromeshes. It is a work in progress and feedback is welcome!

The latest driver exposing VK_NV_displacement_micromap is required to raytrace micromeshes, such as the Vulkan Beta Driver available at https://developer.nvidia.com/vulkan-driver.

We recommend to check the Micro-Mesh Basics slides first as well as the dmm_displacement mini-sample.

There are also NVIDIA GTC presentations Getting Started with Compressed Micro-Meshes [S51410] and Interactive GPU-Based Remeshing of Large Meshes [S51567].

The NVIDIA Micro-Mesh technology covers both opacity micromaps and displacement micromaps. This SDK currently solely covers displacements as a separate SDK exists for opacity.

Building

This repository contains submodules. After cloning, initialize them with:

git submodule update --init --recursive --jobs 8

The one manual dependency is the Vulkan SDK. For Windows, make sure to install the optional "glm" during the install or set the cmake GLM_INCLUDE_DIR location if installed separately.

Further dependencies will be downloaded during the cmake configuration step.

Windows

Tested with Visual Studio 2017, 2019 and 2022. Use cmake-gui to generate project files.

  • Install the Vulkan SDK with glm (set cmake GLM_INCLUDE_DIR if glm is installed separately)
  • Clone this repository and initialize the submodules
  • Run cmake-gui, source code = this repo, build folder = anywhere
  • Configure and Generate. Vulkan paths should be set by the SDK installer.
  • Open path\to\build\micromesh_toolkit.sln with Visual Studio
  • In Solution Explorer, right click micromesh_toolbox and "Set as Startup Project"
  • Build -> Build Solution

See docs/examples.md for usage examples.

Linux

Tested with gcc 11.2.1 and 11.3.0. This assumes build tools and cmake are already installed.

  • Install the Vulkan SDK
  • Install glm (e.g. sudo apt install libglm-dev or sudo dnf install glm-devel)
  • Install X11, GLFW and nVidia-ML libs (sudo apt-get install libx11-dev libxcb1-dev libxcb-keysyms1-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxxf86vm-dev libvulkan-dev libglfw3-dev libnvidia-ml-dev )
  • Clone this repository and initialize the submodules
  • Run source path/to/vulkan-sdk/1.3..<version>/setup-env.sh
  • Run cmake -DVULKAN_BUILD_DEPENDENCIES=on -S . -B path/to/build
  • Run make -C path/to/build -j

See docs/examples.md for usage examples.

Example Micromeshes

The toolkit provides some basic tools to process and bake displacement micromaps. Think of it like creating a heightmap to apply to a low-poly mesh, except the heightmap is highly compressed, supports hardware accelerated raytracing and doesn't need UVs. Some example starting assets are provided here to demonstrate toolkit usage. Download these to get started but feel free to try your own.

Note that these tools currently only support assets in glTF format. Everything else must be converted.

See docs/examples.md for typical asset processing examples using these meshes.

SDK and Toolkit Structure

micromesh SDK

The NVIDIA Displacement Micro-Map SDK is the low-level API meant for embedding in other applications and tools. It has a C-style API as well as an API agnostic GPU interface to facilitate this. As a result it is sometimes a bit less easy to use. All functionality is provided through the micromesh namespace and it makes frequent use of the micromesh::ArrayInfo structure, which allows it to pass data as a pointer & stride combination. All user visible data is allocated by the user, so some operations are executed in two steps where a micromeshOpSomethingBegin returns the sizing required, while micromeshOpSomethingEnd completes it. One can also abort such operations with micromeshOpContextAbort. The micromesh::Context therefore is stateful but fairly lightweight, in case you want to create one per thread. Right now there is also some rudimentary automatic threading within the context.

bary file

  • NVIDIA Displacement Micro-Map BaryFile: library for the .bary file container that is used to store micromaps. The repository provides three libraries
    • bary_core: The core library defines the structs used in the container and provides basic functions that aid validation and serialization. C-style interface.
    • bary_utils: Utility library has C++ utilities that aid storing data with stl containers as well as loading or saving things via file operations.
    • bary_tool: A command-line tool that prints key information about the content of .bary files.

meshops API

The meshops API is a layer above the micromesh SDK, that provides easier usage and higher level operations, such as baking. The functions typically operate on a single mesh provided in memory through an abstraction called meshops::MeshView. This layer makes use of a Vulkan implementation for the various GPU-based operations and leverages the nvpro_core framework doing so.

This meshops layer is still a bit work in progress as we are migrating additional capabilities to it and might see a few more changes than the micromesh API.

  • meshops_core: Provides the main framework for the meshops namespace and covers several basic operations
  • meshops_bake: Features a variety of operations based on raytracing from the base mesh to the high detail reference mesh. We want to point out this is not a commercial class baker and it primarily exists for sample purposes.
    • meshops_remesher: The remesher runs a novel GPU-accelerated mesh simplification algorithm and also generates other mesh properties useful for displacement micromap baking.
    • generate displacement micromaps for high detail reference meshes, which optionally can be tessellated on the fly to account for additional heightmap displacement if provided.
    • resample existing textures from the high detail reference mesh to the base mesh (also allows creation or resampling of tangent space normal maps).

tools & libraries

All tools operate on glTF 2.0 files and do support additional micromap specific glTF extensions from NVIDIA. The specifications are available at KhronosGroup/glTF#2273.

All micromap data is stored as .bary files which is a new container / file format that was specifically designed to allow direct storage of data consumed by the raytracing APIs without additional processing. See the open-source NVIDIA Displacement Micro-Map BaryFile for more details.

  • micromesh_tool: This is the main tool for meshops based operation. We intend to move all tooling operations here, but haven't completed this migration and refactoring yet. The tool operations currently operate on an independent scene state (load gltf freshly), in future there will be a persistent in-memory scene that the operations modify. The tool currently supports:
    • baking using meshops_bake
    • pre-tessellation using meshops_core, compute subdivision levels and adjust base mesh tessellation to account for subdiv level 5 limit
    • displaced-tessellation using meshops_core, create a tessellated mesh that applies all displacements provided through the micromaps (flatten the mesh to traditional triangles)
    • optimization: trims and compresses micromeshes. Since only compressed micromaps are compatible with the ray tracing APIs, this can be used to prepare uncompressed micromaps for rendering.
    • remeshing using meshops_remesher, decimates a mesh to be used as a base mesh for baking.
  • micromesh_python: This is a python module with similar functionality to micromesh_tool, exposing toolkit operations from the meshops_* layer, but without the dependence on glTF. It operates on meshes with geometry and other attributes defined by more generic numpy arrays."

mini samples

The mini-samples showcase our APIs in a minimal fashion, not relying on loading models or other files, but just procedurally generating content to reduce the amount of complexity

  • dmm_displacement: Learn how to raytrace displaced micromeshes using the VK_NV_displacement_micromap extension. It also shows how to create the necessary data for it in a minimal fashion using the micromesh sdk. The extension support is mandatory for this sample.

At the time of writing VK_NV_displacement_micromap is in beta still, meaning the extension is subject to changes. Do not use its headers here in production code!

micromesh toolbox

The micromesh_toolbox is a graphical workbench that allows inspecting micromeshes as well as interacting with some of the tools. It relies on VK_NV_mesh_shader to allow rasterized display of micromeshes. VK_KHR_acceleration_structure is required for baking micromaps. If available, VK_NV_displacement_micromap is used to render micromeshes with raytracing when choosing Rendering -> RTX. VK_NV_displacement_micromap was introduced with the Ada Lovelace architecture based GPUs. If you see a message about the missing extension, update to the latest driver (note: beta drivers are available at https://developer.nvidia.com/vulkan-driver).

The rasterization of micromeshes, especially compressed is a bit of a more complex topic on its own. Therefore there will be a future dedicated sample that goes into the details of how it works and showcases more features, such as dynamic level-of-detail. We recommend to wait for this, rather than attempt to embed the code from the toolbox. The future sample will also provide more performant solutions and address compute-based rasterization as well.

At the time of writing VK_NV_displacement_micromap is in beta still, meaning the extension is subject to changes. Do not use its headers here in production code!

micromesh tool

The command line tool, micromesh_tool, can be used for automation and defining persistent asset pipelines.

micromesh python

The python bindings for the toolkit, summarized in a Jupyter Notebook, can be used for integrating asset pipelines inside any application supporting a Python environment.

See micromesh_python for more details.

Fundamental Data Structures

A micromesh is the result of subdividing a base triangle using a power of two scheme. It is made of microtriangles and microvertices.

Triangle W,U,V

          V                     V                       V
          x                     x                       x
         / \                   / \ micro               / \
        /   \                 /   \ triangle          x _ x microvertex
       /     \               /     \                 / \ / \
      /       \             x _____ x               x _ x _ x
     /         \           / \     / \             / \ / \ / \
    /           \         /   \   /   \           x _ x _ x _ x
   /             \       /     \ /     \         / \ / \ / \ / \ 
  x _____________ x     x _____ x _____ x       x _ x _ x _ x _ x
W                  U   W                  U   W                   U

Subdivision level 0    Subdivision level 1    Subdivision level 2
  1 microtriangle        4 microtriangles       16 microtriangles
  aka base triangle

See docs/data_structures.md for more details on how this is used to generate displacement.

Micromesh Asset Pipeline

We describe the core steps that would be performed to create a micromesh asset from an original input mesh in the Micro-Mesh Asset Pipeline slide-deck as well as in docs/asset_pipeline.md

About the Latest Release (1.1)

  • Heightmap rendering in micromesh_toolkit with dynamic LOD
  • Memory estimate for baking high resolution heightmaps in batches
  • Micromesh USD schema definitions and libusd API
  • meshopsOpApplyBounds() to apply (and discard) direction bounds to positions and directions
  • Better glTF instancing/node hierarchy support for baking whole scenes
  • Fixes for image filename generation when resampling
  • Avoid leaving unused and empty glTF extension references
  • Fix matching regular texture names in automation/link_heightmaps.py

Third-Party Licenses

This project embeds or includes (as submodules) several third-party open-source libraries and/or code derived from them. All such libraries' licenses are included in the PACKAGE-LICENSES folder of this project or of the nvpro_core dependency.

Support Contact

Feel free to file issues directly on the GitHub page or reach out to NVIDIA at [email protected]

More Repositories

1

kaolin

A PyTorch Library for Accelerating 3D Deep Learning Research
Python
4,424
star
2

PhysX

NVIDIA PhysX SDK
C++
2,893
star
3

Falcor

Real-Time Rendering Framework
C++
2,615
star
4

PhysX-3.4

NVIDIA PhysX SDK 3.4
C++
2,307
star
5

kaolin-wisp

NVIDIA Kaolin Wisp is a PyTorch library powered by NVIDIA Kaolin Core to work with neural fields (including NeRFs, NGLOD, instant-ngp and VQAD).
Python
1,451
star
6

rtx-remix

Combined repo for the RTX-Remix runtime
1,354
star
7

DxrTutorials

C++
828
star
8

RTXGI-DDGI

RTX Global Illumination (RTXGI)
C++
685
star
9

GettingStartedWithRTXRayTracing

Getting Started with RTX Ray Tracing
C++
613
star
10

RTX-Path-Tracing

Real-time path tracing library and sample
C++
599
star
11

FleX

C++
579
star
12

nvrhi

C++
525
star
13

RayTracingDenoiser

NVIDIA Ray Tracing Denoiser
HLSL
505
star
14

FaceWorks

A middleware library and sample application for high-quality skin and eye rendering
C++
450
star
15

NVIDIAImageScaling

NVIDIA Image Scaling SDK
C
426
star
16

Streamline

Streamline Integration Framework
C
375
star
17

RTXDI

C++
347
star
18

Blast

A modular destruction SDK designed for performance and flexibility, replacing APEX destruction
C++
331
star
19

dxvk-remix

C++
303
star
20

NvCloth

C
296
star
21

KickstartRT

KickstartRT SDK
C++
185
star
22

Flow

Flow is a sparse grid-based fluid simulation library for real-time applications.
C
168
star
23

donut

C++
164
star
24

HBAOPlus

HBAO+
C++
160
star
25

bridge-remix

This is the NVIDIA RTX Remix Runtime Bridge repository
C++
146
star
26

SpatiotemporalBlueNoiseSDK

C
127
star
27

UnityPhysXPlugin

Experimental Unity package to enable access to NVIDIA PhysX SDK 4 from within Unity.
C#
122
star
28

NRI

C++
90
star
29

RTXMU

C++
89
star
30

donut_examples

C++
72
star
31

ShaderMake

Shader Compilation Tool
C++
72
star
32

NRDSample

C++
69
star
33

GeForceNOW-SDK

This is the home of the SDK for GeForce NOW
C
65
star
34

KickstartRT_demo

Repo for KickstartRT demo application
C++
50
star
35

Opacity-MicroMap-SDK

Opacity Micro-Map SDK Source Repository
C++
36
star
36

MathLib

C++
28
star
37

Displacement-MicroMap-SDK

C++
19
star
38

nas-sample

C++
16
star
39

Streamline_Sample

C++
16
star
40

ComfyUI-RTX-Remix

ComfyUI RTX Remix
Python
14
star
41

Opacity-MicroMap-Samples

Samples repository for the Opacity MicroMap SDK
C++
11
star
42

Displacement-MicroMap-BaryFile

C++
11
star
43

NRIFramework

C
8
star
44

NRISamples

C++
7
star
45

rtxdi-runtime

HLSL
2
star