Skip to content

Commit c42e161

Browse files
authored
Merge branch 'AcademySoftwareFoundation:main' into python_image_loader_fix
2 parents d3a835a + 0c1ed1e commit c42e161

62 files changed

Lines changed: 2166 additions & 371 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.

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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ with these guidelines.
200200
#### Naming Conventions
201201

202202
Class names should use PascalCase, as in `NodeGraph` or `ShaderGenerator`.
203-
Method names should use camelCase starting with a lowercase letter, for
204-
example `getNode` or `setName`. Protected and private member variables should
205-
use an underscore prefix, such as `_name` or `_parent`. Constants should be
206-
written in UPPER_CASE with underscores separating words, as in `EMPTY_STRING`
207-
or `CATEGORY`. Type aliases should append appropriate suffixes to indicate
208-
their purpose, using `Ptr` for pointers, `Vec` for vectors, `Map` for maps,
209-
and `Set` for sets.
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.
210210

211211
#### Static Constants and Class Organization
212212

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

documents/Specification/MaterialX.StandardNodes.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,23 @@ The type of the &lt;image> node determines the number of channels output, which
102102
* `viewdir` (vector3): the view direction determining the value sampled from the projected equiangular map.
103103
* `rotation` (float): the longitudinal sampling offset, in degrees.
104104

105+
<a id="node-hextiledimage"> </a>
106+
107+
* **`hextiledimage`**: samples data from a single image, with provisions for hex-tiling and randomizing the image across uv space.
108+
* `file` (uniform filename): the URI of an image file. The filename can include one or more substitutions to change the file name (including frame number) that is accessed, as described in the [Filename Substitutions](./MaterialX.Specification.md#filename-substitutions) section in the main Specification document.
109+
* `default` (color<em>N</em>): a default value to use if the `file` reference can not be resolved (e.g. if a &lt;geomtoken>, [interfacetoken] or {hostattr} is included in the filename but no substitution value or default is defined, or if the resolved file URI cannot be read). The `default` value must be the same type as the `<hextiledimage>` element itself. If `default` is not defined, the default color value will be 0.0 in all channels.
110+
* `texcoord` (vector2): the name of a vector2-type node specifying the 2D texture coordinate at which the image data is read. Default is to use the current u,v coordinate.
111+
* `tiling` (vector2): the tiling rate for the hexagon tiles along the U and V axes. Default value is (1.0, 1.0).
112+
* `rotation` (float): per-tile rotation randomness in degrees. Default is 0.0.
113+
* `rotationrange` (vector2): [min, max] range in degrees used to randomize rotation for each tile. Default is (0.0, 360.0).
114+
* `scale` (float): per-tile scale randomness multiplier applied to tile size. Default is 1.0.
115+
* `scalerange` (vector2): [min, max] range of scale multipliers used to randomize tile scale. Default is (0.5, 2.0).
116+
* `offset` (float): per-tile translation randomness in UV units. Default is 0.0.
117+
* `offsetrange` (vector2): [min, max] range of offset values in UV units used to randomize tile positions. Default is (0.0, 1.0).
118+
* `falloff` (float): falloff width used to blend neighboring tiles at their edges; larger values produce smoother blends. Default is 0.5.
119+
* `falloffcontrast` (float): contrast applied to the falloff blending to sharpen (values >1) or soften (values <1) transitions. Default is 0.5.
120+
* `lumacoeffs` (uniform color3): the luma coefficients of the current working color space; if no specific color space can be determined, the ACEScg (ap1) luma coefficients [0.2722287, 0.6740818, 0.0536895] will be used. Applications which support color management systems may choose to retrieve the luma coefficients of the working colorspace from the CMS to pass to the &lt;luminance> node's implementation directly, rather than exposing it to the user.
121+
105122
<a id="node-triplanarprojection"> </a>
106123

107124
* **`triplanarprojection`** (NG): samples data from three images (or layers within multi-layer images), and projects a tiled representation of the images along each of the three respective coordinate axes, computing a weighted blend of the three samples using the geometric normal.
@@ -767,6 +784,26 @@ Math nodes have one or two spatially-varying inputs, and are used to perform a m
767784
* `tangent` (vector3): surface tangent vector, defaults to the current world-space tangent vector.
768785
* `bitangent` (vector3): surface bitangent vector, defaults to the current world-space bitangent vector.
769786

787+
<a id="node-hextilednormalmap"> </a>
788+
789+
* **`hextilednormalmap`**: samples data from a single normalmap, with provisions for hex-tiling and randomizing the normalmap across uv space.
790+
* `file` (uniform filename): the URI of an image file. The filename can include one or more substitutions to change the file name (including frame number) that is accessed, as described in the [Filename Substitutions](./MaterialX.Specification.md#filename-substitutions) section in the main Specification document.
791+
* `default` (vector3): a default value to use if the `file` reference can not be resolved (e.g. if a &lt;geomtoken>, [interfacetoken] or {hostattr} is included in the filename but no substitution value or default is defined, or if the resolved file URI cannot be read). Default is (0.5, 0.5, 1.0).
792+
* `texcoord` (vector2): the name of a vector2-type node specifying the 2D texture coordinate at which the image data is read. Default is to use the current u,v coordinate.
793+
* `tiling` (vector2): the tiling rate for the hexagon tiles along the U and V axes. Default value is (1.0, 1.0).
794+
* `rotation` (float): per-tile rotation randomness in degrees. Default is 0.0.
795+
* `rotationrange` (vector2): [min, max] range in degrees used to randomize rotation for each tile. Default is (0.0, 360.0).
796+
* `scale` (float): per-tile scale randomness multiplier applied to tile size. Default is 1.0.
797+
* `scalerange` (vector2): [min, max] range of scale multipliers used to randomize tile scale. Default is (0.5, 2.0).
798+
* `offset` (float): per-tile translation randomness in UV units. Default is 0.0.
799+
* `offsetrange` (vector2): [min, max] range of offset values in UV units used to randomize tile positions. Default is (0.0, 1.0).
800+
* `falloff` (float): falloff width used to blend neighboring tiles at their edges; larger values produce smoother blends. Default is 0.5.
801+
* `strength` (float): Controls how strongly the sampled normal map affects the final normal. A value of 0.0 leaves the surface normal unchanged, 1.0 applies the sampled normal at full strength, and values >1.0 amplify the normal perturbation. Default is 1.0.
802+
* `flip_g` (boolean): If true, negate (flip) the green (G) channel of the sampled normal map to accommodate different tangent-space conventions (handedness). Default is false.
803+
* `normal` (vector3): surface normal; defaults to the current world-space normal.
804+
* `tangent` (vector3): surface tangent vector, defaults to the current world-space tangent vector.
805+
* `bitangent` (vector3): surface bitangent vector, defaults to the current world-space bitangent vector.
806+
770807
<a id="node-creatematrix"> </a>
771808

772809
* **`creatematrix`**: build a 3x3 or 4x4 matrix from three vector3 or four vector3 or vector4 inputs. A matrix44 may also be created from vector3 input values, in which case the fourth value will be set to 0.0 for in1-in3, and to 1.0 for in4 when creating the matrix44.

libraries/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,32 @@ if(MATERIALX_BUILD_DATA_LIBRARY)
2828
add_custom_target(MaterialXBuildData ALL
2929
DEPENDS ${MATERIALX_DATA_LIBRARY_BUILD_FILES})
3030

31+
if (MATERIALX_BUILD_OSOS AND MATERIALX_OSL_BINARY_OSLC)
32+
set(OSO_BUILD_PATH ${CMAKE_CURRENT_BINARY_DIR}/DataLibraryBuild/targets/genoslnetwork/osos)
33+
set(MTLX_BUILD_PATH ${CMAKE_CURRENT_BINARY_DIR}/DataLibraryBuild/targets/genoslnetwork)
34+
35+
set(SENTINEL_FILE ${CMAKE_CURRENT_BINARY_DIR}/buildosos.sentinel)
36+
37+
add_custom_command(
38+
OUTPUT ${SENTINEL_FILE}
39+
COMMAND touch ${SENTINEL_FILE}
40+
COMMAND cmake -E make_directory ${OSO_BUILD_PATH}
41+
COMMAND cmake -E make_directory ${MTLX_BUILD_PATH}
42+
COMMAND MaterialXGenOsl_LibsToOso
43+
--outputOsoPath ${OSO_BUILD_PATH}
44+
--outputMtlxPath ${MTLX_BUILD_PATH}
45+
--oslCompilerPath ${MATERIALX_OSL_BINARY_OSLC}
46+
--oslIncludePath ${MATERIALX_OSL_INCLUDE_PATH}
47+
--libraryRelativeOsoPath libraries/targets/genoslnetwork/osos
48+
--removeNdPrefix true
49+
DEPENDS ${MATERIALX_DATA_LIBRARY_SOURCE_FILES} MaterialXGenOsl_LibsToOso
50+
)
51+
52+
add_custom_target(MaterialXBuild_genoslnetwork_buildOsos ALL DEPENDS ${SENTINEL_FILE})
53+
add_dependencies(MaterialXBuildData MaterialXBuild_genoslnetwork_buildOsos)
54+
55+
endif()
56+
3157
set(DATA_LIBRARY_DIR ${DATA_LIBRARY_BUILD_DIR})
3258
else()
3359
set(DATA_LIBRARY_DIR ${CMAKE_CURRENT_SOURCE_DIR})

libraries/bxdf/genglsl/gltf_pbr.mtlx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@
308308
<input name="in" type="vector3" nodename="rotate_tangent" />
309309
</normalize>
310310
<absval name="abs_anisotropy_rotation" type="float">
311-
<input name="in" type="float" interfacename="anisotropy_rotation"/>
311+
<input name="in" type="float" interfacename="anisotropy_rotation" />
312312
</absval>
313313
<ifgreater name="selected_tangent" type="vector3">
314314
<input name="value1" type="float" nodename="abs_anisotropy_rotation" />

libraries/bxdf/genglsl/open_pbr_surface.mtlx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,21 @@
211211
</multiply>
212212

213213
<!-- Dielectric Base -->
214-
<!-- apply IOR ratio inversion method to avoid TIR artifact (as in Coat TIR section of spec) -->
215-
<divide name="specular_to_coat_ior_ratio" type="float">
216-
<input name="in1" type="float" interfacename="specular_ior" />
217-
<input name="in2" type="float" interfacename="coat_ior" />
218-
</divide>
219-
<divide name="coat_to_specular_ior_ratio" type="float">
220-
<input name="in1" type="float" interfacename="coat_ior" />
221-
<input name="in2" type="float" interfacename="specular_ior" />
222-
</divide>
223-
<ifgreater name="specular_to_coat_ior_ratio_tir_fix" type="float">
224-
<input name="value1" type="float" nodename="specular_to_coat_ior_ratio" />
225-
<input name="value2" type="float" value="1.0" />
226-
<input name="in1" type="float" nodename="specular_to_coat_ior_ratio" />
227-
<input name="in2" type="float" nodename="coat_to_specular_ior_ratio" />
228-
</ifgreater>
214+
<!-- apply IOR ratio inversion method to avoid TIR artifact (as in Coat TIR section of spec) -->
215+
<divide name="specular_to_coat_ior_ratio" type="float">
216+
<input name="in1" type="float" interfacename="specular_ior" />
217+
<input name="in2" type="float" interfacename="coat_ior" />
218+
</divide>
219+
<divide name="coat_to_specular_ior_ratio" type="float">
220+
<input name="in1" type="float" interfacename="coat_ior" />
221+
<input name="in2" type="float" interfacename="specular_ior" />
222+
</divide>
223+
<ifgreater name="specular_to_coat_ior_ratio_tir_fix" type="float">
224+
<input name="value1" type="float" nodename="specular_to_coat_ior_ratio" />
225+
<input name="value2" type="float" value="1.0" />
226+
<input name="in1" type="float" nodename="specular_to_coat_ior_ratio" />
227+
<input name="in2" type="float" nodename="coat_to_specular_ior_ratio" />
228+
</ifgreater>
229229
<mix name="eta_s" type="float">
230230
<input name="fg" type="float" nodename="specular_to_coat_ior_ratio_tir_fix" />
231231
<input name="bg" type="float" interfacename="specular_ior" />
@@ -546,8 +546,7 @@
546546
<!--
547547
OpenPBR Anisotropy node definition
548548
-->
549-
<nodedef name="ND_open_pbr_anisotropy" node="open_pbr_anisotropy" nodegroup="pbr"
550-
doc="Computes anisotropic surface roughness as defined in the OpenPBR specification.">
549+
<nodedef name="ND_open_pbr_anisotropy" node="open_pbr_anisotropy" nodegroup="pbr" doc="Computes anisotropic surface roughness as defined in the OpenPBR specification.">
551550
<input name="roughness" type="float" value="0.0" />
552551
<input name="anisotropy" type="float" value="0.0" />
553552
<output name="out" type="vector2" />

0 commit comments

Comments
 (0)