Skip to content

Commit 887b2e2

Browse files
authored
Merge branch 'AcademySoftwareFoundation:main' into plugin_manager
2 parents 7d0b3ea + 0062647 commit 887b2e2

44 files changed

Lines changed: 1885 additions & 117 deletions

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.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/gltf_pbr.mtlx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<input name="attenuation_color" uniform="true" type="color3" value="1, 1, 1" uimin="0, 0, 0" uimax="1, 1, 1" uiname="Attenuation Color" uifolder="Volume" />
3030
<input name="anisotropy_strength" type="float" value="0" uimin="0" uimax="1" uiname="Anisotropy Strength" uifolder="Anisotropy" />
3131
<input name="anisotropy_rotation" type="float" value="0" uimin="0" uimax="6.283185" uiname="Anisotropy Rotation" uifolder="Anisotropy" />
32+
<input name="dispersion" type="float" value="0" uimin="0" uisoftmax="1.0" uiname="Dispersion" uifolder="Dispersion" />
3233
<output name="out" type="surfaceshader" />
3334
</nodedef>
3435

libraries/bxdf/translation/standard_surface_to_gltf_pbr.mtlx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<input name="transmission" type="float" value="0" />
1515
<input name="transmission_color" type="color3" value="1, 1, 1" />
1616
<input name="transmission_depth" type="float" value="0" />
17+
<input name="transmission_dispersion" type="float" value="0" />
1718
<input name="sheen" type="float" value="0" />
1819
<input name="sheen_color" type="color3" value="1, 1, 1" />
1920
<input name="sheen_roughness" type="float" value="0.3" />
@@ -25,6 +26,7 @@
2526
<input name="normal" type="vector3" defaultgeomprop="Nworld" />
2627
<input name="tangent" type="vector3" defaultgeomprop="Tworld" />
2728
<input name="opacity" type="color3" value="1, 1, 1" />
29+
<input name="thin_walled" type="boolean" value="false" />
2830

2931
<output name="base_color_out" type="color3" />
3032
<output name="metallic_out" type="float" />
@@ -37,10 +39,12 @@
3739
<output name="transmission_out" type="float" />
3840
<output name="thickness_out" type="float" />
3941
<output name="attenuation_color_out" type="color3" />
42+
<output name="attenuation_distance_out" type="float" />
4043
<output name="sheen_color_out" type="color3" />
4144
<output name="sheen_roughness_out" type="float" />
4245
<output name="clearcoat_out" type="float" />
4346
<output name="clearcoat_roughness_out" type="float" />
47+
<output name="dispersion_out" type="float" />
4448
<output name="emissive_out" type="color3" />
4549
<output name="emissive_strength_out" type="float" />
4650
<output name="normal_out" type="vector3" />
@@ -160,7 +164,7 @@
160164
<dot name="transmission" type="float">
161165
<input name="in" type="float" interfacename="transmission" />
162166
</dot>
163-
<dot name="thickness" type="float">
167+
<dot name="attenuation_distance" type="float">
164168
<input name="in" type="float" interfacename="transmission_depth" />
165169
</dot>
166170
<ifgreater name="transmissionAttenuationColor" type="color3">
@@ -176,6 +180,15 @@
176180
<input name="in2" type="color3" value="1, 1, 1" />
177181
</ifgreater>
178182

183+
<convert name="thin_walled_float" type="float">
184+
<input name="in" type="boolean" interfacename="thin_walled" />
185+
</convert>
186+
187+
<subtract name="thickness_from_thin_walled" type="float">
188+
<input name="in1" type="float" value="1" />
189+
<input name="in2" type="float" nodename="thin_walled_float" />
190+
</subtract>
191+
179192
<!-- Sheen -->
180193
<multiply name="sheen_color" type="color3">
181194
<input name="in1" type="color3" interfacename="sheen_color" />
@@ -223,6 +236,19 @@
223236
<input name="in" type="float" interfacename="specular_IOR" />
224237
</dot>
225238

239+
<!-- Dispersion -->
240+
<divide name="dispersion_from_abbe" type="float">
241+
<input name="in1" type="float" value="20.0" />
242+
<input name="in2" type="float" interfacename="transmission_dispersion" />
243+
</divide>
244+
245+
<ifequal name="dispersion" type="float">
246+
<input name="value1" type="float" interfacename="transmission_dispersion" />
247+
<input name="value2" type="float" value="0.0" />
248+
<input name="in1" type="float" value="0.0" />
249+
<input name="in2" type="float" nodename="dispersion_from_abbe" />
250+
</ifequal>
251+
226252
<!-- Geometry -->
227253
<dot name="normal" type="vector3">
228254
<input name="in" type="vector3" interfacename="normal" />
@@ -257,12 +283,14 @@
257283
<output name="anisotropy_strength_out" type="float" nodename="anisotropy_strength" />
258284
<output name="anisotropy_rotation_out" type="float" nodename="anisotropy_rotation" />
259285
<output name="transmission_out" type="float" nodename="transmission" />
260-
<output name="thickness_out" type="float" nodename="thickness" />
286+
<output name="thickness_out" type="float" nodename="thickness_from_thin_walled" />
261287
<output name="attenuation_color_out" type="color3" nodename="attenuation_color" />
288+
<output name="attenuation_distance_out" type="float" nodename="attenuation_distance" />
262289
<output name="sheen_color_out" type="color3" nodename="sheen_color" />
263290
<output name="sheen_roughness_out" type="float" nodename="sqrt_sheen_roughness" />
264291
<output name="clearcoat_out" type="float" nodename="clearcoat" />
265292
<output name="clearcoat_roughness_out" type="float" nodename="clearcoat_roughness" />
293+
<output name="dispersion_out" type="float" nodename="dispersion" />
266294
<output name="emissive_out" type="color3" nodename="emissive" />
267295
<output name="emissive_strength_out" type="float" nodename="emissive_strength" />
268296
<output name="normal_out" type="vector3" nodename="normal" />
File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<materialx version="1.39">
3+
4+
<!--
5+
Copyright Contributors to the MaterialX Project
6+
SPDX-License-Identifier: Apache-2.0
7+
-->
8+
9+
<!-- ======================================================================== -->
10+
<!-- Base target definition for OSL Network targets using shader generation. -->
11+
<!-- ======================================================================== -->
12+
<targetdef name="genoslnetwork" />
13+
14+
</materialx>

resources/Materials/TestSuite/_options.mtlx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<!-- Comma separated list of target" specifiers to indicate which
2323
code generators to use. -->
24-
<input name="targets" type="string" value="genglsl,genosl,genmdl,genessl,genmsl" />
24+
<input name="targets" type="string" value="genglsl,genosl,genoslnetwork,genmdl,genessl,genmsl" />
2525

2626
<!-- Check the count of number of implementations used for a given generator -->
2727
<input name="checkImplCount" type="boolean" value="true" />

source/MaterialXGenGlsl/GlslShaderGenerator.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,6 @@ void GlslShaderGenerator::emitPixelStage(const ShaderGraph& graph, GenContext& c
463463
_tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV] = "mx_transform_uv.glsl";
464464
}
465465

466-
// Emit uv transform code globally if needed.
467-
if (context.getOptions().hwAmbientOcclusion)
468-
{
469-
emitLibraryInclude("stdlib/genglsl/lib/" + _tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV], context, stage);
470-
}
471-
472466
emitLightFunctionDefinitions(graph, context, stage);
473467

474468
// Emit function definitions for all nodes in the graph.

0 commit comments

Comments
 (0)