Skip to content

Commit de2cc6a

Browse files
authored
Merge branch 'AcademySoftwareFoundation:main' into node_editor_traversal
2 parents 674da45 + 0062647 commit de2cc6a

86 files changed

Lines changed: 2303 additions & 212 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: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ on:
77
pull_request:
88
paths-ignore:
99
- '**.md'
10+
schedule:
11+
# Nightly build
12+
- cron: '30 10 * * *'
1013
workflow_dispatch:
1114

1215
jobs:
1316

1417
build:
1518
name: Build
1619
runs-on: ${{ matrix.os }}
20+
env:
21+
IS_EXTENDED_BUILD: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
1722
strategy:
1823
fail-fast: false
1924
matrix:
@@ -109,6 +114,7 @@ jobs:
109114
python: 3.13
110115
cmake_config: -G "Visual Studio 17 2022" -A "x64"
111116
test_shaders: ON
117+
extended_build_oiio: ON
112118

113119
- name: Windows_VS2022_x64_SharedLibs
114120
os: windows-2025
@@ -156,11 +162,10 @@ jobs:
156162
Add-Content $env:GITHUB_PATH "$PWD/build/installed/bin"
157163
158164
- name: Install OpenImageIO
159-
if: matrix.build_oiio == 'ON' && runner.os == 'Windows'
165+
if: env.IS_EXTENDED_BUILD == 'true' && matrix.extended_build_oiio == 'ON' && runner.os == 'Windows'
160166
run: |
161-
C:/vcpkg/vcpkg install openimageio --triplet=x64-windows-release
162-
Add-Content $env:GITHUB_PATH "C:/vcpkg/installed/x64-windows-release/bin"
163-
Add-Content $env:GITHUB_PATH "C:/vcpkg/installed/x64-windows-release/share/openimageio"
167+
C:/vcpkg/vcpkg install openimageio --triplet=x64-windows
168+
Add-Content $env:GITHUB_PATH "C:/vcpkg/installed/x64-windows/bin"
164169
165170
- name: Install Python ${{ matrix.python }}
166171
if: matrix.python != 'None'
@@ -178,7 +183,12 @@ jobs:
178183
run: find source \( -name *.h -o -name *.cpp -o -name *.mm -o -name *.inl \) ! -path "*/External/*" ! -path "*/NanoGUI/*" | xargs clang-format -i --verbose
179184

180185
- name: CMake Generate
181-
run: cmake -S . -B build -DMATERIALX_BUILD_PYTHON=ON -DMATERIALX_BUILD_VIEWER=ON -DMATERIALX_BUILD_GRAPH_EDITOR=ON -DMATERIALX_BUILD_TESTS=ON -DMATERIALX_TEST_RENDER=OFF -DMATERIALX_WARNINGS_AS_ERRORS=ON ${{matrix.cmake_config}}
186+
shell: bash
187+
run: |
188+
if [ "${{ env.IS_EXTENDED_BUILD }}" == "true" ] && [ "${{ matrix.extended_build_oiio }}" == "ON" ]; then
189+
EXTENDED_BUILD_CONFIG="-DMATERIALX_BUILD_OIIO=ON -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows"
190+
fi
191+
cmake -S . -B build -DMATERIALX_BUILD_PYTHON=ON -DMATERIALX_BUILD_VIEWER=ON -DMATERIALX_BUILD_GRAPH_EDITOR=ON -DMATERIALX_BUILD_TESTS=ON -DMATERIALX_TEST_RENDER=OFF -DMATERIALX_WARNINGS_AS_ERRORS=ON $EXTENDED_BUILD_CONFIG ${{matrix.cmake_config}}
182192
183193
- name: CMake Build
184194
run: cmake --build build --target install --config Release --parallel 2

CMakeLists.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ option(MATERIALX_BUILD_GRAPH_EDITOR "Build the MaterialX Graph Editor." OFF)
3939
option(MATERIALX_BUILD_DOCS "Create HTML documentation using Doxygen. Requires that Doxygen be installed." OFF)
4040

4141
option(MATERIALX_BUILD_GEN_GLSL "Build the GLSL shader generator back-end." ON)
42-
option(MATERIALX_BUILD_GEN_OSL "Build the OSL shader generator back-end." ON)
42+
option(MATERIALX_BUILD_GEN_OSL "Build the OSL shader generator back-ends." ON)
4343
option(MATERIALX_BUILD_GEN_MDL "Build the MDL shader generator back-end." ON)
4444
option(MATERIALX_BUILD_GEN_MSL "Build the MSL shader generator back-end." ON)
4545
option(MATERIALX_BUILD_RENDER "Build the MaterialX Render modules." ON)
@@ -48,6 +48,7 @@ option(MATERIALX_BUILD_OIIO "Build OpenImageIO support for MaterialXRender." OFF
4848
option(MATERIALX_BUILD_OCIO "Build OpenColorIO support for shader generators." OFF)
4949
option(MATERIALX_BUILD_TESTS "Build unit tests." OFF)
5050
option(MATERIALX_BUILD_BENCHMARK_TESTS "Build benchmark tests." OFF)
51+
option(MATERIALX_BUILD_OSOS "Build OSL .oso's of standard library shaders for the OSL Network generator" OFF)
5152

5253
option(MATERIALX_BUILD_SHARED_LIBS "Build MaterialX libraries as shared rather than static." OFF)
5354
option(MATERIALX_BUILD_DATA_LIBRARY "Build generated products from the MaterialX data library." OFF)
@@ -85,6 +86,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "iOS" OR CMAKE_SYSTEM_NAME MATCHES "tvOS" OR CMAKE
8586
set(MATERIALX_BUILD_GEN_GLSL OFF)
8687
set(MATERIALX_BUILD_GEN_OSL OFF)
8788
set(MATERIALX_BUILD_GEN_MDL OFF)
89+
set(MATERIALX_BUILD_OSOS OFF)
8890
set(MATERIALX_BUILD_TESTS OFF)
8991
endif()
9092

@@ -103,6 +105,7 @@ if (MATERIALX_BUILD_APPLE_FRAMEWORK)
103105
endif()
104106

105107
if (MATERIALX_BUILD_JS)
108+
set(MATERIALX_BUILD_OSOS OFF)
106109
set(MATERIALX_BUILD_RENDER OFF)
107110
set(MATERIALX_BUILD_TESTS OFF)
108111
endif()
@@ -136,6 +139,13 @@ if(SKBUILD)
136139
set(MATERIALX_PYTHON_FOLDER_NAME "MaterialX")
137140
endif()
138141

142+
if (MATERIALX_BUILD_OSOS)
143+
set(MATERIALX_BUILD_DATA_LIBRARY ON)
144+
set(MATERIALX_BUILD_GEN_OSL ON)
145+
set(MATERIALX_BUILD_RENDER ON)
146+
set(MATERIALX_BUILD_RENDER_PLATFORMS ON)
147+
endif()
148+
139149
# Helpers for MDL validation
140150
if (MATERIALX_BUILD_GEN_MDL)
141151
set(MATERIALX_MDLC_EXECUTABLE "" CACHE FILEPATH "Full path to the mdlc binary.")
@@ -164,6 +174,7 @@ mark_as_advanced(MATERIALX_BUILD_GEN_GLSL)
164174
mark_as_advanced(MATERIALX_BUILD_GEN_OSL)
165175
mark_as_advanced(MATERIALX_BUILD_GEN_MDL)
166176
mark_as_advanced(MATERIALX_BUILD_GEN_MSL)
177+
mark_as_advanced(MATERIALX_BUILD_OSOS)
167178
mark_as_advanced(MATERIALX_BUILD_RENDER)
168179
mark_as_advanced(MATERIALX_BUILD_RENDER_PLATFORMS)
169180
mark_as_advanced(MATERIALX_BUILD_OIIO)
@@ -215,7 +226,7 @@ endif()
215226

216227
# Allow the OSL CMake package to provide binary locations for render tests.
217228
# This will not override explicitly provided oslc, testrender, and include paths.
218-
if(MATERIALX_BUILD_RENDER AND MATERIALX_BUILD_GEN_OSL AND MATERIALX_BUILD_TESTS)
229+
if((MATERIALX_BUILD_RENDER AND MATERIALX_BUILD_GEN_OSL AND MATERIALX_BUILD_TESTS) OR MATERIALX_BUILD_OSOS)
219230
find_package(OSL QUIET)
220231
if(OSL_FOUND)
221232
if(NOT MATERIALX_OSL_BINARY_OSLC)
@@ -225,6 +236,10 @@ if(MATERIALX_BUILD_RENDER AND MATERIALX_BUILD_GEN_OSL AND MATERIALX_BUILD_TESTS)
225236
# OSL does not yet export a CMake target for testrender.
226237
set(MATERIALX_OSL_BINARY_TESTRENDER $<TARGET_FILE_DIR:OSL::oslc>/testrender)
227238
endif()
239+
if(NOT MATERIALX_OSL_INCLUDE_PATH)
240+
# OSL does not yet export a CMake target for testrender.
241+
set(MATERIALX_OSL_INCLUDE_PATH $<TARGET_FILE_DIR:OSL::oslc>/../include)
242+
endif()
228243
endif()
229244
endif()
230245

@@ -467,6 +482,9 @@ if(MATERIALX_BUILD_GEN_GLSL OR MATERIALX_BUILD_GEN_OSL OR MATERIALX_BUILD_GEN_MD
467482
add_definitions(-DMATERIALX_BUILD_GEN_OSL)
468483
add_subdirectory(source/MaterialXGenOsl)
469484
endif()
485+
if (MATERIALX_BUILD_OSOS)
486+
add_definitions(-DMATERIALX_BUILD_OSOS)
487+
endif()
470488
if (MATERIALX_BUILD_GEN_MDL)
471489
add_definitions(-DMATERIALX_BUILD_GEN_MDL)
472490
add_subdirectory(source/MaterialXGenMdl)

CONTRIBUTING.md

Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,96 @@ in the ASWF Slack or in TSC meetings before any PR is submitted, in order to
189189
solicit feedback, build consensus, and alert all stakeholders to be on the
190190
lookout for the eventual PR when it appears.
191191

192-
### Coding Conventions
192+
### Developer Guidelines
193+
194+
The following guidelines represent coding standards that we strive to follow
195+
in the MaterialX project. While not all existing code may adhere to these
196+
standards yet, we encourage all new contributions to follow these practices,
197+
and we welcome incremental improvements to bring existing code into alignment
198+
with these guidelines.
199+
200+
#### Naming Conventions
201+
202+
Class names should use PascalCase, as in `NodeGraph` or `ShaderGenerator`.
203+
Variable and function names should use camelCase starting with a lowercase
204+
letter, as in `childName` or `getNode`. Protected and private member variables
205+
additionally require an underscore prefix, as in `_parent` or `_childMap`.
206+
Constants should be written in UPPER_CASE with underscores separating words,
207+
as in `EMPTY_STRING` or `CATEGORY`. Type aliases should append appropriate
208+
suffixes to indicate their purpose, using `Ptr` for pointers, `Vec` for
209+
vectors, `Map` for maps, and `Set` for sets.
210+
211+
#### Static Constants and Class Organization
212+
213+
Class members should be organized in order of decreasing visibility: public,
214+
protected, then private. Static constants should be placed at the end of their
215+
respective visibility section. String constants should be defined in implementation
216+
files rather than headers to avoid One Definition Rule violations. The
217+
`EMPTY_STRING` constant should be used instead of empty string literals (`""`)
218+
for clarity and consistency.
219+
220+
#### Smart Pointer Conventions
221+
222+
Heap-allocated objects in the public API should always use `shared_ptr` for
223+
memory management. Type aliases should be defined for all shared pointers,
224+
following the pattern of `ElementPtr` for `shared_ptr<Element>`. Both mutable
225+
and const versions of these type aliases should be provided, e.g. `ElementPtr`
226+
and `ConstElementPtr`. Raw pointers should be avoided except when representing
227+
non-owning references within implementation details.
228+
229+
#### Const Correctness
230+
231+
Methods that do not modify an object's state should be marked as `const`.
232+
Accessor methods should provide const versions to enable their use on const
233+
objects. Type aliases following the pattern `ConstElementPtr` should be used to
234+
indicate read-only access through shared pointers. Parameters that should not
235+
be modified within a function should be declared as const.
236+
237+
#### Parameter Passing and Return Values
238+
239+
Strings and complex objects should be passed by `const&` to avoid unnecessary
240+
copies. Shared pointers should be passed by value since they are designed to
241+
be cheap to copy. When returning shared pointers, they should be returned by
242+
value rather than by reference. Methods should be marked as `const` whenever
243+
they do not modify the object's state.
244+
245+
#### Exception Handling
246+
247+
Exceptions should be used for exceptional conditions rather than for normal
248+
control flow. Custom exception types should be defined by inheriting from
249+
`Exception` to represent specific error categories. Exception messages should
250+
be descriptive and include relevant context to aid in debugging. All exceptions
251+
that may be thrown by a method should be documented using the `@throws` tag in
252+
the method's documentation. When catching exceptions, specific exception types
253+
should be caught rather than generic exceptions whenever possible.
254+
255+
#### Header Includes
256+
257+
Header includes should be written with angle brackets, with paths relative to
258+
the root source folder (e.g. `#include <MaterialXCore/Element.h>`). This
259+
ensures consistent include paths across the entire codebase, regardless of the
260+
location of the referencing file.
261+
262+
Each implementation file should include its corresponding header file first,
263+
so the first include in `Element.cpp` should be `Element.h`. This ensures that
264+
the header file is self-contained and doesn't accidentally depend on includes
265+
from other headers.
266+
267+
After the corresponding header, include blocks should be ordered hierarchically,
268+
with high-level modules listed before low-level modules (e.g.
269+
`MaterialXGenShader`, followed by `MaterialXFormat`, followed by
270+
`MaterialXCore`). This maximizes opportunities to catch missing dependencies in
271+
the high-level modules, which might otherwise be hidden at build time. Within
272+
include blocks, individual includes should be ordered alphabetically, providing
273+
a simple canonical order that is straightforward for developers to check.
274+
275+
In the interest of avoiding include cycles, developers are free to leverage
276+
forward declarations of classes that are trivially referenced within another
277+
header. In the interest of clarity and efficiency, developers are free to
278+
leverage transitive header includes, where low-level headers that have already
279+
been included by a high-level header do not need to be restated individually.
280+
281+
#### Coding Style
193282

194283
The coding style of the MaterialX project is defined by a
195284
[clang-format](.clang-format) file in the repository, which is supported by
@@ -200,7 +289,18 @@ file to automatically align the code to MaterialX conventions. When modifying
200289
existing code, follow the surrounding formatting conventions so that new or
201290
modified code blends in with the current code.
202291

203-
### Unit Tests
292+
#### Documentation Standards
293+
294+
All classes and methods in the public API should be documented with Doxygen
295+
comments. Classes should be documented with the `@class` tag, and structs with
296+
the `@struct` tag, followed by a brief description and any detailed
297+
documentation. Method documentation should include `@param`, `@return`, and
298+
`@throws` tags where applicable. Related methods should be grouped together
299+
using `/// @name GroupName` sections to improve readability. File-level
300+
documentation should be placed immediately after the copyright header using
301+
the `/// @file` directive.
302+
303+
#### Unit Tests
204304

205305
Each MaterialX module has a companion folder within the
206306
[MaterialXTest](source/MaterialXTest) module, containing a set of unit tests

documents/Specification/MaterialX.Specification.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Because the same word can be used to mean slightly different things in different
9999

100100
An **Element** is a named object within a MaterialX document, which may possess any number of child elements and attributes. An **Attribute** is a named property of a MaterialX element.
101101

102-
A **Node** is a function that generates or operates upon spatially-varying data. This specification provides a set of standard nodes with precise definitions, and also supports the creation of custom nodes for application-specific uses. The interface for a node’s incoming data is declared through **Inputs**, which may be spatially-varying or uniform, and **Tokens**, which are string values that can be substituted into filenames declared in node inputs.
102+
A **Node** is a function that generates or operates upon spatially-varying data. This specification provides a set of standard nodes with precise definitions, and also supports the creation of custom nodes for application-specific uses. The interface for a node’s incoming data is declared through **Inputs**, which may be spatially-varying or uniform, and **Tokens**, which are string values that can be substituted into filenames declared in node inputs. The interface for a node's outgoing data is declared through one or more **Outputs**; a node's Inputs, Tokens and Outputs are collectively referred to as the node's **Ports**.
103103

104104
A **Pattern** is a node that generates or processes simple scalar, vector, and color data, and has access to local properties of any geometry that has been bound.
105105

@@ -937,7 +937,7 @@ Specific applications will commonly support sources and operators that do not ma
937937

938938
### Custom Node Declaration NodeDef Elements
939939

940-
Each custom node must be explicitly declared with a &lt;nodedef> element, with child &lt;input>, &lt;token> and &lt;output> elements specifying the expected names and types of the node’s inputs and output(s).
940+
Each custom node must be explicitly declared with a &lt;nodedef> element, with child &lt;input>, &lt;token> and &lt;output> elements specifying the expected names and types of the node’s ports.
941941

942942
Attributes for &lt;nodedef> elements:
943943

0 commit comments

Comments
 (0)