Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 00fde4a

Browse files
pknowlesnvbbarranpixeljetstreamakeley98NVmklefrancois
committed
Displacement-MicroMap-Toolkit squash
commit c67035766aa14bba8c5a645b052fbc3c03b7922d Co-authored-by: Brian Barran <[email protected]> Co-authored-by: Christoph Kubisch <[email protected]> Co-authored-by: David Akeley <[email protected]> Co-authored-by: Martin-Karl Lefrancois <[email protected]> Co-authored-by: Mathias Heyer <[email protected]> Co-authored-by: Neil Bickford <[email protected]> Co-authored-by: Pascal Gautron <[email protected]> Co-authored-by: Pyarelal Knowles <[email protected]> Co-authored-by: Tristan Lorach <[email protected]>
1 parent 33e1240 commit 00fde4a

File tree

129 files changed

+7869
-2766
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+7869
-2766
lines changed

CMakeLists.txt

+25-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
33
cmake_policy(SET CMP0079 NEW) # Allow linking with targets in other directories
44
project(
55
micromesh_toolkit
6-
VERSION 1.0
6+
VERSION 1.1
77
DESCRIPTION "Micromesh Tools"
88
LANGUAGES C CXX)
99

1010
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1111

1212
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/_install" CACHE PATH "folder in which INSTALL will put everything needed to run the binaries" FORCE)
1313

14+
# Set the default for enabling beta extensions before nvpro_core. Beta
15+
# extensions can conflict if the Vulkan SDK and nvpro_core generated
16+
# nvvk/extensions_vk.hpp versions are different.
17+
option(VK_ENABLE_BETA_EXTENSIONS "Enable beta extensions provided by the Vulkan SDK" OFF)
18+
1419
# Enable bounds and other error checking for gcc debug builds in std::vector
1520
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
1621

@@ -37,6 +42,17 @@ set(NVPRO_CORE_DIR ${BASE_DIRECTORY}/nvpro_core)
3742
if(MSVC)
3843
add_definitions(/wd26812) # 'enum class' over 'enum'
3944
add_definitions(/wd26451) # Arithmetic overflow, casting 4 byte value to 8 byte value
45+
else()
46+
# Ignore warnings from some third party libraries by including them with -isystem
47+
include_directories(SYSTEM
48+
external/nvpro_core/
49+
external/nvpro_core/imgui/
50+
external/nvpro_core/third_party/stb/
51+
external/nvpro_core/third_party/imgui/
52+
external/nvpro_core/third_party/vma/include/
53+
external/nvpro_core/third_party/tinygltf/
54+
micromesh_toolbox/thirdparty/aftermath_sdk/include/
55+
)
4056
endif()
4157

4258
#--------------------------------------------------------------------------------------------------
@@ -48,6 +64,9 @@ _add_package_ZLIB()
4864
_add_package_VulkanSDK()
4965
_add_package_ShaderC()
5066
_add_package_ImGUI()
67+
if(WIN32)
68+
_add_package_DirectX12()
69+
endif()
5170
_add_nvpro_core_lib()
5271

5372
_add_package_Glm()
@@ -77,31 +96,27 @@ endfunction()
7796

7897
find_first(PATH_BARY_CORE Displacement-MicroMap-BaryFile
7998
${CMAKE_CURRENT_SOURCE_DIR}/external/Displacement-MicroMap-BaryFile
80-
${CMAKE_CURRENT_SOURCE_DIR}/external/bary_core
8199
${CMAKE_CURRENT_SOURCE_DIR}/../bary_core
82100
${CMAKE_CURRENT_SOURCE_DIR}/../sdk/bary_core
83101
)
84102
add_subdirectory(${PATH_BARY_CORE} ${CMAKE_BINARY_DIR}/bary_core)
85103

86104
find_first(PATH_MICROMESH_CORE Displacement-MicroMap-SDK/micromesh_core
87105
${CMAKE_CURRENT_SOURCE_DIR}/external/Displacement-MicroMap-SDK/micromesh_core
88-
${CMAKE_CURRENT_SOURCE_DIR}/external/micromesh_core
89106
${CMAKE_CURRENT_SOURCE_DIR}/../micromesh_core
90107
${CMAKE_CURRENT_SOURCE_DIR}/../sdk/micromesh_core
91108
)
92109
add_subdirectory(${PATH_MICROMESH_CORE} ${CMAKE_BINARY_DIR}/micromesh_core)
93110

94111
find_first(PATH_SDK_COMPRESSION Displacement-MicroMap-SDK/micromesh_displacement_compression
95112
${CMAKE_CURRENT_SOURCE_DIR}/external/Displacement-MicroMap-SDK/micromesh_displacement_compression
96-
${CMAKE_CURRENT_SOURCE_DIR}/external/micromesh_displacement_compression
97113
${CMAKE_CURRENT_SOURCE_DIR}/../micromesh_displacement_compression
98114
${CMAKE_CURRENT_SOURCE_DIR}/../sdk/micromesh_displacement_compression
99115
)
100116
add_subdirectory(${PATH_SDK_COMPRESSION} ${CMAKE_BINARY_DIR}/micromesh_displacement_compression)
101117

102118
find_first(PATH_SDK_REMESHING Displacement-MicroMap-SDK/micromesh_displacement_remeshing
103119
${CMAKE_CURRENT_SOURCE_DIR}/external/Displacement-MicroMap-SDK/micromesh_displacement_remeshing
104-
${CMAKE_CURRENT_SOURCE_DIR}/external/micromesh_displacement_remeshing
105120
${CMAKE_CURRENT_SOURCE_DIR}/../micromesh_displacement_remeshing
106121
${CMAKE_CURRENT_SOURCE_DIR}/../sdk/micromesh_displacement_remeshing
107122
)
@@ -141,8 +156,11 @@ if(WIN32) # Windows
141156
)
142157
else() # Linux
143158
set(MICROMESH_COMPILE_WARNINGS
144-
-Wsign-compare
145-
-Wconversion
159+
-Werror
160+
-Werror=sign-compare
161+
-Werror=conversion
162+
-Werror=format
163+
-Werror=unused
146164
)
147165
endif()
148166

README.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
This toolkit provides libraries, samples and tools to create and view displaced micromeshes.
44
It is a work in progress and feedback is welcome!
55

6+
The latest driver exposing `VK_NV_displacement_micromap` is required to
7+
raytrace micromeshes, such as the *Vulkan Beta Driver* available at
8+
https://developer.nvidia.com/vulkan-driver.
9+
610
We recommend to check the [Micro-Mesh Basics
711
slides](https://developer.download.nvidia.com/ProGraphics/nvpro-samples/slides/Micro-Mesh_Basics.pdf)
812
first as well as the [`dmm_displacement`
@@ -153,8 +157,8 @@ This `meshops` layer is still a bit work in progress as we are migrating additio
153157
### **tools & libraries**
154158

155159
All tools operate on glTF 2.0 files and do support additional micromap specific
156-
glTF extensions from NVIDIA. The spcifications are available at
157-
<https://github.com/NeilBickford-NV/glTF/tree/micro-mesh/extensions/2.0/Vendor>.
160+
glTF extensions from NVIDIA. The specifications are available at
161+
<https://github.com/KhronosGroup/glTF/pull/2273>.
158162

159163
All micromap data is stored as `.bary` files which is a new container / file
160164
format that was specifically designed to allow direct storage of data consumed
@@ -262,6 +266,17 @@ from an original input mesh in the [Micro-Mesh Asset Pipeline
262266
slide-deck](https://developer.download.nvidia.com/ProGraphics/nvpro-samples/slides/Micro-Mesh_Asset_Pipeline.pdf)
263267
as well as in [docs/asset_pipeline.md](docs/asset_pipeline.md)
264268

269+
## About the Latest Release (1.1)
270+
271+
- Heightmap rendering in micromesh_toolkit with dynamic LOD
272+
- Memory estimate for baking high resolution heightmaps in batches
273+
- Micromesh USD schema definitions and libusd API
274+
- meshopsOpApplyBounds() to apply (and discard) direction bounds to positions and directions
275+
- Better glTF instancing/node hierarchy support for baking whole scenes
276+
- Fixes for image filename generation when resampling
277+
- Avoid leaving unused and empty glTF extension references
278+
- Fix matching regular texture names in automation/link_heightmaps.py
279+
265280
## Third-Party Licenses
266281

267282
This project embeds or includes (as submodules) several third-party open-source
@@ -273,4 +288,4 @@ dependency](https://github.com/nvpro-samples/nvpro_core/tree/master/PACKAGE-LICE
273288
## Support Contact
274289

275290
Feel free to file issues directly on the GitHub page or reach out to NVIDIA at
276-
291+

automation/link_heightmaps.py

+27-3
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,37 @@
2929
parser.add_argument('--filter', nargs='+', help='Regex for material names to change')
3030
parser.add_argument('--filter-out', nargs='+', help='Regex for material names to ignore')
3131
parser.add_argument('--copy-from', type=pathlib.Path, help='Source gltf file to use as a template. Takes precedence over the image filename search.')
32+
parser.add_argument('--match-one-image', action='store_true', help='A heightmap will be matched to an image and only added to materials sharing that image. Reduces false positives.')
3233
#parser.add_argument('--heightmaps', nargs='+', type=pathlib.Path, help='Provide heightmap names explicitly in the order of materials')
3334
args = parser.parse_args()
3435

3536
# Return true if the filename could be a heightmap
3637
def heightmapishName(name):
3738
return re.search(r'height|disp', name, re.IGNORECASE)
3839

40+
def find_in_object(obj, target_name, depth):
41+
if target_name in obj:
42+
return obj[target_name]
43+
if depth > 0:
44+
for child in obj.values():
45+
if isinstance(child, dict):
46+
value = find_in_object(child, target_name, depth - 1)
47+
if value is not None:
48+
return value
49+
return None
50+
3951
# Seach objects in the gltf json and return the ID for something referencing the given ID
4052
def find_ids(data, object_name, target_names, target_id):
4153
for id, obj in enumerate(data.get(object_name, [])):
4254
for target_name in target_names:
55+
# Find target_name with depth 1 so baseColorTexture can be found in
56+
# material.pbrMetallicRoughness instead of the material directly.
4357
#if args.verbose: print('Looking for {}=={} in {} {}'.format(target_name, target_id, object_name, id))
44-
if target_name in obj:
45-
if obj[target_name] == target_id:
58+
value = find_in_object(obj, target_name, 1)
59+
if value is not None:
60+
if value == target_id:
4661
yield id
47-
elif isinstance(obj[target_name], dict) and obj[target_name].get('index') == target_id:
62+
elif isinstance(value, dict) and value.get('index') == target_id:
4863
yield id
4964

5065
def heightmapMatchMetric(candidate, image, material_names):
@@ -149,8 +164,16 @@ def filterMaterialName(material_name):
149164
# Assume the most similar heightmap names belong to the same materials as existing images in a greedy fashion
150165
unlinked_heightmaps = []
151166
unlinked_material_ids = set()
167+
best_image = {}
168+
warn_multiple_matches = False
152169
for metric, candidate, image, material_ids in reversed(sorted(matches)):
153170
heightmap = candidate
171+
if heightmap.name in best_image and best_image[heightmap.name] != image:
172+
if args.match_one_image:
173+
continue
174+
elif not warn_multiple_matches:
175+
warn_multiple_matches = True
176+
print("Warning: adding the same heightmap multiple times consider enabling '--match-one-image'", file=sys.stderr)
154177
for material_id in set(material_ids) - unlinked_material_ids:
155178
unlinked_material_ids.add(material_id)
156179

@@ -176,6 +199,7 @@ def filterMaterialName(material_name):
176199
# Add the material to the job list
177200
material_name = data['materials'][material_id]['name']
178201
unlinked_heightmaps += [(material_id, material_name, heightmap, image, sampler_id)]
202+
best_image[heightmap.name] = image
179203

180204
had_changes = False
181205

common/vulkan_nv/vk_nv_micromesh.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030

3131
#include <vulkan/vulkan_core.h>
3232

33+
#ifdef VK_ENABLE_BETA_EXTENSIONS
34+
#include <vulkan/vulkan_beta.h>
35+
#endif
36+
3337
// for name, value in test:gmatch("(VK_[%w_]+) = ([%w_]+),") do print("#define "..name.." ((VkStructureType)"..value..")") end
3438

3539

@@ -330,7 +334,6 @@ extern "C" {
330334
#define VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_TRIANGLES_DISPLACEMENT_MICROMAP_NV ((VkStructureType)1000397002)
331335
#define VK_PIPELINE_CREATE_RAY_TRACING_DISPLACEMENT_MICROMAP_BIT_NV ((VkPipelineCreateFlagBits)0x10000000)
332336
#define VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DISPLACEMENT_MICROMAP_UPDATE_NV ((VkBuildAccelerationStructureFlagBitsKHR)0x00000200)
333-
#define VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DISPLACEMENT_MICROMAP_INSTANCE_NV ((VkBuildAccelerationStructureFlagBitsKHR)0x00000400)
334337
#define VK_MICROMAP_TYPE_DISPLACEMENT_MICROMAP_NV ((VkMicromapTypeEXT)1000397000)
335338

336339
typedef struct VkPhysicalDeviceDisplacementMicromapFeaturesNV {

external/nvpro_core

Submodule nvpro_core updated 85 files

meshops_bake/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ set(PROJECT_NAME "meshops_bake")
55

66
# Sources and headers for the library
77
set(SOURCE_FILES
8+
meshops_bake_batch.hpp
9+
meshops_bake_batch.cpp
810
meshops_bake_vk.hpp
911
meshops_bake_vk.cpp
1012
meshops_bake.cpp

0 commit comments

Comments
 (0)