Skip to content

Commit 388c117

Browse files
authored
Merge branch 'AcademySoftwareFoundation:main' into uri_for_viewer
2 parents be30f6c + 8d792db commit 388c117

69 files changed

Lines changed: 2983 additions & 1355 deletions

File tree

Some content is hidden

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

.github/workflows/main.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
compiler: gcc
3232
compiler_version: "14"
3333
python: 3.13
34+
extended_build_perfetto: ON
3435

3536
- name: Linux_GCC_14_Python314
3637
os: ubuntu-24.04
@@ -174,8 +175,8 @@ jobs:
174175
- name: Install MDL SDK
175176
if: env.IS_EXTENDED_BUILD == 'true' && matrix.extended_build_mdl_sdk == 'ON' && runner.os == 'Windows'
176177
run: |
177-
C:/vcpkg/vcpkg install mdl-sdk --triplet=x64-windows
178-
Add-Content $env:GITHUB_PATH "C:/vcpkg/installed/x64-windows/bin"
178+
C:/vcpkg/vcpkg install mdl-sdk[dds,df-vulkan,openimageio] --triplet=x64-windows-release
179+
Add-Content $env:GITHUB_PATH "C:/vcpkg/installed/x64-windows-release/bin"
179180
180181
- name: Install Python ${{ matrix.python }}
181182
if: matrix.python != 'None'
@@ -198,13 +199,16 @@ jobs:
198199
EXTENDED_BUILD_CONFIG=""
199200
if [ "${{ env.IS_EXTENDED_BUILD }}" == "true" ]; then
200201
if [ "${{ runner.os }}" == "Windows" ]; then
201-
EXTENDED_BUILD_CONFIG="-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows"
202+
EXTENDED_BUILD_CONFIG="-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
202203
fi
203204
if [ "${{ matrix.extended_build_oiio }}" == "ON" ]; then
204-
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DMATERIALX_BUILD_OIIO=ON"
205+
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DVCPKG_TARGET_TRIPLET=x64-windows -DMATERIALX_BUILD_OIIO=ON"
205206
fi
206207
if [ "${{ matrix.extended_build_mdl_sdk }}" == "ON" -a "${{ runner.os }}" == "Windows" ]; then
207-
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DMATERIALX_MDL_SDK_DIR=C:/vcpkg/installed/x64-windows"
208+
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DVCPKG_TARGET_TRIPLET=x64-windows-release -DMATERIALX_MDL_SDK_DIR=C:/vcpkg/installed/x64-windows-release"
209+
fi
210+
if [ "${{ matrix.extended_build_perfetto }}" == "ON" ]; then
211+
EXTENDED_BUILD_CONFIG="$EXTENDED_BUILD_CONFIG -DMATERIALX_BUILD_PERFETTO_TRACING=ON"
208212
fi
209213
fi
210214
TEST_RENDER_CONFIG="-DMATERIALX_TEST_RENDER=OFF"
@@ -228,7 +232,8 @@ jobs:
228232
run: |
229233
python MaterialXTest/main.py
230234
python MaterialXTest/genshader.py
231-
python Scripts/comparenodedefs.py
235+
python Scripts/comparenodedefs.py --spec ../documents/Specification/MaterialX.StandardNodes.md --mtlx ../libraries/stdlib/stdlib_defs.mtlx
236+
python Scripts/comparenodedefs.py --spec ../documents/Specification/MaterialX.PBRSpec.md --mtlx ../libraries/pbrlib/pbrlib_defs.mtlx
232237
python Scripts/creatematerial.py ../resources/Materials/Examples/StandardSurface/chess_set --texturePrefix chessboard --shadingModel standard_surface
233238
python Scripts/creatematerial.py ../resources/Materials/Examples/GltfPbr/boombox --shadingModel gltf_pbr
234239
python Scripts/mxformat.py ../resources/Materials/TestSuite/stdlib/upgrade --yes --upgrade
@@ -265,7 +270,7 @@ jobs:
265270
run: |
266271
sudo apt-get install gcovr
267272
mkdir coverage
268-
gcovr --html --html-details --output coverage/index.html --exclude .*\/External\/.* --root .. .
273+
gcovr --html --html-details --output coverage/index.html --exclude .*\/External\/.* --exclude .*perfetto.* --root .. .
269274
working-directory: build
270275

271276
- name: Static Analysis Tests
@@ -276,7 +281,7 @@ jobs:
276281
else
277282
brew install cppcheck
278283
fi
279-
cppcheck --project=build/compile_commands.json --error-exitcode=1 --suppress=normalCheckLevelMaxBranches --suppress=*:*/External/* --suppress=*:*/NanoGUI/*
284+
cppcheck --project=build/compile_commands.json --error-exitcode=1 --suppress=normalCheckLevelMaxBranches --suppress=*:*/External/* --suppress=*:*/NanoGUI/* --suppress=*:*perfetto*
280285
281286
- name: Setup Rendering Environment (Linux)
282287
if: matrix.test_render == 'ON' && runner.os == 'Linux'
@@ -357,6 +362,14 @@ jobs:
357362
name: MaterialX_Coverage
358363
path: build/coverage
359364

365+
- name: Upload Perfetto Traces
366+
uses: actions/upload-artifact@v4
367+
if: matrix.extended_build_perfetto == 'ON' && env.IS_EXTENDED_BUILD == 'true'
368+
with:
369+
name: Traces_${{ matrix.name }}
370+
path: build/**/*.perfetto-trace
371+
if-no-files-found: ignore
372+
360373
javascript:
361374
name: JavaScript
362375
runs-on: ubuntu-latest
@@ -467,6 +480,10 @@ jobs:
467480
name: MaterialX_Python_SDist
468481
path: sdist
469482

483+
- name: Install Doxygen (Windows)
484+
uses: ssciwr/doxygen-install@v1
485+
if: runner.os == 'Windows'
486+
470487
- name: Build Wheel
471488
uses: pypa/cibuildwheel@v2.23.2
472489
with:
@@ -478,7 +495,6 @@ jobs:
478495
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
479496
CIBW_BEFORE_ALL_LINUX: yum install -y libXt-devel doxygen
480497
CIBW_BEFORE_ALL_MACOS: brew install doxygen
481-
CIBW_BEFORE_ALL_WINDOWS: choco install doxygen.install -y
482498
CIBW_BUILD_VERBOSITY: 1
483499
CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2
484500
MACOSX_DEPLOYMENT_TARGET: '11.0'

CMakeLists.txt

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ option(MATERIALX_BUILD_OCIO "Build OpenColorIO support for shader generators." O
5151
option(MATERIALX_BUILD_TESTS "Build unit tests." OFF)
5252
option(MATERIALX_BUILD_BENCHMARK_TESTS "Build benchmark tests." OFF)
5353
option(MATERIALX_BUILD_OSOS "Build OSL .oso's of standard library shaders for the OSL Network generator" OFF)
54+
option(MATERIALX_BUILD_PERFETTO_TRACING "Build with Perfetto tracing support for performance analysis." OFF)
5455

5556
option(MATERIALX_BUILD_SHARED_LIBS "Build MaterialX libraries as shared rather than static." OFF)
5657
option(MATERIALX_BUILD_DATA_LIBRARY "Build generated products from the MaterialX data library." OFF)
@@ -224,9 +225,45 @@ mark_as_advanced(MATERIALX_EMSDK_PATH)
224225
mark_as_advanced(MATERIALX_BUILD_IOS)
225226
mark_as_advanced(MATERIALX_BUILD_APPLE_FRAMEWORK)
226227
mark_as_advanced(MATERIALX_MDL_BINARY_MDLC)
228+
mark_as_advanced(MATERIALX_MDL_BINARY_TESTRENDER)
227229
mark_as_advanced(MATERIALX_MDL_MODULE_PATHS)
228230
mark_as_advanced(MATERIALX_MDL_SDK_DIR)
229231
mark_as_advanced(MATERIALX_SLANG_RHI_SOURCE_DIR)
232+
mark_as_advanced(MATERIALX_BUILD_PERFETTO_TRACING)
233+
234+
# Perfetto tracing support
235+
if(MATERIALX_BUILD_PERFETTO_TRACING)
236+
include(FetchContent)
237+
FetchContent_Declare(
238+
perfetto
239+
GIT_REPOSITORY https://android.googlesource.com/platform/external/perfetto
240+
GIT_TAG v43.0
241+
GIT_SHALLOW TRUE
242+
)
243+
# Only fetch the SDK, not the full Perfetto source
244+
set(PERFETTO_SDK_INCLUDE_DIR "${CMAKE_BINARY_DIR}/_deps/perfetto-src/sdk")
245+
FetchContent_MakeAvailable(perfetto)
246+
add_definitions(-DMATERIALX_BUILD_PERFETTO_TRACING)
247+
248+
# Define compile flags for perfetto.cc (Perfetto SDK triggers various warnings)
249+
# These variables are used in source/CMakeLists.txt (monolithic) and MaterialXTrace (non-monolithic)
250+
# Note: set_source_files_properties is directory-scoped, so we define variables here
251+
# but apply them in the directories where targets are created.
252+
if(MSVC)
253+
set(MATERIALX_PERFETTO_COMPILE_DEFINITIONS "NOMINMAX;WIN32_LEAN_AND_MEAN" CACHE INTERNAL "")
254+
# /bigobj: perfetto.cc has too many sections for default MSVC object format
255+
# /W0: disable all warnings for third-party Perfetto SDK code
256+
# /WX-: disable warnings-as-errors (overrides project-level /WX)
257+
set(MATERIALX_PERFETTO_COMPILE_FLAGS "/bigobj /W0 /WX-" CACHE INTERNAL "")
258+
else()
259+
set(MATERIALX_PERFETTO_COMPILE_DEFINITIONS "" CACHE INTERNAL "")
260+
# -Wno-error: Don't treat warnings as errors (Perfetto has shadowing issues)
261+
# -Wno-shadow: Suppress shadow warnings (kDevNull shadows global)
262+
set(MATERIALX_PERFETTO_COMPILE_FLAGS "-Wno-error -Wno-shadow" CACHE INTERNAL "")
263+
endif()
264+
265+
message(STATUS "Perfetto tracing support enabled")
266+
endif()
230267

231268
if (MATERIALX_BUILD_USE_CCACHE)
232269
# Setup CCache for C/C++ compilation
@@ -264,11 +301,23 @@ if (MATERIALX_BUILD_BENCHMARK_TESTS)
264301
add_definitions(-DMATERIALX_BUILD_BENCHMARK_TESTS)
265302
endif()
266303

267-
# GEN MDL does not have any additional dependencies. For loading and compiling MDL, e.g., in the test renderer, the MDL SDK is needed.
304+
# MaterialXGenMdl does not have any additional dependencies.
305+
# MaterialXTest/MaterialXGenMdl performs a syntax check if the mdlc binary is available.
306+
# MaterialXTest/MaterialXRenderMdl needs the df_vulkan example, SDK library, and image plugins.
268307
if(MATERIALX_MDL_SDK_DIR)
269308
find_package(mdl QUIET CONFIG REQUIRED PATHS ${MATERIALX_MDL_SDK_DIR})
270309
get_target_property(MATERIALX_MDL_BINARY_MDLC mdl::mdlc LOCATION)
271310
set(MATERIALX_MDL_BINARY_MDLC ${MATERIALX_MDL_BINARY_MDLC} CACHE FILEPATH "Full path to the mdlc binary." FORCE)
311+
if((${mdl_VERSION} VERSION_GREATER_EQUAL "2025.0.3") OR (${mdl_VERSION} STREQUAL "trunk"))
312+
find_program(MATERIALX_MDL_BINARY_TESTRENDER
313+
NAMES df_vulkan
314+
HINTS
315+
${MATERIALX_MDL_SDK_DIR}/examples/mdl_sdk/df_vulkan # regular install layout
316+
${MATERIALX_MDL_SDK_DIR}/tools/mdl-sdk) # vcpkg layout
317+
else()
318+
message(WARNING "The MDL df_vulkan test renderer requires an MDL SDK >= 2025.0.3 (found ${mdl_VERSION}).")
319+
set(MATERIALX_MDL_BINARY_TESTRENDER "" CACHE FILEPATH "Full path to the MDL df_vulkan test renderer.")
320+
endif()
272321
endif()
273322

274323
# Adjust the default installation path
@@ -478,6 +527,9 @@ endif()
478527
# Add core subdirectories
479528
add_subdirectory(source/MaterialXCore)
480529
add_subdirectory(source/MaterialXFormat)
530+
if(MATERIALX_BUILD_PERFETTO_TRACING)
531+
add_subdirectory(source/MaterialXTrace)
532+
endif()
481533

482534
# Add shader generation subdirectories
483535
add_subdirectory(source/MaterialXGenShader)

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ be cheap to copy. When returning shared pointers, they should be returned by
242242
value rather than by reference. Methods should be marked as `const` whenever
243243
they do not modify the object's state.
244244

245+
#### Thread Safety
246+
247+
MaterialX classes support multiple concurrent readers, but not concurrent
248+
reads and writes, following the pattern of standard C++ containers. This
249+
design enables efficient parallel processing in read-heavy workloads such
250+
as shader generation and scene traversal, while keeping the implementation
251+
simple and avoiding the overhead of fine-grained locking.
252+
245253
#### Exception Handling
246254

247255
Exceptions should be used for exceptional conditions rather than for normal

GOVERNANCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ The current Voting Members of the MaterialX TSC are:
4848
- Doug Smythe - Industrial Light & Magic
4949
- Niklas Harrysson - Lumiere Software
5050
- Orn Gunnarsson - Autodesk
51+
- Lee Kerley - Apple
52+
- Frankie Liu - NVIDIA
5153
- Andréa Machizaud - Adobe
5254

5355
### Stakeholders
@@ -66,8 +68,6 @@ The current Stakeholders of the MaterialX TSC are:
6668
- Fran González García - Pixar RenderMan
6769
- Ole Gulbrandsen - Sony Pictures Imageworks
6870
- Rafal Jaroszkiewicz - SideFX
69-
- Lee Kerley - Apple
70-
- Lutz Kettner - NVIDIA
7171
- Chris Kulla - Epic Games
7272
- Bernard Kwok - Khronos Group
7373
- Karen Lucknavalai - Pixar USD

cmake/modules/MaterialXConfig.cmake.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ if(@MATERIALX_BUILD_RENDER@ AND @MATERIALX_INSTALL_RESOURCES@)
3939
set_and_check(MATERIALX_RESOURCES_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/resources")
4040
endif()
4141

42+
if(UNIX AND NOT APPLE)
43+
find_dependency(X11 REQUIRED COMPONENTS Xt)
44+
if("RenderGlsl" IN_LIST MaterialX_FIND_COMPONENTS)
45+
find_dependency(OpenGL REQUIRED)
46+
set(MaterialX_RenderGlsl_FOUND TRUE)
47+
endif()
48+
endif()
49+
4250
check_required_components(@CMAKE_PROJECT_NAME@)
4351

4452
@EXPORT_ALIASES@

documents/Specification/MaterialX.NPRSpec.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,55 @@ This document describes a number of MaterialX nodes primarily applicable to non-
3636

3737
<a id="node-viewdirection"> </a>
3838

39-
* **`viewdirection`**: the current scene view direction (e.g. from the viewing/camera position to the current shading position). If `viewdirection` is used in a PBR shading context, it should be noted that this would be the same as the incident ray direction for primary ("camera") rays but **not** for secondary/reflection rays. This node must be of type vector3.
39+
### `viewdirection`
40+
The current scene view direction, as defined by the shading environment.
4041

41-
* `space` (uniform string): the space in which to return the view vector direction, defaults to `world`.
42+
The view direction is a normalized vector from the viewer position to the current shading position. In a PBR shading context, it represents the incident direction for primary camera rays, independent of any secondary or reflection rays.
43+
44+
|Port |Description |Type |Default|Accepted Values |
45+
|-------|--------------------------------------|-------|-------|--------------------|
46+
|`space`|The space of the view direction vector|string |world |model, object, world|
47+
|`out` |Output: view direction |vector3| | |
4248

4349

4450

4551
## NPR Utility Nodes
4652

4753
<a id="node-facingratio"> </a>
4854

49-
* **`facingratio`**: returns the geometric facing ratio, computed as the dot product between the view direction and geometric normal. Output is a float between 0.0 and 1.0.
55+
### `facingratio`
56+
The geometric facing ratio of the view direction and surface normal.
57+
58+
Facing ratio is computed as the dot product between the view direction and surface normal.
59+
60+
|Port |Description |Type |Default |
61+
|---------------|--------------------------------------------------------------------------|-------|--------|
62+
|`viewdirection`|The input view direction vector |vector3|_Vworld_|
63+
|`normal` |The input surface normal vector |vector3|_Nworld_|
64+
|`faceforward` |Makes the output always positive, facing towards the view direction |boolean|true |
65+
|`invert` |Inverts the output values by multiplying them by -1 |boolean|false |
66+
|`out` |Output: the float representing the ratio between view direction and normal|float | |
5067

51-
* `viewdirection` (vector3): the viewing direction, defaults to the value of the "Vworld" (world space view direction) geometric property.
52-
* `normal` (vector3): the surface normal vector, defaults to the value of the "Nworld" (world space view direction) geometric property. This vector is expected to be prenormalized to length 1.0.
53-
* `faceforward` (boolean): description needed; default is false.
54-
* `invert` (boolean): description needed; default is false.
5568

5669

5770

5871
## NPR Shading Nodes
5972

6073
<a id="node-gooch-shade"> </a>
6174

62-
* **`gooch_shade`**: Computes the single-pass shading portion of the Gooch[^Gooch1998] lighting model. Output type `surfaceshader`.
63-
* `warm_color` (color3): the "warm" color for shading, defaults to (0.8, 0.8, 0.7) in the `lin_rec709` colorspace.
64-
* `cool_color` (color3): the "cool" color for shading, defaults to (0.3, 0.3, 0.8) in the `lin_rec709` colorspace.
65-
* `specular_intensity` (float): the intensity of the specular component. Defaults to 1.0.
66-
* `shininess` (float): the specular power typically ranging from 1 to 256, defaults to 64.
67-
* `light_direction` (vector3): the incoming predominant lighting direction in world space, defaults to (1.0, -0.5, -0.5).
75+
### `gooch_shade`
76+
Computes the color from single-pass shading portion of the Gooch[^Gooch1998] lighting model.
77+
78+
Gooch shade provides an illustrative shading effect by blending colors based on the angle between the surface normal and the light direction. It also provides a simple Phong specular highlight, on top of the warm and cool colors.
79+
80+
|Port |Description |Type |Default |
81+
|--------------------|---------------------------------------|-------|-------------|
82+
|`warm_color` |The color facing toward the light |color3 |0.8, 0.8, 0.7|
83+
|`cool_color` |The color facing away from the light |color3 |0.3, 0.3, 0.8|
84+
|`specular_intensity`|The intensity of the highlight |float |1 |
85+
|`shininess` |The size of the highlight |float |64 |
86+
|`light_direction` |The world-space direction of the light |vector3|1, -0.5, -0.5|
87+
|`out` |Output: the Gooch lighting model result|color3 | |
6888

6989
<br>
7090

0 commit comments

Comments
 (0)