diff --git a/Sources/MXResources/Resources/CMakeLists.txt b/Sources/MXResources/Resources/CMakeLists.txt
new file mode 100644
index 00000000..10212c95
--- /dev/null
+++ b/Sources/MXResources/Resources/CMakeLists.txt
@@ -0,0 +1,4 @@
+if(NOT SKBUILD)
+ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
+ DESTINATION "resources" MESSAGE_NEVER)
+endif()
diff --git a/Sources/MXResources/Resources/Lights/envmap_shader.mtlx b/Sources/MXResources/Resources/Lights/environment_map.mtlx
similarity index 67%
rename from Sources/MXResources/Resources/Lights/envmap_shader.mtlx
rename to Sources/MXResources/Resources/Lights/environment_map.mtlx
index 8c9c6ec0..8aef3c11 100644
--- a/Sources/MXResources/Resources/Lights/envmap_shader.mtlx
+++ b/Sources/MXResources/Resources/Lights/environment_map.mtlx
@@ -1,17 +1,10 @@
-
+
-
-
-
-
-
-
-
-
+
-
+
@@ -46,14 +39,19 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
-
+
diff --git a/Sources/MXResources/Resources/Lights/irradiance/irr_goegap.hdr b/Sources/MXResources/Resources/Lights/irradiance/goegap.hdr
similarity index 100%
rename from Sources/MXResources/Resources/Lights/irradiance/irr_goegap.hdr
rename to Sources/MXResources/Resources/Lights/irradiance/goegap.hdr
diff --git a/Sources/MXResources/Resources/Lights/irradiance/irr_goegap_split.hdr b/Sources/MXResources/Resources/Lights/irradiance/goegap_split.hdr
similarity index 100%
rename from Sources/MXResources/Resources/Lights/irradiance/irr_goegap_split.hdr
rename to Sources/MXResources/Resources/Lights/irradiance/goegap_split.hdr
diff --git a/Sources/MXResources/Resources/Lights/irradiance/irr_san_giuseppe_bridge.hdr b/Sources/MXResources/Resources/Lights/irradiance/san_giuseppe_bridge.hdr
similarity index 100%
rename from Sources/MXResources/Resources/Lights/irradiance/irr_san_giuseppe_bridge.hdr
rename to Sources/MXResources/Resources/Lights/irradiance/san_giuseppe_bridge.hdr
diff --git a/Sources/MXResources/Resources/Lights/irradiance/irr_san_giuseppe_bridge_split.hdr b/Sources/MXResources/Resources/Lights/irradiance/san_giuseppe_bridge_split.hdr
similarity index 100%
rename from Sources/MXResources/Resources/Lights/irradiance/irr_san_giuseppe_bridge_split.hdr
rename to Sources/MXResources/Resources/Lights/irradiance/san_giuseppe_bridge_split.hdr
diff --git a/Sources/MXResources/Resources/Lights/irradiance/irr_table_mountain.hdr b/Sources/MXResources/Resources/Lights/irradiance/table_mountain.hdr
similarity index 100%
rename from Sources/MXResources/Resources/Lights/irradiance/irr_table_mountain.hdr
rename to Sources/MXResources/Resources/Lights/irradiance/table_mountain.hdr
diff --git a/Sources/MXResources/Resources/Lights/irradiance/irr_table_mountain_split.hdr b/Sources/MXResources/Resources/Lights/irradiance/table_mountain_split.hdr
similarity index 100%
rename from Sources/MXResources/Resources/Lights/irradiance/irr_table_mountain_split.hdr
rename to Sources/MXResources/Resources/Lights/irradiance/table_mountain_split.hdr
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/READMEtest.md b/Sources/MXResources/Resources/Materials/TestSuite/README.md
similarity index 100%
rename from Sources/MXResources/Resources/Materials/TestSuite/READMEtest.md
rename to Sources/MXResources/Resources/Materials/TestSuite/README.md
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/_options.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/_options.mtlx
index bb29fbd7..99db2a9f 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/_options.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/_options.mtlx
@@ -11,23 +11,6 @@
can also be performed depending on the options enabled.
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -91,41 +74,9 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/libraries/metal/textures/test_mesh_wire_norm.png b/Sources/MXResources/Resources/Materials/TestSuite/libraries/metal/textures/mesh_wire_norm.png
similarity index 100%
rename from Sources/MXResources/Resources/Materials/TestSuite/libraries/metal/textures/test_mesh_wire_norm.png
rename to Sources/MXResources/Resources/Materials/TestSuite/libraries/metal/textures/mesh_wire_norm.png
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/nprlib/edge_brighten.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/nprlib/edge_brighten.mtlx
new file mode 100644
index 00000000..8ce3affd
--- /dev/null
+++ b/Sources/MXResources/Resources/Materials/TestSuite/nprlib/edge_brighten.mtlx
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/nprlib/gooch_shade.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/nprlib/gooch_shade.mtlx
new file mode 100644
index 00000000..9e723e2d
--- /dev/null
+++ b/Sources/MXResources/Resources/Materials/TestSuite/nprlib/gooch_shade.mtlx
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/nprlib/starfield.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/nprlib/starfield.mtlx
new file mode 100644
index 00000000..6898054a
--- /dev/null
+++ b/Sources/MXResources/Resources/Materials/TestSuite/nprlib/starfield.mtlx
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/nprlib/toon_shade.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/nprlib/toon_shade.mtlx
new file mode 100644
index 00000000..1c93cad6
--- /dev/null
+++ b/Sources/MXResources/Resources/Materials/TestSuite/nprlib/toon_shade.mtlx
@@ -0,0 +1,151 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/bsdf/generalized_schlick.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/bsdf/generalized_schlick.mtlx
index cb36a895..a320dcda 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/bsdf/generalized_schlick.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/bsdf/generalized_schlick.mtlx
@@ -1,6 +1,6 @@
-
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/bsdf/wedge_conductor.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/bsdf/wedge_conductor.mtlx
deleted file mode 100644
index 4e34fdc4..00000000
--- a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/bsdf/wedge_conductor.mtlx
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/displacement/displacement.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/displacement/displacement.mtlx
index 6ea8b7e9..d0ef0735 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/displacement/displacement.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/displacement/displacement.mtlx
@@ -1,6 +1,6 @@
-
+
@@ -21,7 +21,7 @@
-
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/multioutput/multishaderoutput.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/multioutput/multishaderoutput.mtlx
index 7456b088..f6dacf6e 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/multioutput/multishaderoutput.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/multioutput/multishaderoutput.mtlx
@@ -1,6 +1,6 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/network_surfaceshader.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/network_surfaceshader.mtlx
new file mode 100644
index 00000000..fb5202b3
--- /dev/null
+++ b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/network_surfaceshader.mtlx
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/normalmapped_surfaceshader.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/normalmapped_surfaceshader.mtlx
index 8a928487..460f8a89 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/normalmapped_surfaceshader.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/normalmapped_surfaceshader.mtlx
@@ -25,4 +25,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/surfacematerial_with_graph.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/surfacematerial_with_graph.mtlx
index 203aae6b..1ea487a5 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/surfacematerial_with_graph.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/pbrlib/surfaceshader/surfacematerial_with_graph.mtlx
@@ -1,10 +1,6 @@
-
-
-
-
-
+
@@ -12,42 +8,46 @@
-
-
-
+
+
+
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
-
-
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/adjustment/smoothstep.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/adjustment/smoothstep.mtlx
index 90510df2..e1fb7611 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/adjustment/smoothstep.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/adjustment/smoothstep.mtlx
@@ -1,8 +1,8 @@
@@ -20,38 +20,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -60,14 +28,6 @@
-
-
-
-
-
-
-
-
@@ -76,14 +36,6 @@
-
-
-
-
-
-
-
-
@@ -92,12 +44,4 @@
-
-
-
-
-
-
-
-
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/math.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/math.mtlx
index 5a4f0b21..09696183 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/math.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/math.mtlx
@@ -234,6 +234,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/math_operators.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/math_operators.mtlx
index fd48cd27..f2218140 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/math_operators.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/math_operators.mtlx
@@ -462,6 +462,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/matrix.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/matrix.mtlx
new file mode 100644
index 00000000..4bcb5557
--- /dev/null
+++ b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/math/matrix.mtlx
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/noise/noise.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/noise/noise.mtlx
index 14ab1b97..9a43223c 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/noise/noise.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/noise/noise.mtlx
@@ -1,208 +1,127 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/procedural/tiledshape.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/procedural/tiledshape.mtlx
index 69fd225f..fe6e4145 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/procedural/tiledshape.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/procedural/tiledshape.mtlx
@@ -24,7 +24,7 @@
-
+
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/texture/image_noise.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/texture/image_noise.mtlx
deleted file mode 100644
index 760e5088..00000000
--- a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/texture/image_noise.mtlx
+++ /dev/null
@@ -1,228 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/upgrade/syntax_1_37.mtlx b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/upgrade/syntax_1_37.mtlx
index 66dc69f6..7404b755 100644
--- a/Sources/MXResources/Resources/Materials/TestSuite/stdlib/upgrade/syntax_1_37.mtlx
+++ b/Sources/MXResources/Resources/Materials/TestSuite/stdlib/upgrade/syntax_1_37.mtlx
@@ -58,7 +58,7 @@
-
+
diff --git a/Sources/MXResources/Resources/README.md b/Sources/MXResources/Resources/README.md
new file mode 100644
index 00000000..6b353e02
--- /dev/null
+++ b/Sources/MXResources/Resources/README.md
@@ -0,0 +1,5 @@
+# Resources
+
+- [Geometry](Geometry): Sample geometry files. Includes files used by test suite.
+- [Images](Images): Sample image files. Includes files used by test suite.
+- [Materials](Materials) : Set of MaterialX documents. Includes [test suite files](Materials/TestSuite).
diff --git a/Sources/MXResources/libraries/CMakeLists.txt b/Sources/MXResources/libraries/CMakeLists.txt
deleted file mode 100644
index d60a54cf..00000000
--- a/Sources/MXResources/libraries/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-if (MATERIALX_OSL_LEGACY_CLOSURES)
- set(PBRLIB_SUFFIX "legacy")
-else()
- set(PBRLIB_SUFFIX "mtlx")
-endif()
-
-if(NOT SKBUILD)
- install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
- DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}"
- PATTERN "CMakeLists.txt" EXCLUDE
- PATTERN "pbrlib_genosl_impl.*" EXCLUDE)
- install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.${PBRLIB_SUFFIX}"
- DESTINATION "${MATERIALX_INSTALL_STDLIB_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx)
-endif()
-
-set(MATERIALX_PYTHON_LIBRARIES_PATH "${MATERIALX_PYTHON_FOLDER_NAME}/${MATERIALX_INSTALL_STDLIB_PATH}")
-if(SKBUILD)
- set(MATERIALX_PYTHON_LIBRARIES_PATH "${SKBUILD_PLATLIB_DIR}/MaterialX/libraries")
-endif()
-
-if(MATERIALX_BUILD_PYTHON)
- install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
- DESTINATION "${MATERIALX_PYTHON_LIBRARIES_PATH}"
- PATTERN "CMakeLists.txt" EXCLUDE
- PATTERN "pbrlib_genosl_impl.*" EXCLUDE)
- install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pbrlib/genosl/pbrlib_genosl_impl.${PBRLIB_SUFFIX}"
- DESTINATION "${MATERIALX_PYTHON_LIBRARIES_PATH}/pbrlib/genosl/" RENAME pbrlib_genosl_impl.mtlx)
-endif()
diff --git a/Sources/MXResources/libraries/README.md b/Sources/MXResources/libraries/README.md
index 937e20e4..15916f76 100644
--- a/Sources/MXResources/libraries/README.md
+++ b/Sources/MXResources/libraries/README.md
@@ -3,67 +3,62 @@
This folder contains the standard data libraries for MaterialX, providing declarations and graph definitions for the MaterialX nodes, and source code for all supported shader generators.
## Standard Pattern Library
-
- [stdlib](stdlib)
- - [stdlib_defs.mtlx](stdlib/stdlib_defs.mtlx) : Nodedef declarations.
- - [stdlib_ng.mtlx](stdlib/stdlib_ng.mtlx) : Nodegraph definitions.
- - [genglsl](stdlib/genglsl): GLSL language support.
- - [lib](stdlib/genglsl/lib) : Shader utility files.
- - [stdlib_genglsl_impl.mtlx](stdlib/genglsl/stdlib_genglsl_impl.mtlx) : Mapping from declarations to implementations.
- - [genosl](stdlib/genosl): OSL language support.
- - [lib](stdlib/genosl/lib) : Shader utility files.
- - [stdlib_genosl_impl.mtlx](stdlib/genosl/stdlib_genosl_impl.mtlx) : Mapping from declarations to implementations.
- - [genmdl](stdlib/genmdl): MDL language support.
- - [stdlib_genmdl_impl.mtlx](stdlib/genmdl/stdlib_genmdl_impl.mtlx) : Mapping from declarations to implementations.
- - Additional MaterialX support libraries for MDL are located in the [source/MXGenMdl/materialx](../source/MXGenMdl/materialx) package folder
- - [genmsl](stdlib/genmsl): MSL language support.
- - [lib](stdlib/genmsl/lib) : Shader utility files.
- - [stdlib_genmsl_impl.mtlx](stdlib/genmsl/stdlib_genmsl_impl.mtlx) : Mapping from declarations to implementations.
+ - [stdlib_defs.mtlx](stdlib/stdlib_defs.mtlx) : Nodedef declarations.
+ - [stdlib_ng.mtlx](stdlib/stdlib_ng.mtlx) : Nodegraph definitions.
+ - [genglsl](stdlib/genglsl): GLSL language support.
+ - [lib](stdlib/genglsl/lib) : Shader utility files.
+ - [stdlib_genglsl_impl.mtlx](stdlib/genglsl/stdlib_genglsl_impl.mtlx) : Mapping from declarations to implementations.
+ - [genosl](stdlib/genosl): OSL language support.
+ - [lib](stdlib/genosl/lib) : Shader utility files.
+ - [stdlib_genosl_impl.mtlx](stdlib/genosl/stdlib_genosl_impl.mtlx) : Mapping from declarations to implementations.
+ - [genmdl](stdlib/genmdl): MDL language support.
+ - [stdlib_genmdl_impl.mtlx](stdlib/genmdl/stdlib_genmdl_impl.mtlx) : Mapping from declarations to implementations.
+ - Additional MaterialX support libraries for MDL are located in the [source/MaterialXGenMdl/mdl/materialx](../source/MaterialXGenMdl/mdl/materialx) package folder
+ - [genmsl](stdlib/genmsl): MSL language support.
+ - [lib](stdlib/genmsl/lib) : Shader utility files.
+ - [stdlib_genmsl_impl.mtlx](stdlib/genmsl/stdlib_genmsl_impl.mtlx) : Mapping from declarations to implementations.
## Physically Based Shading Library
-
- [pbrlib](pbrlib)
- - [pbrlib_defs.mtlx](pbrlib/pbrlib_defs.mtlx) : Nodedef declarations.
- - [pbrlib_ng.mtlx](pbrlib/pbrlib_ng.mtlx) : Nodegraph definitions.
- - [genglsl](pbrlib/genglsl) : GLSL language support
- - [lib](pbrlib/genglsl/lib) : Shader utility files.
- - [pbrlib_genglsl_impl.mtlx](pbrlib/genglsl/pbrlib_genglsl_impl.mtlx) : Mapping from declarations to implementations.
- - [genosl](pbrlib/genosl) : OSL language support
- - [lib](pbrlib/genosl/lib) : Shader utility files.
- - [pbrlib_genosl_impl.mtlx](pbrlib/genosl/pbrlib_genosl_impl.mtlx) : Mapping from declarations to implementations.
- - [genmdl](pbrlib/genmdl) : MDL language support
- - [pbrlib_genmdl_impl.mtlx](pbrlib/genmdl/pbrlib_genmdl_impl.mtlx) : Mapping from declarations to implementations.
- - [genmsl](pbrlib/genmsl) : MSL language support
- - [pbrlib_genmsl_impl.mtlx](pbrlib/genmsl/pbrlib_genmsl_impl.mtlx) : Mapping from declarations to implementations.
+ - [pbrlib_defs.mtlx](pbrlib/pbrlib_defs.mtlx) : Nodedef declarations.
+ - [pbrlib_ng.mtlx](pbrlib/pbrlib_ng.mtlx) : Nodegraph definitions.
+ - [genglsl](pbrlib/genglsl) : GLSL language support
+ - [lib](pbrlib/genglsl/lib) : Shader utility files.
+ - [pbrlib_genglsl_impl.mtlx](pbrlib/genglsl/pbrlib_genglsl_impl.mtlx) : Mapping from declarations to implementations.
+ - [genosl](pbrlib/genosl) : OSL language support
+ - [lib](pbrlib/genosl/lib) : Shader utility files.
+ - [pbrlib_genosl_impl.mtlx](pbrlib/genosl/pbrlib_genosl_impl.mtlx) : Mapping from declarations to implementations.
+ - [genmdl](pbrlib/genmdl) : MDL language support
+ - [pbrlib_genmdl_impl.mtlx](pbrlib/genmdl/pbrlib_genmdl_impl.mtlx) : Mapping from declarations to implementations.
+ - [genmsl](pbrlib/genmsl) : MSL language support
+ - [pbrlib_genmsl_impl.mtlx](pbrlib/genmsl/pbrlib_genmsl_impl.mtlx) : Mapping from declarations to implementations.
## BxDF Graph Library
-
- [bxdf](bxdf)
- - [standard_surface.mtlx](bxdf/standard_surface.mtlx) : Graph definition of the [Autodesk Standard Surface](https://autodesk.github.io/standard-surface/) shading model.
- - [gltf_pbr.mtlx](bxdf/gltf_pbr.mtlx) : Graph definition of the [glTF PBR](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#appendix-b-brdf-implementation) shading model.
- - [usd_preview_surface.mtlx](bxdf/usd_preview_surface.mtlx) : Graph definition of the [UsdPreviewSurface](https://openusd.org/release/spec_usdpreviewsurface.html) shading model.
- - [lama](bxdf/lama) : Graph definitions of the [MaterialX Lama](https://rmanwiki.pixar.com/display/REN24/MaterialX+Lama) node set.
+ - [standard_surface.mtlx](bxdf/standard_surface.mtlx) : Graph definition of the [Autodesk Standard Surface](https://autodesk.github.io/standard-surface/) shading model.
+ - [gltf_pbr.mtlx](bxdf/gltf_pbr.mtlx) : Graph definition of the [glTF PBR](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#appendix-b-brdf-implementation) shading model.
+ - [usd_preview_surface.mtlx](bxdf/usd_preview_surface.mtlx) : Graph definition of the [UsdPreviewSurface](https://openusd.org/release/spec_usdpreviewsurface.html) shading model.
+ - [lama](bxdf/lama) : Graph definitions of the [MaterialX Lama](https://rmanwiki.pixar.com/display/REN24/MaterialX+Lama) node set.
## Color Management Library
-
- MaterialX shader generation natively supports a small set of common spaces for input colors, with all color transforms implemented as language-independent MaterialX graphs.The canonical definitions of these color transforms may be found in the OpenColorIO configuration for [ACES 1.2](https://github.com/colour-science/OpenColorIO-Configs/tree/feature/aces-1.2-config/aces_1.2).
- - lin_rec709
- - g18_rec709
- - g22_rec709
- - rec709_display
- - acescg (lin_ap1)
- - g22_ap1
- - srgb_texture
- - lin_adobergb
- - adobergb
- - srgb_displayp3
- - lin_displayp3
+ - lin_rec709
+ - g18_rec709
+ - g22_rec709
+ - rec709_display
+ - acescg (lin_ap1)
+ - g22_ap1
+ - srgb_texture
+ - lin_adobergb
+ - adobergb
+ - srgb_displayp3
+ - lin_displayp3
- [cmlib](cmlib)
- - [cmlib_defs.mtlx](cmlib/cmlib_defs.mtlx) : Nodedef declarations.
- - [cmlib_ng.mtlx](cmlib/cmlib_ng.mtlx) : Nodegraph definitions.
+ - [cmlib_defs.mtlx](cmlib/cmlib_defs.mtlx) : Nodedef declarations.
+ - [cmlib_ng.mtlx](cmlib/cmlib_ng.mtlx) : Nodegraph definitions.
## Target Definitions
-
- Each target implementation requires a target definition for declaration / implementation correspondence to work.
- The [targets](targets) folder contains definition files for the following core targets:
- GLSL : `genglsl`
@@ -73,14 +68,13 @@ This folder contains the standard data libraries for MaterialX, providing declar
- Any additional target files should be added under this folder and loaded in as required.
### Target Support
-
- GLSL target support is for version 4.0 or higher.
- OSL target support is for version 1.9.10 or higher.
- MDL target support is for version 1.7.
- Basic GLSL and MSL `lightshader` node definitions and implementations are provided for the following light types:
- - point, directional, spot
+ - point, directional, spot
- Shader generation does not currently support:
- - `ambientocclusion` node.
- - `arrayappend` node.
- - `curveadjust` node.
- - `displacementshader` and `volumeshader` nodes for hardware shading targets (GLSL, MSL).
+ - `ambientocclusion` node.
+ - `arrayappend` node.
+ - `curveadjust` node.
+ - `displacementshader` and `volumeshader` nodes for hardware shading targets (GLSL, MSL).
diff --git a/Sources/MXResources/libraries/bxdf/gltf_pbr.mtlx b/Sources/MXResources/libraries/bxdf/gltf_pbr.mtlx
index 6654e634..b42054a1 100644
--- a/Sources/MXResources/libraries/bxdf/gltf_pbr.mtlx
+++ b/Sources/MXResources/libraries/bxdf/gltf_pbr.mtlx
@@ -359,7 +359,7 @@
-
+
diff --git a/Sources/MXResources/libraries/bxdf/usd_preview_surface.mtlx b/Sources/MXResources/libraries/bxdf/usd_preview_surface.mtlx
index 984bad03..6efb2881 100644
--- a/Sources/MXResources/libraries/bxdf/usd_preview_surface.mtlx
+++ b/Sources/MXResources/libraries/bxdf/usd_preview_surface.mtlx
@@ -9,7 +9,7 @@
-
+
@@ -18,7 +18,7 @@
-
+
diff --git a/Sources/MXResources/libraries/mdl/materialx/core.mdl b/Sources/MXResources/libraries/mdl/materialx/core.mdl
new file mode 100644
index 00000000..f9fe427b
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/core.mdl
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// MDL implementation of core types and supporting functions from
+// MaterialX: An Open Standard for Network-Based CG Object Looks
+// Document v1.37 REV2, January 19, 2020
+// and
+// MaterialX: An Open Standard for Network-Based CG Object Looks
+// Document v1.37 REV2, January 19, 2020
+// www.materialx.org
+// in
+// NVIDIA Material Definition Language 1.7
+// Language Specification
+// Document version 1.7.2, January 17, 2022
+// www.nvidia.com/mdl
+
+mdl 1.6;
+
+import ::math::*;
+import ::state::*;
+import ::tex::*;
+
+// Epsilon value used in float calculations.
+export const float FLOAT_EPS = 0.000001;
+
+// MaterialX Data Types
+// NOTE: We use native MDL types where possible and rely on the translator
+// to map MaterialX types to MDL types according to this table:
+//
+// MaterialX --> MDL
+// ------------------
+// integer --> int
+// boolean --> bool
+// float --> float
+// color3 --> color
+// color4 --> struct color4 (see below)
+// vector2 --> float2
+// vector3 --> float3
+// vector4 --> float4
+// matrix33 --> float3x3
+// matrix44 --> float4x4
+// string --> string, or context specific enums (see below)
+// filename --> texture_2d, or other repective resource type
+// geomname --> (N.A.)
+// array --> T[] (deferred-size arrays)
+//
+// NOTE: The type mapping is not bijective, multiple types in MaterialX
+// map to the same type in MDL, which can impact the translation
+// of overloaded nodes to not generate mutliple identical definitions.
+
+// Special struct type for color4
+export struct color4 {
+ color rgb = color(0.0);
+ float a = 1.0;
+};
+
+// NOTE: MDL does not support operator overloading nor custom constructors,
+// we use constructor-like functions defined here to help the generator
+// to work with the vector and color types, as well as operator-like
+// functions for the color4 type.
+export color4 mk_color4( float v) { return color4( color(v), v);}
+export color4 mk_color4( float r, float g, float b, float a) { return color4(color(r,g,b), a); }
+export color4 mk_color4( float3 v) { return color4(color(v.x, v.y, v.z), 1.0); }
+export color4 mk_color4( float4 v) { return color4(color(v.x, v.y, v.z), v.w); }
+export color4 mk_color4( color v) { return color4(v, 1.0); }
+export color4 mk_color4( color v, float a) { return color4(v, a); }
+export color mk_color3( float r, float g, float b) { return color(r, g, b); }
+export color mk_color3( float v) { return color(v); }
+export color mk_color3( float2 v) { return color(v.x, v.y, 0.0); }
+export color mk_color3( float3 v) { return color(v.x, v.y, v.z); }
+export color mk_color3( float4 v) { return color(v.x, v.y, v.z); }
+export color mk_color3( color v) { return v; }
+export color mk_color3( color4 v) { return v.rgb; }
+export float3 mk_float3( color4 v) { return float3(v.rgb); }
+export float4 mk_float4( color4 v) {
+ float3 rgb = float3(v.rgb);
+ return float4(rgb.x, rgb.y, rgb.z, v.a);
+}
+
+export color4 mx_add( color4 v1, color4 v2) { return color4(v1.rgb + v2.rgb, v1.a + v2.a); }
+export color4 mx_add( color4 v1, float v2) { return color4(v1.rgb + v2 , v1.a + v2 ); }
+export color4 mx_subtract( color4 v1, color4 v2) { return color4(v1.rgb - v2.rgb, v1.a - v2.a); }
+export color4 mx_subtract( color4 v1, float v2) { return color4(v1.rgb - v2 , v1.a - v2 ); }
+export color4 mx_multiply( color4 v1, color4 v2) { return color4(v1.rgb * v2.rgb, v1.a * v2.a); }
+export color4 mx_multiply( color4 v1, float v2) { return color4(v1.rgb * v2 , v1.a * v2 ); }
+export color4 mx_divide( color4 v1, color4 v2) { return color4(v1.rgb / v2.rgb, v1.a / v2.a); }
+export color4 mx_divide( color4 v1, float v2) { return color4(v1.rgb / v2 , v1.a / v2 ); }
+export float mx_mod( float x, float y) { return x - y * math::floor(x/y); }
+export float2 mx_mod( float2 x, float2 y) { return x - y * math::floor(x/y); }
+export float3 mx_mod( float3 x, float3 y) { return x - y * math::floor(x/y); }
+export float4 mx_mod( float4 x, float4 y) { return x - y * math::floor(x/y); }
+export float2 mx_mod( float2 x, float y) { return mx_mod(x, float2(y,y)); }
+export float3 mx_mod( float3 x, float y) { return mx_mod(x, float3(y,y,y)); }
+export float4 mx_mod( float4 x, float y) { return mx_mod(x, float4(y,y,y,y)); }
+
+// Parameter Expressions and Function Curves
+// Idea: attach an auxiliary lookup function if an array of frame values is
+// given in a attribute
+export int curve_lookup( int index, int[] values, int min, int max) {
+ return values[::math::clamp( index, min, max) - min];
+}
+export float curve_lookup( int index, float[] values, int min, int max) {
+ return values[::math::clamp( index, min, max) - min];
+}
+export float2 curve_lookup( int index, float2[] values, int min, int max) {
+ return values[::math::clamp( index, min, max) - min];
+}
+export float3 curve_lookup( int index, float3[] values, int min, int max) {
+ return values[::math::clamp( index, min, max) - min];
+}
+export float4 curve_lookup( int index, float4[] values, int min, int max) {
+ return values[::math::clamp( index, min, max) - min];
+}
+export color curve_lookup( int index, color[] values, int min, int max) {
+ return values[::math::clamp( index, min, max) - min];
+}
+
+// Enum selecting address modes for texture nodes, instead of string
+export enum mx_addressmode_type {
+ mx_addressmode_type_constant,
+ mx_addressmode_type_clamp,
+ mx_addressmode_type_periodic,
+ mx_addressmode_type_mirror
+};
+
+// Enum selecting filter modes for texture nodes, instead of string
+export enum mx_filterlookup_type {
+ mx_filterlookup_type_closest,
+ mx_filterlookup_type_linear,
+ mx_filterlookup_type_cubic
+};
+
+// Enum selecting coordinate spaces, instead of string
+export enum mx_coordinatespace_type {
+ mx_coordinatespace_type_model,
+ mx_coordinatespace_type_object,
+ mx_coordinatespace_type_world
+};
+
+// Helper function mapping MaterialX coordinate spaces to MDL coordinate spaces
+export state::coordinate_space mx_map_space( mx_coordinatespace_type space) {
+ switch (space) {
+ case mx_coordinatespace_type_world:
+ return state::coordinate_world;
+ case mx_coordinatespace_type_object:
+ return state::coordinate_object;
+ default:
+ return state::coordinate_internal;
+ }
+}
+
+// Helper function mapping MaterialX coordinate space strings to MDL coordinate spaces
+export state::coordinate_space mx_map_space( string space) {
+ if (space == "world") {
+ return state::coordinate_world;
+ }
+ else if (space == "object") {
+ return state::coordinate_object;
+ }
+ else {
+ return state::coordinate_internal;
+ }
+}
+
+// Support return type structures for the separate[234] types
+export struct mx_separate2_vector2_type { float outx = 0.0; float outy = 0.0; };
+export struct mx_separate3_color3_type { float outr = 0.0; float outg = 0.0; float outb = 0.0; };
+export struct mx_separate3_vector3_type { float outx = 0.0; float outy = 0.0; float outz = 0.0; };
+export struct mx_separate4_color4_type { float outr = 0.0; float outg = 0.0; float outb = 0.0; float outa = 0.0; };
+export struct mx_separate4_vector4_type { float outx = 0.0; float outy = 0.0; float outz = 0.0; float outw = 0.0; };
+
+// Enum for blur filter type, instead of string
+export enum mx_filter_type {
+ mx_filter_type_box,
+ mx_filter_type_gaussian
+};
+
+// Enum selecting microfacet models, instead of string
+export enum mx_distribution_type {
+ mx_distribution_type_ggx
+};
+
+// Custom annotation for MDL function parameters to map between MDL and the original MaterialX graph.
+// * When added to a paramater, the "name" will contain the path in the MaterialX graph starting
+// from the root up to the input using `/` as separator.
+export annotation origin(string name);
diff --git a/Sources/MXResources/libraries/mdl/materialx/hsv.mdl b/Sources/MXResources/libraries/mdl/materialx/hsv.mdl
new file mode 100644
index 00000000..3c7753a9
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/hsv.mdl
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Support functions for HSV <--> RGB color conversions
+
+mdl 1.6;
+
+import ::limits::*;
+import ::math::*;
+
+// Convert from the HSV color model to the RGB color model
+export float3 mx_hsvtorgb(float3 hsv) {
+ // from "Color Imaging, Fundamentals and Applications", Reinhard et al., p. 442
+
+ float h = 6.0 * (hsv.x - math::floor(hsv.x));
+ int hi = int(h); // truncate
+ float f = h - float(hi);
+
+ float zy = hsv.z*hsv.y;
+ float a = hsv.z - zy;
+ float b = hsv.z - zy*f;
+ float c = a + zy*f;
+
+ switch(hi) {
+ default:
+ // hue out of [0,1] range...
+ // fall through...
+ case 0:
+ return float3(hsv.z, c, a);
+ case 1:
+ return float3(b, hsv.z, a);
+ case 2:
+ return float3(a, hsv.z, c);
+ case 3:
+ return float3(a, b, hsv.z);
+ case 4:
+ return float3(c, a, hsv.z);
+ case 5:
+ return float3(hsv.z, a, b);
+ }
+}
+
+// Convert from the RGB color model to the HSV color model
+export float3 mx_rgbtohsv(float3 rgb) {
+ // from "Color Imaging, Fundamentals and Applications", Reinhard et al., p. 442
+ // H =
+ // 60*(G-B)/(max-min) if R is max
+ // 60*(2+((B-R)/(max-min))) if G is max
+ // 60*(4+((R-G)/(max-min))) if B if max
+ // and normalize the result by dividing by 360deg
+ // S = (max-min)/max
+ // V = max
+
+ float max = math::max(rgb.x, math::max(rgb.y, rgb.z));
+ float min = math::min(rgb.x, math::min(rgb.y, rgb.z));
+ float range = max - min;
+ float inv_range = (1.0f/6.0f)/range;
+
+ float saturation = (max > limits::FLOAT_MIN) ? (range / max) : 0.0f;
+ float hue = (saturation != 0.0f) ?
+ ((max == rgb.x) ? ((rgb.y-rgb.z)*inv_range) // R is max
+ : (max == rgb.y) ? ((2.0f/6.0f) + (rgb.z-rgb.x)*inv_range) // G is max
+ : ((4.0f/6.0f) + (rgb.x-rgb.y)*inv_range)) // B is max
+ : 0.0f; // hue is undefined (assume 0)
+
+ return float3((hue >= 0.0f) ? hue : (hue + 1.0f), saturation, max);
+}
diff --git a/Sources/MXResources/libraries/mdl/materialx/noise.mdl b/Sources/MXResources/libraries/mdl/materialx/noise.mdl
new file mode 100644
index 00000000..a6c1658b
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/noise.mdl
@@ -0,0 +1,760 @@
+//
+// Copyright Contributors to the MaterialX Project
+// SPDX-License-Identifier: Apache-2.0
+//
+
+/********************************************************************************
+MaterialX Noise Library.
+
+This library is a modified version of the noise library found in
+Open Shading Language:
+github.com/imageworks/OpenShadingLanguage/blob/master/src/include/OSL/oslnoise.h
+
+It contains the subset of noise types needed to implement the MaterialX
+standard library. The modifications are mainly conversions from C++ to MDL.
+Produced results should be identical to the OSL noise functions.
+
+Original copyright notice:
+------------------------------------------------------------------------
+Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
+All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+* Neither the name of Sony Pictures Imageworks nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+------------------------------------------------------------------------
+********************************************************************************/
+
+mdl 1.6;
+
+import ::anno::*;
+import ::math::*;
+import ::state::*;
+
+import .::core::*;
+import .::swizzle::*;
+
+float mx_bilerp_float(float v0, float v1, float v2, float v3, float s, float t)
+{
+ float s1 = 1.0 - s;
+ return (1.0 - t) * (v0*s1 + v1*s) + t * (v2*s1 + v3*s);
+}
+float3 mx_bilerp_float3(float3 v0, float3 v1, float3 v2, float3 v3, float s, float t)
+{
+ float s1 = 1.0 - s;
+ return (1.0 - t) * (v0*s1 + v1*s) + t * (v2*s1 + v3*s);
+}
+float mx_trilerp_float(float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float s, float t, float r)
+{
+ float s1 = 1.0 - s;
+ float t1 = 1.0 - t;
+ float r1 = 1.0 - r;
+ return (r1*(t1*(v0*s1 + v1*s) + t*(v2*s1 + v3*s)) +
+ r*(t1*(v4*s1 + v5*s) + t*(v6*s1 + v7*s)));
+}
+float3 mx_trilerp_float3(float3 v0, float3 v1, float3 v2, float3 v3, float3 v4, float3 v5, float3 v6, float3 v7, float s, float t, float r)
+{
+ float s1 = 1.0 - s;
+ float t1 = 1.0 - t;
+ float r1 = 1.0 - r;
+ return (r1*(t1*(v0*s1 + v1*s) + t*(v2*s1 + v3*s)) +
+ r*(t1*(v4*s1 + v5*s) + t*(v6*s1 + v7*s)));
+}
+
+// 2 and 3 dimensional gradient functions - perform a dot product against a
+// randomly chosen vector. Note that the gradient vector is not normalized, but
+// this only affects the overal "scale" of the result, so we simply account for
+// the scale by multiplying in the corresponding "perlin" function.
+float mx_gradient_float(int mxp_hash, float mxp_x, float mxp_y)
+{
+ // 8 possible directions (+-1,+-2) and (+-2,+-1)
+ int h = mxp_hash & 7;
+ float u = h<4 ? mxp_x : mxp_y;
+ float v = 2.0 * (h<4 ? mxp_y : mxp_x);
+ // compute the dot product with (x,y).
+ return (((h&1)!=0) ? -u : u) + (((h&2) != 0) ? -v : v);
+}
+float mx_gradient_float(int mxp_hash, float mxp_x, float mxp_y, float mxp_z)
+{
+ // use vectors pointing to the edges of the cube
+ int h = mxp_hash & 15;
+ float u = h<8 ? mxp_x : mxp_y;
+ float v = h<4 ? mxp_y : ((h==12)||(h==14)) ? mxp_x : mxp_z;
+ return (((h&1)!=0)?-u:u) + (((h&2)!=0)?-v:v);
+}
+float3 mx_gradient_float3(int3 mxp_hash, float mxp_x, float mxp_y)
+{
+ return float3(mx_gradient_float(mxp_hash.x, mxp_x, mxp_y),
+ mx_gradient_float(mxp_hash.y, mxp_x, mxp_y),
+ mx_gradient_float(mxp_hash.z, mxp_x, mxp_y));
+}
+float3 mx_gradient_float3(int3 mxp_hash, float mxp_x, float mxp_y, float mxp_z)
+{
+ return float3(mx_gradient_float(mxp_hash.x, mxp_x, mxp_y, mxp_z),
+ mx_gradient_float(mxp_hash.y, mxp_x, mxp_y, mxp_z),
+ mx_gradient_float(mxp_hash.z, mxp_x, mxp_y, mxp_z));
+}
+// Scaling factors to normalize the result of gradients above.
+// These factors were experimentally calculated to be:
+// 2D: 0.6616
+// 3D: 0.9820
+//JAN: why do those differ from osl sourcecode?
+float mx_gradient_scale2d_float(float mxp_v) { return 0.6616 * mxp_v; }
+float mx_gradient_scale3d_float(float mxp_v) { return 0.9820 * mxp_v; }
+float3 mx_gradient_scale2d_float3(float3 mxp_v) { return 0.6616 * mxp_v; }
+float3 mx_gradient_scale3d_float3(float3 mxp_v) { return 0.9820 * mxp_v; }
+
+/// Bitwise circular rotation left by k bits (for 32 bit unsigned integers)
+int mx_rotl32(int mxp_x, int mxp_k)
+{
+ return (mxp_x<>>(32-mxp_k)); //note the unsigned right shift
+}
+
+int3 mx_bjmix(int a, int b, int c)
+{
+ a -= c; a ^= mx_rotl32(c, 4); c += b;
+ b -= a; b ^= mx_rotl32(a, 6); a += c;
+ c -= b; c ^= mx_rotl32(b, 8); b += a;
+ a -= c; a ^= mx_rotl32(c,16); c += b;
+ b -= a; b ^= mx_rotl32(a,19); a += c;
+ c -= b; c ^= mx_rotl32(b, 4); b += a;
+ return int3(a, b, c);
+}
+
+// Mix up and combine the bits of a, b, and c (doesn't change them, but
+// returns a hash of those three original values).
+int mx_bjfinal(int mxp_a, int mxp_b, int mxp_c)
+{
+ mxp_c ^= mxp_b; mxp_c -= mx_rotl32(mxp_b,14);
+ mxp_a ^= mxp_c; mxp_a -= mx_rotl32(mxp_c,11);
+ mxp_b ^= mxp_a; mxp_b -= mx_rotl32(mxp_a,25);
+ mxp_c ^= mxp_b; mxp_c -= mx_rotl32(mxp_b,16);
+ mxp_a ^= mxp_c; mxp_a -= mx_rotl32(mxp_c,4);
+ mxp_b ^= mxp_a; mxp_b -= mx_rotl32(mxp_a,14);
+ mxp_c ^= mxp_b; mxp_c -= mx_rotl32(mxp_b,24);
+ return mxp_c;
+}
+
+// Convert a 32 bit integer into a floating point number in [0,1]
+float mx_bits_to_01(int mxp_bits)
+{
+ return mxp_bits >=0 ? float(mxp_bits) / 4294967295.:
+ float(mxp_bits>>>1)/ 2147483647.;
+}
+
+float mx_fade(float mxp_t)
+{
+ return mxp_t * mxp_t * mxp_t * (mxp_t * (mxp_t * 6.0 - 15.0) + 10.0);
+}
+
+int mx_hash_int(int mxp_x)
+{
+ int len = 1;
+ int seed = int(0xdeadbeef) + (len << 2) + 13;
+ return mx_bjfinal(seed + mxp_x, seed, seed);
+}
+
+int mx_hash_int(int mxp_x, int mxp_y)
+{
+ int len = 2;
+ int a, b, c;
+ a = b = c = int(0xdeadbeef) + (len << 2) + 13;
+ a += mxp_x;
+ b += mxp_y;
+ return mx_bjfinal(a, b, c);
+}
+
+int mx_hash_int(int mxp_x, int mxp_y, int mxp_z)
+{
+ int len = 3;
+ int a, b, c;
+ a = b = c = int(0xdeadbeef) + (len << 2) + 13;
+ a += mxp_x;
+ b += mxp_y;
+ c += mxp_z;
+ return mx_bjfinal(a, b, c);
+}
+
+int mx_hash_int(int x, int y, int z, int xx)
+{
+ int len = 4;
+ int a, b, c;
+ a = b = c = int(0xdeadbeef) + (len << 2) + 13;
+ a += x;
+ b += y;
+ c += z;
+ int3 abc = mx_bjmix(a, b, c);
+ a = abc.x;
+ b = abc.y;
+ c = abc.z;
+ a += xx;
+ return mx_bjfinal(a, b, c);
+}
+
+int mx_hash_int(int x, int y, int z, int xx, int yy)
+{
+ int len = 5;
+ int a, b, c;
+ a = b = c = int(0xdeadbeef) + (len << 2) + 13;
+ a += x;
+ b += y;
+ c += z;
+ int3 abc = mx_bjmix(a, b, c);
+ a = abc.x;
+ b = abc.y;
+ c = abc.z;
+ a += xx;
+ b += yy;
+ return mx_bjfinal(a, b, c);
+}
+
+int3 mx_hash_int3(int mxp_x, int mxp_y)
+{
+ int h = mx_hash_int(mxp_x, mxp_y);
+ // we only need the low-order bits to be random, so split out
+ // the 32 bit result into 3 parts for each channel
+ int3 result;
+ result.x = (h ) & 0xFF;
+ result.y = (h >>> 8 ) & 0xFF;
+ result.z = (h >>> 16) & 0xFF;
+ return result;
+}
+
+int3 mx_hash_int3(int mxp_x, int mxp_y, int mxp_z)
+{
+ int h = mx_hash_int(mxp_x, mxp_y, mxp_z);
+ // we only need the low-order bits to be random, so split out
+ // the 32 bit result into 3 parts for each channel
+ int3 result;
+ result.x = (h ) & 0xFF;
+ result.y = (h >>> 8 ) & 0xFF;
+ result.z = (h >>> 16) & 0xFF;
+ return result;
+}
+
+export float mx_perlin_noise_float(
+ float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
+[[
+ anno::noinline()
+]]
+{
+ float ix=math::floor(mxp_p.x);
+ float iy=math::floor(mxp_p.y);
+ int X = int(ix);
+ int Y = int(iy);
+ float fx = mxp_p.x-ix;
+ float fy = mxp_p.y-iy;
+ float u = mx_fade(fx);
+ float v = mx_fade(fy);
+ float result = mx_bilerp_float(
+ mx_gradient_float(mx_hash_int(X , Y ), fx , fy ),
+ mx_gradient_float(mx_hash_int(X+1, Y ), fx-1.0, fy ),
+ mx_gradient_float(mx_hash_int(X , Y+1), fx , fy-1.0),
+ mx_gradient_float(mx_hash_int(X+1, Y+1), fx-1.0, fy-1.0),
+ u, v);
+ return mx_gradient_scale2d_float(result);
+}
+
+export float3 mx_perlin_noise_float3(
+ float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
+[[
+ anno::noinline()
+]]
+{
+ float ix=math::floor(mxp_p.x);
+ float iy=math::floor(mxp_p.y);
+ int X = int(ix);
+ int Y = int(iy);
+ float fx = mxp_p.x-ix;
+ float fy = mxp_p.y-iy;
+ float u = mx_fade(fx);
+ float v = mx_fade(fy);
+ float3 result = mx_bilerp_float3(
+ mx_gradient_float3(mx_hash_int3(X , Y ), fx , fy ),
+ mx_gradient_float3(mx_hash_int3(X+1, Y ), fx-1.0, fy ),
+ mx_gradient_float3(mx_hash_int3(X , Y+1), fx , fy-1.0),
+ mx_gradient_float3(mx_hash_int3(X+1, Y+1), fx-1.0, fy-1.0),
+ u, v);
+ return mx_gradient_scale2d_float3(result);
+}
+
+export float mx_perlin_noise_float(
+ float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
+[[
+ anno::noinline()
+]]
+{
+ float ix=math::floor(mxp_p.x);
+ float iy=math::floor(mxp_p.y);
+ float iz=math::floor(mxp_p.z);
+ int X = int(ix);
+ int Y = int(iy);
+ int Z = int(iz);
+ float fx = mxp_p.x-ix;
+ float fy = mxp_p.y-iy;
+ float fz = mxp_p.z-iz;
+ float u = mx_fade(fx);
+ float v = mx_fade(fy);
+ float w = mx_fade(fz);
+ float result = mx_trilerp_float(
+ mx_gradient_float(mx_hash_int(X , Y , Z ), fx , fy , fz ),
+ mx_gradient_float(mx_hash_int(X+1, Y , Z ), fx-1.0, fy , fz ),
+ mx_gradient_float(mx_hash_int(X , Y+1, Z ), fx , fy-1.0, fz ),
+ mx_gradient_float(mx_hash_int(X+1, Y+1, Z ), fx-1.0, fy-1.0, fz ),
+ mx_gradient_float(mx_hash_int(X , Y , Z+1), fx , fy , fz-1.0),
+ mx_gradient_float(mx_hash_int(X+1, Y , Z+1), fx-1.0, fy , fz-1.0),
+ mx_gradient_float(mx_hash_int(X , Y+1, Z+1), fx , fy-1.0, fz-1.0),
+ mx_gradient_float(mx_hash_int(X+1, Y+1, Z+1), fx-1.0, fy-1.0, fz-1.0),
+ u, v, w);
+ return mx_gradient_scale3d_float(result);
+}
+
+export float3 mx_perlin_noise_float3(
+ float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
+[[
+ anno::noinline()
+]]
+{
+ float ix=math::floor(mxp_p.x);
+ float iy=math::floor(mxp_p.y);
+ float iz=math::floor(mxp_p.z);
+ int X = int(ix);
+ int Y = int(iy);
+ int Z = int(iz);
+ float fx = mxp_p.x-ix;
+ float fy = mxp_p.y-iy;
+ float fz = mxp_p.z-iz;
+ float u = mx_fade(fx);
+ float v = mx_fade(fy);
+ float w = mx_fade(fz);
+ float3 result = mx_trilerp_float3(
+ mx_gradient_float3(mx_hash_int3(X , Y , Z ), fx , fy , fz ),
+ mx_gradient_float3(mx_hash_int3(X+1, Y , Z ), fx-1.0, fy , fz ),
+ mx_gradient_float3(mx_hash_int3(X , Y+1, Z ), fx , fy-1.0, fz ),
+ mx_gradient_float3(mx_hash_int3(X+1, Y+1, Z ), fx-1.0, fy-1.0, fz ),
+ mx_gradient_float3(mx_hash_int3(X , Y , Z+1), fx , fy , fz-1.0),
+ mx_gradient_float3(mx_hash_int3(X+1, Y , Z+1), fx-1.0, fy , fz-1.0),
+ mx_gradient_float3(mx_hash_int3(X , Y+1, Z+1), fx , fy-1.0, fz-1.0),
+ mx_gradient_float3(mx_hash_int3(X+1, Y+1, Z+1), fx-1.0, fy-1.0, fz-1.0),
+ u, v, w);
+ return mx_gradient_scale3d_float3(result);
+}
+
+export float mx_cell_noise_float(float mxp_p)
+[[
+ anno::noinline()
+]]
+{
+ int ix = math::floor(mxp_p);
+ return mx_bits_to_01(mx_hash_int(ix));
+}
+
+export float mx_cell_noise_float(
+ float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
+[[
+ anno::noinline()
+]]
+{
+ int ix = math::floor(mxp_p.x);
+ int iy = math::floor(mxp_p.y);
+ return mx_bits_to_01(mx_hash_int(ix, iy));
+}
+
+export float mx_cell_noise_float(
+ float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
+[[
+ anno::noinline()
+]]
+{
+ int ix = math::floor(mxp_p.x);
+ int iy = math::floor(mxp_p.y);
+ int iz = math::floor(mxp_p.z);
+ return mx_bits_to_01(mx_hash_int(ix, iy, iz));
+}
+
+export float mx_cell_noise_float(float4 mxp_p)
+[[
+ anno::noinline()
+]]
+{
+ int ix = math::floor(mxp_p.x);
+ int iy = math::floor(mxp_p.y);
+ int iz = math::floor(mxp_p.z);
+ int iw = math::floor(mxp_p.w);
+ return mx_bits_to_01(mx_hash_int(ix, iy, iz, iw));
+}
+
+export float3 mx_cell_noise_float3(float mxp_p)
+[[
+ anno::noinline()
+]]
+{
+ int ix = math::floor(mxp_p);
+ return float3(
+ mx_bits_to_01(mx_hash_int(ix, 0)),
+ mx_bits_to_01(mx_hash_int(ix, 1)),
+ mx_bits_to_01(mx_hash_int(ix, 2))
+ );
+}
+
+export float3 mx_cell_noise_float3(
+ float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
+[[
+ anno::noinline()
+]]
+{
+ int ix = math::floor(mxp_p.x);
+ int iy = math::floor(mxp_p.y);
+ return float3(
+ mx_bits_to_01(mx_hash_int(ix, iy, 0)),
+ mx_bits_to_01(mx_hash_int(ix, iy, 1)),
+ mx_bits_to_01(mx_hash_int(ix, iy, 2))
+ );
+}
+
+export float3 mx_cell_noise_float3(
+ float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
+[[
+ anno::noinline()
+]]
+{
+ int ix = math::floor(mxp_p.x);
+ int iy = math::floor(mxp_p.y);
+ int iz = math::floor(mxp_p.z);
+ return float3(
+ mx_bits_to_01(mx_hash_int(ix, iy, iz, 0)),
+ mx_bits_to_01(mx_hash_int(ix, iy, iz, 1)),
+ mx_bits_to_01(mx_hash_int(ix, iy, iz, 2))
+ );
+}
+
+export float3 mx_cell_noise_float3(float4 mxp_p)
+[[
+ anno::noinline()
+]]
+{
+ int ix = math::floor(mxp_p.x);
+ int iy = math::floor(mxp_p.y);
+ int iz = math::floor(mxp_p.z);
+ int iw = math::floor(mxp_p.w);
+ return float3(
+ mx_bits_to_01(mx_hash_int(ix, iy, iz, iw, 0)),
+ mx_bits_to_01(mx_hash_int(ix, iy, iz, iw, 1)),
+ mx_bits_to_01(mx_hash_int(ix, iy, iz, iw, 2))
+ );
+}
+
+export float mx_fractal_noise_float(
+ float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
+ int mxp_octaves = 3,
+ float mxp_lacunarity = 2.0,
+ float mxp_diminish= 0.5)
+[[
+ anno::noinline()
+]]
+{
+ float result = 0.0;
+ float amplitude = 1.0;
+ for (int i = 0; i < mxp_octaves; ++i)
+ {
+ result += amplitude * mx_perlin_noise_float(mxp_p);
+ amplitude *= mxp_diminish;
+ mxp_p *= mxp_lacunarity;
+ }
+ return result;
+}
+
+export float3 mx_fractal_noise_float3(
+ float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
+ int mxp_octaves = 3,
+ float mxp_lacunarity = 2.0,
+ float mxp_diminish= 0.5)
+[[
+ anno::noinline()
+]]
+{
+ float3 result = float3(0.0);
+ float amplitude = 1.0;
+ for (int i = 0; i < mxp_octaves; ++i)
+ {
+ result += amplitude * mx_perlin_noise_float3(mxp_p);
+ amplitude *= mxp_diminish;
+ mxp_p *= mxp_lacunarity;
+ }
+ return result;
+}
+
+export float2 mx_fractal_noise_float2(
+ float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
+ int mxp_octaves = 3,
+ float mxp_lacunarity = 2.0,
+ float mxp_diminish= 0.5)
+[[
+ anno::noinline()
+]]
+{
+ return float2(mx_fractal_noise_float(mxp_p, mxp_octaves, mxp_lacunarity, mxp_diminish),
+ mx_fractal_noise_float(mxp_p+float3(19, 193, 17), mxp_octaves, mxp_lacunarity, mxp_diminish));
+}
+
+export float4 mx_fractal_noise_float4(
+ float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
+ int mxp_octaves = 3,
+ float mxp_lacunarity = 2.0,
+ float mxp_diminish= 0.5)
+[[
+ anno::noinline()
+]]
+{
+
+ float3 c = mx_fractal_noise_float3(mxp_p, mxp_octaves, mxp_lacunarity, mxp_diminish);
+ float a = mx_fractal_noise_float(mxp_p+float3(19, 193, 17), mxp_octaves, mxp_lacunarity, mxp_diminish);
+ return float4(c.x, c.y, c.z, a);
+}
+
+float mx_worley_distance2(float2 p, int x, int y, int xoff, int yoff, float jitter, int metric)
+{
+ float3 tmp = mx_cell_noise_float3(float2(x+xoff, y+yoff));
+ float2 off = float2(tmp.x, tmp.y);
+
+ off -= 0.5f;
+ off *= jitter;
+ off += 0.5f;
+
+ float2 cellpos = float2(float(x), float(y)) + off;
+ float2 diff = cellpos - p;
+ if (metric == 2)
+ return math::abs(diff.x) + math::abs(diff.y); // Manhattan distance
+ if (metric == 3)
+ return math::max(math::abs(diff.x), math::abs(diff.y)); // Chebyshev distance
+ // Either Euclidian or Distance^2
+ return math::dot(diff, diff);
+}
+
+float mx_worley_distance3(float3 p, int x, int y, int z, int xoff, int yoff, int zoff, float jitter, int metric)
+{
+ float3 off = mx_cell_noise_float3(float3(x+xoff, y+yoff, z+zoff));
+
+ off -= 0.5f;
+ off *= jitter;
+ off += 0.5f;
+
+ float3 cellpos = float3(float(x), float(y), float(z)) + off;
+ float3 diff = cellpos - p;
+ if (metric == 2)
+ return math::abs(diff.x) + math::abs(diff.y) + math::abs(diff.z); // Manhattan distance
+ if (metric == 3)
+ return math::max(math::max(math::abs(diff.x), math::abs(diff.y)), math::abs(diff.z)); // Chebyshev distance
+ // Either Euclidian or Distance^2
+ return math::dot(diff, diff);
+}
+
+export float mx_worley_noise_float(float2 p, float jitter, int metric)
+{
+ float ix = math::floor(p.x);
+ float iy = math::floor(p.y);
+ int X = int(ix);
+ int Y = int(iy);
+ float2 localpos = float2(p.x-ix, p.y-iy);
+
+ float sqdist = 1e6f; // Some big number for jitter > 1 (not all GPUs may be IEEE)
+ for (int x = -1; x <= 1; ++x)
+ {
+ for (int y = -1; y <= 1; ++y)
+ {
+ float dist = mx_worley_distance2(localpos, x, y, X, Y, jitter, metric);
+ sqdist = math::min(sqdist, dist);
+ }
+ }
+ if (metric == 0)
+ sqdist = math::sqrt(sqdist);
+ return sqdist;
+}
+
+export float2 mx_worley_noise_float2(float2 p, float jitter, int metric)
+{
+ float ix = math::floor(p.x);
+ float iy = math::floor(p.y);
+ int X = int(ix);
+ int Y = int(iy);
+ float2 localpos = float2(p.x-ix, p.y-iy);
+
+ float2 sqdist = float2(1e6f, 1e6f);
+ for (int x = -1; x <= 1; ++x)
+ {
+ for (int y = -1; y <= 1; ++y)
+ {
+ float dist = mx_worley_distance2(localpos, x, y, X, Y, jitter, metric);
+ if (dist < sqdist.x)
+ {
+ sqdist.y = sqdist.x;
+ sqdist.x = dist;
+ }
+ else if (dist < sqdist.y)
+ {
+ sqdist.y = dist;
+ }
+ }
+ }
+ if (metric == 0)
+ sqdist = math::sqrt(sqdist);
+ return sqdist;
+}
+
+export float3 mx_worley_noise_float3(float2 p, float jitter, int metric)
+{
+ float ix = math::floor(p.x);
+ float iy = math::floor(p.y);
+ int X = int(ix);
+ int Y = int(iy);
+ float2 localpos = float2(p.x-ix, p.y-iy);
+
+ float3 sqdist = float3(1e6f, 1e6f, 1e6f);
+ for (int x = -1; x <= 1; ++x)
+ {
+ for (int y = -1; y <= 1; ++y)
+ {
+ float dist = mx_worley_distance2(localpos, x, y, X, Y, jitter, metric);
+ if (dist < sqdist.x)
+ {
+ sqdist.z = sqdist.y;
+ sqdist.y = sqdist.x;
+ sqdist.x = dist;
+ }
+ else if (dist < sqdist.y)
+ {
+ sqdist.z = sqdist.y;
+ sqdist.y = dist;
+ }
+ else if (dist < sqdist.z)
+ {
+ sqdist.z = dist;
+ }
+ }
+ }
+ if (metric == 0)
+ sqdist = math::sqrt(sqdist);
+ return sqdist;
+}
+
+export float mx_worley_noise_float(float3 p, float jitter, int metric)
+{
+ float ix = math::floor(p.x);
+ float iy = math::floor(p.y);
+ float iz = math::floor(p.z);
+ int X = int(ix);
+ int Y = int(iy);
+ int Z = int(iz);
+ float3 localpos = float3(p.x-ix, p.y-iy, p.z-iz);
+
+ float sqdist = 1e6f;
+ for (int x = -1; x <= 1; ++x)
+ {
+ for (int y = -1; y <= 1; ++y)
+ {
+ for (int z = -1; z <= 1; ++z)
+ {
+ float dist = mx_worley_distance3(localpos, x, y, z, X, Y, Z, jitter, metric);
+ sqdist = math::min(sqdist, dist);
+ }
+ }
+ }
+ if (metric == 0)
+ sqdist = math::sqrt(sqdist);
+ return sqdist;
+}
+
+export float2 mx_worley_noise_float2(float3 p, float jitter, int metric)
+{
+ float ix = math::floor(p.x);
+ float iy = math::floor(p.y);
+ float iz = math::floor(p.z);
+ int X = int(ix);
+ int Y = int(iy);
+ int Z = int(iz);
+ float3 localpos = float3(p.x-ix, p.y-iy, p.z-iz);
+
+ float2 sqdist = float2(1e6f, 1e6f);
+ for (int x = -1; x <= 1; ++x)
+ {
+ for (int y = -1; y <= 1; ++y)
+ {
+ for (int z = -1; z <= 1; ++z)
+ {
+ float dist = mx_worley_distance3(localpos, x, y, z, X, Y, Z, jitter, metric);
+ if (dist < sqdist.x)
+ {
+ sqdist.y = sqdist.x;
+ sqdist.x = dist;
+ }
+ else if (dist < sqdist.y)
+ {
+ sqdist.y = dist;
+ }
+ }
+ }
+ }
+ if (metric == 0)
+ sqdist = math::sqrt(sqdist);
+ return sqdist;
+}
+
+export float3 mx_worley_noise_float3(float3 p, float jitter, int metric)
+{
+ float ix = math::floor(p.x);
+ float iy = math::floor(p.y);
+ float iz = math::floor(p.z);
+ int X = int(ix);
+ int Y = int(iy);
+ int Z = int(iz);
+ float3 localpos = float3(p.x-ix, p.y-iy, p.z-iz);
+
+ float3 sqdist = float3(1e6f, 1e6f, 1e6f);
+ for (int x = -1; x <= 1; ++x)
+ {
+ for (int y = -1; y <= 1; ++y)
+ {
+ for (int z = -1; z <= 1; ++z)
+ {
+ float dist = mx_worley_distance3(localpos, x, y, z, X, Y, Z, jitter, metric);
+ if (dist < sqdist.x)
+ {
+ sqdist.z = sqdist.y;
+ sqdist.y = sqdist.x;
+ sqdist.x = dist;
+ }
+ else if (dist < sqdist.y)
+ {
+ sqdist.z = sqdist.y;
+ sqdist.y = dist;
+ }
+ else if (dist < sqdist.z)
+ {
+ sqdist.z = dist;
+ }
+ }
+ }
+ }
+ if (metric == 0)
+ sqdist = math::sqrt(sqdist);
+ return sqdist;
+}
diff --git a/Sources/MXResources/libraries/mdl/materialx/pbrlib.mdl b/Sources/MXResources/libraries/mdl/materialx/pbrlib.mdl
new file mode 100644
index 00000000..0c11ce37
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/pbrlib.mdl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// MDL implementation of all types and nodes of
+// MaterialX Physically-Based Shading Nodes
+// Document v1.37 REV2, July 16, 2019 (Revised October 17, 2019)
+// see www.materialx.org
+// in
+// NVIDIA Material Definition Language 1.8
+// Language Specification
+// Document version 1.8.2, May 24, 2023
+// www.nvidia.com/mdl
+
+mdl 1.8;
+
+// forward the latest version
+export using .::pbrlib_1_8 import *;
diff --git a/Sources/MXResources/libraries/mdl/materialx/pbrlib_1_6.mdl b/Sources/MXResources/libraries/mdl/materialx/pbrlib_1_6.mdl
new file mode 100644
index 00000000..fbd6b5c1
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/pbrlib_1_6.mdl
@@ -0,0 +1,1009 @@
+/*
+ * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// MDL implementation of all types and nodes of
+// MaterialX Physically-Based Shading Nodes
+// Document v1.37 REV2, July 16, 2019 (Revised October 17, 2019)
+// see www.materialx.org
+// in
+// NVIDIA Material Definition Language 1.6
+// Language Specification
+// Document version 1.6.1, December 16, 2019
+// www.nvidia.com/mdl
+
+mdl 1.6;
+
+import ::anno::*;
+import ::df::*;
+import ::math::*;
+import ::state::*;
+
+import .::core::*;
+import .::swizzle::*;
+
+// NOTE: We use the MDL material type to represent all PBS nodes of
+// BSDF, EDF, VDF and other MaterialX material related types.
+// To document, and possibly also support tool diagnostics, we
+// use the ::anno::usage(string) annotation to document the
+// true MaterialX type, only connections with equal usage
+// annotations are correct MaterialX connections.
+
+// NOTE: Geometric parameters like surface normal are specified in MDL internal
+// space, which is the efficient and natural way for MDL.
+// TODO: Check that the generator emits proper space transform conversion
+// calls where needed
+// TODO: Check how MaterialX unit handling works with this
+// TODO: Check if scene_units_per_meter() is applicable as well, like for displacement
+
+// NOTE: Some PBR nodes require multiple implementations with different
+// parameter types. If those require a material type as result, we
+// cannot use overlaods and must use different names. Examples are
+// mix, add, multiply, and we include displacement for orthogonality.
+
+// NOTE: Because of the BTDFs and the VDF below them, we have to take care
+// of volumetric properties in the BSDF components as well. Since IOR
+// is uniform in MDL, some nodes have a limitation on how IOR works.
+
+
+// Enum selecting scatter mode, instead of string
+export enum mx_scatter_mode {
+ mx_scatter_mode_R,
+ mx_scatter_mode_T,
+ mx_scatter_mode_RT
+};
+
+// Helper function mapping MaterialX scatter mode to MDL scatter_mode enum
+export df::scatter_mode mx_map_scatter_mode(
+ mx_scatter_mode mode
+) {
+ switch (mode) {
+ case mx_scatter_mode_R:
+ return df::scatter_reflect;
+ case mx_scatter_mode_T:
+ return df::scatter_transmit;
+ default:
+ return df::scatter_reflect_transmit;
+ }
+}
+
+export material mx_oren_nayar_diffuse_bsdf(
+ float mxp_weight = 1.0,
+ color mxp_color = color(0.18),
+ float mxp_roughness = 0.0,
+ float3 mxp_normal = state::normal()
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= material(
+ surface: material_surface(
+ scattering: df::weighted_layer(
+ weight: mxp_weight,
+ layer: df::diffuse_reflection_bsdf(
+ tint: mxp_color,
+ roughness: mxp_roughness
+ ),
+ normal: mxp_normal
+ )
+ )
+);
+
+// NOTE: Approximate Burley with df::diffuse_reflection_bsdf, the difference isn't big
+export material mx_burley_diffuse_bsdf(
+ float mxp_weight = 1.0,
+ color mxp_color = color(0.18),
+ float mxp_roughness = 0.0,
+ float3 mxp_normal = state::normal()
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= material(
+ surface: material_surface(
+ scattering: df::weighted_layer(
+ weight: mxp_weight,
+ layer: df::diffuse_reflection_bsdf(
+ tint: mxp_color,
+ roughness: mxp_roughness
+ ),
+ normal: mxp_normal
+ )
+ )
+);
+
+export material mx_translucent_bsdf(
+ float mxp_weight = 1.0,
+ color mxp_color = color(1.0),
+ float3 mxp_normal = state::normal()
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= material(
+ surface: material_surface(
+ scattering: df::weighted_layer(
+ weight: mxp_weight,
+ layer: df::diffuse_transmission_bsdf(
+ tint: mxp_color
+ ),
+ normal: mxp_normal
+ )
+ )
+);
+
+// TODO MDL 1.8
+// * will add support for thin film above a color_custom_curve_layer node until then, thin_film will have no effect
+// * thin_film(thickness: 0.0, ior: < 1.0) will be handled properly
+export material mx_dielectric_bsdf(
+ float mxp_weight = 1.0,
+ color mxp_tint = color(1.0),
+ float mxp_ior = 1.5,
+ float2 mxp_roughness = float2(0.0),
+ float3 mxp_normal = state::normal(),
+ float3 mxp_tangent = state::texture_tangent_u(0),
+ uniform core::mx_distribution_type mxp_distribution = core::mx_distribution_type_ggx [[ anno::unused() ]],
+ uniform mx_scatter_mode mxp_scatter_mode = mx_scatter_mode_R,
+ material mxp_base = material() [[ anno::usage( "materialx:bsdf") ]],
+ float mxp_thinfilm_thickness = 0.0,
+ float mxp_thinfilm_ior = 1.0
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= let {
+ float coatIor = mxp_thinfilm_ior <= 0.0 ? 1.0 : mxp_thinfilm_ior;
+ float grazing_refl = math::max((1.0 - math::average(mxp_roughness)), 0.0);
+ float root_r = (mxp_ior-1)/(mxp_ior+1);
+ bsdf bsdf_R = df::thin_film(
+ thickness: mxp_thinfilm_thickness,
+ ior: color(coatIor),
+ // fresnel layer has issues if base is a diffuse transmission, use custom curve for now
+ // this will break thin_film but improves standard_surface with diffuse transmission
+ base: df::custom_curve_layer(
+ normal_reflectivity: root_r*root_r,
+ grazing_reflectivity: grazing_refl,
+ weight: mxp_weight,
+ layer: df::microfacet_ggx_smith_bsdf(
+ roughness_u: mxp_roughness.x,
+ roughness_v: mxp_roughness.y,
+ tint: mxp_tint,
+ tangent_u: mxp_tangent,
+ mode: df::scatter_reflect),
+ base: mxp_base.surface.scattering,
+ normal: mxp_normal));
+
+ bsdf bsdf_T = df::weighted_layer(
+ weight: mxp_weight,
+ layer: df::microfacet_ggx_smith_bsdf(
+ roughness_u: mxp_roughness.x,
+ roughness_v: mxp_roughness.y,
+ tint: mxp_tint,
+ tangent_u: mxp_tangent,
+ mode: df::scatter_transmit),
+ normal: mxp_normal);
+
+ bsdf bsdf_RT = df::weighted_layer(
+ weight: mxp_weight,
+ layer: df::thin_film(
+ thickness: mxp_thinfilm_thickness,
+ ior: color(coatIor),
+ base: df::microfacet_ggx_smith_bsdf(
+ roughness_u: mxp_roughness.x,
+ roughness_v: mxp_roughness.y,
+ tint: mxp_tint,
+ tangent_u: mxp_tangent,
+ mode: df::scatter_reflect_transmit)),
+ normal: mxp_normal);
+
+ bsdf bsdf_selected = (mxp_scatter_mode == mx_scatter_mode_R) ? bsdf_R :
+ ((mxp_scatter_mode == mx_scatter_mode_T) ? bsdf_T : bsdf_RT);
+} in material(
+ surface: material_surface(
+ scattering: bsdf_selected
+ ),
+ // we need to carry volume properties along for SSS
+ ior: mxp_base.ior,
+ volume: mxp_base.volume
+);
+
+// TODO MDL 1.8
+// * thin_film(thickness: 0.0, ior: < 1.0) will be handled properly
+export material mx_conductor_bsdf(
+ float mxp_weight = 1.0,
+ color mxp_ior = color(0.18, 0.42, 1.37),
+ color mxp_extinction = color(3.42, 2.35, 1.77),
+ float2 mxp_roughness = float2(0.0),
+ float3 mxp_normal = state::normal(),
+ float3 mxp_tangent = state::texture_tangent_u(0),
+ uniform core::mx_distribution_type mxp_distribution = core::mx_distribution_type_ggx [[ anno::unused() ]],
+ float mxp_thinfilm_thickness = 0.0,
+ float mxp_thinfilm_ior = 1.0
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= let {
+ float coatIor = mxp_thinfilm_ior <= 0.0 ? 1.0 : mxp_thinfilm_ior;
+ bsdf ggx_model = df::microfacet_ggx_smith_bsdf(
+ roughness_u: mxp_roughness.x,
+ roughness_v: mxp_roughness.y,
+ tangent_u: mxp_tangent);
+ bsdf conductor = df::fresnel_factor(
+ ior: mxp_ior,
+ extinction_coefficient: mxp_extinction,
+ base: ggx_model);
+ bsdf thin_film_conductor = df::thin_film(
+ thickness: mxp_thinfilm_thickness,
+ ior: color(coatIor),
+ base: conductor);
+} in material(
+ surface: material_surface(
+ scattering: df::weighted_layer(
+ weight: mxp_weight,
+ layer: thin_film_conductor,
+ normal: mxp_normal
+ )
+ )
+);
+
+// TODO MDL 1.8
+// * will add support for thin film above a color_custom_curve_layer node until then, thin_film will have no effect
+// * thin_film(thickness: 0.0, ior: < 1.0) will be handled properly
+export material mx_generalized_schlick_bsdf(
+ float mxp_weight = 1.0,
+ color mxp_color0 = color(1.0),
+ color mxp_color90 = color(1.0),
+ float mxp_exponent = 5.0,
+ float2 mxp_roughness = float2(0.05),
+ float3 mxp_normal = state::normal(),
+ float3 mxp_tangent = state::texture_tangent_u(0),
+ uniform core::mx_distribution_type mxp_distribution = core::mx_distribution_type_ggx [[ anno::unused() ]],
+ uniform mx_scatter_mode mxp_scatter_mode = mx_scatter_mode_R,
+ material mxp_base = material() [[ anno::usage( "materialx:bsdf") ]],
+ float mxp_thinfilm_thickness = 0.0,
+ float mxp_thinfilm_ior = 1.0
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= let {
+ float coatIor = mxp_thinfilm_ior <= 0.0 ? 1.0 : mxp_thinfilm_ior;
+ // float avgF0 = math::average(float3(mxp_color0));
+ bsdf ggx_model_R = df::microfacet_ggx_smith_bsdf(
+ roughness_u: mxp_roughness.x,
+ roughness_v: mxp_roughness.y,
+ tint: color(1.0),
+ tangent_u: mxp_tangent,
+ mode: df::scatter_reflect);
+
+ bsdf ggx_model_T = df::microfacet_ggx_smith_bsdf(
+ roughness_u: mxp_roughness.x,
+ roughness_v: mxp_roughness.y,
+ tint: color(1.0),
+ tangent_u: mxp_tangent,
+ mode: df::scatter_transmit);
+} in material(
+ surface: material_surface(
+ scattering: df::weighted_layer(
+ weight: mxp_weight,
+ layer: mxp_scatter_mode == mx_scatter_mode_T
+ ? df::color_custom_curve_layer(
+ normal_reflectivity: mxp_color0,
+ grazing_reflectivity: mxp_color90,
+ exponent: mxp_exponent,
+ layer: bsdf(),
+ base: ggx_model_T)
+ : df::thin_film(
+ thickness: mxp_thinfilm_thickness,
+ ior: color(coatIor),
+ base: df::color_custom_curve_layer(
+ normal_reflectivity: mxp_color0,
+ grazing_reflectivity: mxp_color90,
+ exponent: mxp_exponent,
+ layer: ggx_model_R,
+ base: mxp_scatter_mode == mx_scatter_mode_R
+ ? mxp_base.surface.scattering
+ : ggx_model_T)),
+ base: mxp_base.surface.scattering,
+ normal: mxp_normal
+ )
+ ),
+ // we can't use the computed ior here because it's varying
+ // assuming that we have something glass like when transmission is used
+ ior: color(1.5), // color(mx_f0_to_ior(avgF0))
+
+ // we need to carry volume properties along for SSS
+ volume: mxp_base.volume
+);
+
+export material mx_subsurface_bsdf(
+ float mxp_weight = 1.0 [[ anno::unused() ]],
+ color mxp_color = color(0.18),
+ float3 mxp_radius = float3(1.0), // TODO: should probably be a color in MTLX Spec
+ float mxp_anisotropy = 0.0,
+ float3 mxp_normal = state::normal() [[ anno::unused() ]]
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= let {
+ // https://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_slides_v2.pdf
+ // Phase function eccentricity 'g' has been omitted here since we pass that directly
+ // to anisotropic_vdf(directional_bias: g).
+ color albedo = color(4.09712) +
+ (4.20863f * mxp_color) -
+ math::sqrt(
+ 9.59217f +
+ 41.6808f * mxp_color +
+ 17.7126f * mxp_color * mxp_color);
+
+ color albedo_sq = albedo * albedo;
+
+ color white = color(1.0, 1.0, 1.0);
+
+ color alpha =
+ (white - albedo_sq) / (white - mxp_anisotropy * albedo_sq);
+
+ color radius_inv = white/color(mxp_radius);
+
+ color sigma_s = alpha * radius_inv;
+ color sigma_a = radius_inv - sigma_s;
+
+} in material(
+ volume: material_volume(
+ scattering: df::anisotropic_vdf (
+ directional_bias: mxp_anisotropy
+ ),
+ scattering_coefficient: sigma_s,
+ absorption_coefficient: sigma_a
+ ),
+
+ surface: material_surface(
+ scattering: df::diffuse_transmission_bsdf(tint: white)
+ )
+);
+
+// TODO: MDL's sheen BSDF has no possibility to configure the base BSDF, it is
+// always a diffuse BSDF. Its color is configurable through the multiscatter
+// tint and can be fed through the extra mxp_diffuse_tint input. A context
+// analysis in the generator can map the color of the base to this input.
+export material mx_sheen_bsdf(
+ float mxp_weight = 1.0,
+ color mxp_color = color(1.0),
+ float mxp_roughness = 0.2,
+ float3 mxp_normal = state::normal(),
+ material mxp_base = material() [[ anno::usage( "materialx:bsdf") ]],
+ color mxp_diffuse_color = color(1.0) // color of the base layer, MDL supports only diffuse
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= material(
+ surface: material_surface(
+ scattering: df::weighted_layer(
+ weight: mxp_weight,
+ layer: df::sheen_bsdf(
+ roughness: mxp_roughness,
+ tint: mxp_color,
+ multiscatter_tint: mxp_diffuse_color
+ ),
+ base: mxp_base.surface.scattering,
+ normal: mxp_normal
+ )
+ ),
+ // we need to carry volume properties along for SSS
+ ior: mxp_base.ior,
+ volume: mxp_base.volume
+);
+
+export material mx_thin_film_bsdf(
+ float mxp_thickness = 1000.0,
+ float mxp_ior = 1.5,
+ material mxp_base = material() [[ anno::usage( "materialx:bsdf") ]]
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= material(
+ surface: material_surface(
+ scattering: df::thin_film(
+ thickness: mxp_thickness,
+ ior: color(mxp_ior),
+ base: mxp_base.surface.scattering
+ )
+ ),
+ // we need to carry volume properties along for SSS
+ ior: mxp_base.ior,
+ volume: mxp_base.volume
+);
+
+// EDF Nodes
+
+export material mx_uniform_edf(
+ color mxp_color = color(1.0)
+) [[
+ anno::usage( "materialx:edf")
+]]
+= material(
+ surface: material_surface(
+ emission: material_emission( emission: df::diffuse_edf(), intensity: mxp_color * math::PI)
+ )
+);
+
+export material mx_conical_edf(
+ color mxp_color = color(1.0),
+ float3 mxp_normal = state::normal()
+ [[
+ anno::unused()
+ ]],
+ uniform float mxp_inner_angle = 60.0,
+ uniform float mxp_outer_angle = 0.0
+) [[
+ anno::usage( "materialx:edf")
+]]
+= material(
+ surface: material_surface(
+ emission: material_emission(
+ emission: df::spot_edf( // TODO: refine exact math of the mapping here
+ spread: math::radians( math::max(mxp_inner_angle, mxp_outer_angle)),
+ exponent: (mxp_outer_angle <= mxp_inner_angle) ? 0.0 : 1.0
+ ),
+ intensity: mxp_color * math::PI
+ )
+ )
+);
+
+export material mx_measured_edf(
+ color mxp_color = color(1.0),
+ float3 mxp_normal = state::normal()
+ [[
+ anno::unused()
+ ]],
+ uniform light_profile mxp_file = light_profile()
+) [[
+ anno::usage( "materialx:edf")
+]]
+= material(
+ surface: material_surface(
+ emission: material_emission(
+ emission: df::measured_edf( profile: mxp_file),
+ intensity: mxp_color * math::PI
+ )
+ )
+);
+
+// no directional factor for EDFs in MDL 1.6
+export material mx_generalized_schlick_edf(
+ color mxp_color0 = color(1.0) [[anno::unused()]],
+ color mxp_color90 = color(1.0) [[anno::unused()]],
+ float mxp_exponent = 5.0 [[anno::unused()]],
+ material mxp_base = material() [[ anno::usage( "materialx:bsdf") ]]
+) [[
+ anno::usage( "materialx:edf")
+]]
+= material(
+ thin_walled: mxp_base.thin_walled,
+ surface: material_surface(
+ scattering: mxp_base.surface.scattering,
+ emission: mxp_base.surface.emission
+ ),
+ backface: mxp_base.backface,
+ ior: mxp_base.ior,
+ volume: mxp_base.volume,
+ geometry: mxp_base.geometry,
+ hair: mxp_base.hair
+);
+
+// VDF Nodes
+
+export material mx_absorption_vdf(
+ // TODO: should probably become color3 in the MaterialX spec
+ float3 mxp_absorption = float3(0.0)
+) [[
+ anno::usage( "materialx:vdf")
+]]
+= material(
+ volume: material_volume(
+ absorption_coefficient: color( mxp_absorption)
+ )
+);
+
+export material mx_anisotropic_vdf(
+ // TODO: should probably become color3 in the MaterialX spec
+ float3 mxp_absorption = float3(0.0),
+ // TODO: should probably become color3 in the MaterialX spec
+ float3 mxp_scattering = float3(0.0),
+ float mxp_anisotropy = 0.0
+) [[
+ anno::usage( "materialx:vdf")
+]]
+= material(
+ volume: material_volume(
+ scattering: df::anisotropic_vdf( directional_bias: mxp_anisotropy),
+ absorption_coefficient: color( mxp_absorption),
+ scattering_coefficient: color( mxp_scattering)
+ )
+);
+
+// Shader Nodes
+
+// NOTE: The MDL material with thin_walled == false uses the same material_surface
+// properties for the front- and backface, the material will not be black
+// from the backside as mandated by the MaterialX spec.
+export material mx_surface(
+ material mxp_bsdf = material() [[ anno::usage( "materialx:bsdf") ]],
+ material mxp_edf = material() [[ anno::usage( "materialx:edf") ]],
+ float mxp_opacity = 1.0,
+ uniform float mxp_transmission_ior = 0.0 // extra parameter for setting transmission IOR
+) [[
+ anno::usage( "materialx:surfaceshader")
+]]
+= let {
+ bsdf bsdf_node = mxp_bsdf.surface.scattering;
+ material_emission edf_node = mxp_edf.surface.emission;
+ // we need to carry volume properties along for SSS
+ material_volume bsdf_volume = mxp_bsdf.volume;
+} in material(
+ thin_walled: false,
+ surface: material_surface(
+ scattering: bsdf_node,
+ emission: edf_node
+ ),
+ ior: mxp_transmission_ior > 0.0 ? color(mxp_transmission_ior) : mxp_bsdf.ior,
+ volume: bsdf_volume,
+ geometry: material_geometry(
+ cutout_opacity: mxp_opacity
+ )
+);
+
+export material mx_thin_surface(
+ material mxp_front_bsdf = material() [[ anno::usage( "materialx:bsdf") ]],
+ material mxp_front_edf = material() [[ anno::usage( "materialx:edf") ]],
+ material mxp_back_bsdf = material() [[ anno::usage( "materialx:bsdf") ]],
+ material mxp_back_edf = material() [[ anno::usage( "materialx:edf") ]],
+ float mxp_opacity = 1.0
+) [[
+ anno::usage( "materialx:surfaceshader")
+]]
+= let {
+ bsdf front_bsdf_node = mxp_front_bsdf.surface.scattering;
+ material_emission front_edf_node = mxp_front_edf.surface.emission;
+ bsdf back_bsdf_node = mxp_back_bsdf.surface.scattering;
+ material_emission back_edf_node = mxp_back_edf.surface.emission;
+ // we need to carry volume properties along for SSS
+ // TODO: clarify SSS behavior in MaterialX for thin-walled surfaces,
+ // in MDL there is only one volume property
+ material_volume bsdf_volume = mxp_front_bsdf.volume;
+} in material(
+ thin_walled: true,
+ surface: material_surface(
+ scattering: front_bsdf_node,
+ emission: front_edf_node
+ ),
+ backface: material_surface(
+ scattering: back_bsdf_node,
+ emission: back_edf_node
+ ),
+ ior: color(1.0),
+ volume: bsdf_volume,
+ geometry: material_geometry(
+ cutout_opacity: mxp_opacity
+ )
+);
+
+// MDL 1.6, Volumes do not support emission.
+export material mx_volume(
+ material mxp_vdf = material() [[ anno::usage( "materialx:vdf") ]],
+ material mxp_edf = material() [[ anno::usage( "materialx:edf"), anno::unused() ]]
+) [[
+ anno::usage( "materialx:volumeshader")
+]]
+= material(
+ volume: material_volume(
+ absorption_coefficient: mxp_vdf.volume.absorption_coefficient,
+ scattering_coefficient: mxp_vdf.volume.scattering_coefficient
+ )
+);
+
+export material mx_light(
+ material mxp_edf = material() [[ anno::usage( "materialx:edf") ]],
+ color mxp_intensity = color(1.0),
+ float mxp_exposure = 0.0
+) [[
+ anno::usage( "materialx:lightshader")
+]]
+= let {
+ edf emission = mxp_edf.surface.emission.emission;
+ color intensity = mxp_edf.surface.emission.intensity;
+ color scale = (mxp_exposure == 0.0)
+ ? mxp_intensity
+ : mxp_intensity * math::pow(2, mxp_exposure);
+} in material(
+ // TODO: check MTLX spec if we need emission on front- end backface
+ surface: material_surface(
+ emission: material_emission(
+ emission: emission,
+ intensity: intensity * scale
+ )
+ )
+);
+
+// NOTE: MDL provides function overloading, but not material definition
+// overlaoding. We thus try to use float3 as MDL type matching
+// the MaterialX displacementshader and allow thus for an overloaded
+// implementation of mxp_displacement.
+// TODO: Check if this works in the translator and higher level nodes, like
+// mxp_material, if not, we have to switch to the material type and
+// use two different names for mxp_displacemnnt.
+export material mx_displacement_float(
+ float mxp_displacement = 0.0,
+ float mxp_scale = 1.0
+) [[
+ anno::usage( "materialx:displacementshader")
+]] = material(
+ geometry: material_geometry(
+ displacement: mxp_displacement * mxp_scale * state::scene_units_per_meter() * state::normal()
+ )
+);
+
+export material mx_displacement_vector3(
+ float3 mxp_displacement = float3(0.0),
+ float mxp_scale = 1.0
+) [[
+ anno::usage( "materialx:displacementshader")
+]] = let
+{
+ float3 vec = (mxp_displacement.x * state::texture_tangent_u(0)
+ + mxp_displacement.y * state::texture_tangent_v(0)
+ + mxp_displacement.z * state::normal());
+} in material(
+ geometry: material_geometry(
+ displacement: vec * mxp_scale * state::scene_units_per_meter()
+ )
+);
+
+
+// helper function to mix two scattering volumes:
+// - combined scattering coefficient is just the sum of the two
+// - VDF mixer weight is the relative probability of encountering the corresponding
+// particle type
+// NOTE: mixer weight should be a color, but due to a bug in current MDL compilers
+// the color mixers don't accept non-uniform weights yet
+export struct volume_mix_return {
+ color scattering_coefficient;
+ float mix_weight1; // mix_weight2 = 1.0 - mix_weight1, can use any mixer
+};
+export volume_mix_return volume_mix(
+ color scattering_coefficient1,
+ float weight1,
+ color scattering_coefficient2,
+ float weight2)
+{
+ color s1 = weight1 * scattering_coefficient1;
+ color s = s1 + weight2 * scattering_coefficient2;
+ return volume_mix_return(scattering_coefficient: s, mix_weight1: math::average(s1 / s));
+}
+
+export material mx_mix_bsdf(
+ material mxp_fg = material() [[ anno::usage( "materialx:bsdf") ]],
+ material mxp_bg = material() [[ anno::usage( "materialx:bsdf") ]],
+ float mxp_mix = 0.0
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= let {
+ float mix = math::saturate(mxp_mix);
+ volume_mix_return v = volume_mix(
+ mxp_fg.volume.scattering_coefficient, mix,
+ mxp_bg.volume.scattering_coefficient, (1.0f - mix));
+} in material(
+ surface: material_surface(
+ scattering: df::weighted_layer(
+ weight: mix,
+ layer: mxp_fg.surface.scattering,
+ base: mxp_bg.surface.scattering
+ )
+ ),
+ // we need to carry volume properties along for SSS
+ ior: mxp_fg.ior, // NOTE: IOR is uniform, cannot mix here
+ volume: material_volume(
+ scattering: df::clamped_mix(
+ df::vdf_component[](
+ df::vdf_component(v.mix_weight1, mxp_fg.volume.scattering),
+ df::vdf_component(1.0 - v.mix_weight1, mxp_bg.volume.scattering))
+ ),
+ absorption_coefficient: mix * mxp_fg.volume.absorption_coefficient +
+ (1.0 - mix) * mxp_bg.volume.absorption_coefficient,
+ scattering_coefficient: v.scattering_coefficient
+ )
+);
+
+// NOTE: mixing two EDFs fails with the df::clamped_mix since the weights are uniform in MDL 1.6
+export material mx_mix_edf(
+ material mxp_fg = material() [[ anno::usage( "materialx:edf") ]],
+ material mxp_bg = material() [[ anno::usage( "materialx:edf") ]],
+ float mxp_mix = 0.0
+) [[
+ anno::usage( "materialx:edf")
+]]
+= let {
+ float mix = math::saturate(mxp_mix);
+} in material(
+ surface: material_surface(
+ emission: material_emission(
+ emission: mxp_fg.surface.emission.emission,
+ intensity: mix * mxp_fg.surface.emission.intensity +
+ (1.0 - mix) * mxp_bg.surface.emission.intensity
+ )
+ )
+);
+
+export material mx_mix_vdf(
+ material mxp_fg = material() [[ anno::usage( "materialx:vdf") ]],
+ material mxp_bg = material() [[ anno::usage( "materialx:vdf") ]],
+ float mxp_mix = 0.0
+) [[
+ anno::usage( "materialx:vdf")
+]]
+= let {
+ float mix = math::saturate(mxp_mix);
+ volume_mix_return v = volume_mix(
+ mxp_fg.volume.scattering_coefficient, mix,
+ mxp_bg.volume.scattering_coefficient, (1.0f - mix));
+} in material(
+ ior: mxp_fg.ior, // NOTE: IOR is uniform, cannot mix here
+ volume: material_volume(
+ scattering: df::clamped_mix(
+ df::vdf_component[](
+ df::vdf_component( v.mix_weight1, mxp_fg.volume.scattering),
+ df::vdf_component( 1.0 - v.mix_weight1, mxp_bg.volume.scattering))
+ ),
+ absorption_coefficient: mix * mxp_fg.volume.absorption_coefficient +
+ (1.0 - mix) * mxp_bg.volume.absorption_coefficient,
+ scattering_coefficient: v.scattering_coefficient
+ )
+);
+
+// NOTE: Adding two BSDFs is not supported in MDL, the generator would best
+// analyze the context for mixing weights and replace the add with a mix.
+// The provided implementation just mixes the BSDFs with equal weight.
+export material mx_add_bsdf(
+ material mxp_in1 = material() [[ anno::usage( "materialx:bsdf") ]],
+ material mxp_in2 = material() [[ anno::usage( "materialx:bsdf") ]]
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= let {
+ volume_mix_return v = volume_mix(
+ mxp_in1.volume.scattering_coefficient, 1.0f,
+ mxp_in2.volume.scattering_coefficient, 1.0f);
+} in material(
+ surface: material_surface(
+ scattering: df::clamped_mix(
+ df::bsdf_component[](
+ df::bsdf_component( 0.5, mxp_in1.surface.scattering),
+ df::bsdf_component( 0.5, mxp_in2.surface.scattering)
+ )
+ )
+ ),
+ // we need to carry volume properties along for SSS
+ volume: material_volume(
+ scattering: df::clamped_mix(
+ df::vdf_component[](
+ df::vdf_component( v.mix_weight1, mxp_in1.volume.scattering),
+ df::vdf_component( 1.0 - v.mix_weight1, mxp_in2.volume.scattering))
+ ),
+ absorption_coefficient: mxp_in1.volume.absorption_coefficient +
+ mxp_in2.volume.absorption_coefficient,
+ scattering_coefficient: v.scattering_coefficient
+ )
+);
+
+// NOTE: Adding two EDFs is not supported in MDL, the generator would best
+// analyze the context for mixing weights and replace the add with a mix.
+// The provided implementation just mixes the EDFs with equal weight
+// and adds the intensities.
+export material mx_add_edf(
+ material mxp_in1 = material() [[ anno::usage( "materialx:edf") ]],
+ material mxp_in2 = material() [[ anno::usage( "materialx:edf") ]]
+) [[
+ anno::usage( "materialx:edf")
+]]
+= material(
+ surface: material_surface(
+ emission: material_emission(
+ emission: df::clamped_mix(
+ df::edf_component[](
+ df::edf_component( 0.5, mxp_in1.surface.emission.emission),
+ df::edf_component( 0.5, mxp_in2.surface.emission.emission))
+ ),
+ intensity: mxp_in1.surface.emission.intensity + mxp_in2.surface.emission.intensity
+ )
+ )
+);
+
+// NOTE: Adding two VDFs is not supported in MDL, the generator would best
+// analyze the context for mixing weights and replace the add with a mix.
+// The provided implementation just mixes the VDFs with equal weight.
+export material mx_add_vdf(
+ material mxp_in1 = material() [[ anno::usage( "materialx:vdf") ]],
+ material mxp_in2 = material() [[ anno::usage( "materialx:vdf") ]]
+) [[
+ anno::usage( "materialx:vdf")
+]]
+= let {
+ volume_mix_return v = volume_mix(
+ mxp_in1.volume.scattering_coefficient, 1.0f,
+ mxp_in2.volume.scattering_coefficient, 1.0f);
+} in material(
+ // assuming mixing the IOR is the best we can do here
+ ior: 0.5 * mxp_in1.ior + 0.5 * mxp_in2.ior,
+ volume: material_volume(
+ scattering: df::clamped_mix(
+ df::vdf_component[](
+ df::vdf_component( v.mix_weight1, mxp_in1.volume.scattering),
+ df::vdf_component( 1.0 - v.mix_weight1, mxp_in2.volume.scattering))
+ ),
+ absorption_coefficient: mxp_in1.volume.absorption_coefficient +
+ mxp_in2.volume.absorption_coefficient,
+ scattering_coefficient: v.scattering_coefficient
+ )
+);
+
+export material mx_multiply_bsdf_color3(
+ material mxp_in1 = material() [[ anno::usage( "materialx:bsdf") ]],
+ color mxp_in2 = color(1.0)
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= material(
+ surface: material_surface(
+ scattering: df::tint(
+ tint: mxp_in2,
+ base: mxp_in1.surface.scattering
+ )
+ ),
+ // we need to carry volume properties along for SSS
+ ior: mxp_in1.ior,
+ volume: mxp_in1.volume
+);
+
+export material mx_multiply_bsdf_float(
+ material mxp_in1 = material() [[ anno::usage( "materialx:bsdf") ]],
+ float mxp_in2 = 1.0
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= material(
+ surface: material_surface(
+ scattering: df::tint(
+ tint: color(mxp_in2),
+ base: mxp_in1.surface.scattering
+ )
+ ),
+ // we need to carry volume properties along for SSS
+ ior: mxp_in1.ior,
+ volume: mxp_in1.volume
+);
+
+export material mx_multiply_edf_color3(
+ material mxp_in1 = material() [[ anno::usage( "materialx:edf") ]],
+ color mxp_in2 = color(1.0)
+) [[
+ anno::usage( "materialx:edf")
+]]
+= material(
+ surface: material_surface(
+ emission: material_emission(
+ emission: mxp_in1.surface.emission.emission,
+ intensity: mxp_in2 * mxp_in1.surface.emission.intensity
+ )
+ )
+);
+
+export material mx_multiply_edf_float(
+ material mxp_in1 = material() [[ anno::usage( "materialx:edf") ]],
+ float mxp_in2 = 1.0
+) [[
+ anno::usage( "materialx:edf")
+]]
+= material(
+ surface: material_surface(
+ emission: material_emission(
+ emission: mxp_in1.surface.emission.emission,
+ intensity: mxp_in2 * mxp_in1.surface.emission.intensity
+ )
+ )
+);
+
+export material mx_multiply_vdf_color3(
+ material mxp_in1 = material() [[ anno::usage( "materialx:vdf") ]],
+ color mxp_in2 = color(1.0)
+) [[
+ anno::usage( "materialx:vdf")
+]]
+= material(
+ ior: mxp_in1.ior,
+ volume: material_volume(
+ scattering: mxp_in1.volume.scattering,
+ absorption_coefficient: color(1.0)
+ - mxp_in2 * (color(1.0) - mxp_in1.volume.absorption_coefficient),
+ scattering_coefficient: mxp_in2 * mxp_in1.volume.scattering_coefficient
+ )
+);
+
+export material mx_multiply_vdf_float(
+ material mxp_in1 = material() [[ anno::usage( "materialx:vdf") ]],
+ float mxp_in2 = 1.0
+) [[
+ anno::usage( "materialx:vdf")
+]]
+= material(
+ ior: mxp_in1.ior,
+ volume: material_volume(
+ scattering: mxp_in1.volume.scattering,
+ absorption_coefficient: color(1.0)
+ - mxp_in2 * (color(1.0) - mxp_in1.volume.absorption_coefficient),
+ scattering_coefficient: mxp_in2 * mxp_in1.volume.scattering_coefficient
+ )
+);
+
+export float2 mx_roughness_anisotropy(
+ float mxp_roughness = 0.0,
+ float mxp_anisotropy = 0.0
+) {
+ float roughness_sqr = math::clamp(mxp_roughness*mxp_roughness, core::FLOAT_EPS, 1.0);
+ if (mxp_anisotropy > 0.0)
+ {
+ float aspect = math::sqrt(1.0 - math::clamp(mxp_anisotropy, 0.0, 0.98));
+ return float2(
+ math::min(roughness_sqr / aspect, 1.0),
+ roughness_sqr * aspect);
+ }
+ return float2(roughness_sqr);
+}
+
+export float2 mx_roughness_dual(
+ float2 mxp_roughness = float2(0.0)
+) {
+ if (mxp_roughness.y < 0.0)
+ mxp_roughness.y = mxp_roughness.x;
+ return float2(
+ math::clamp(mxp_roughness.x * mxp_roughness.x, core::FLOAT_EPS, 1.0),
+ math::clamp(mxp_roughness.y * mxp_roughness.y, core::FLOAT_EPS, 1.0));
+}
+
+export color mx_blackbody(
+ float mxp_temperature = 5000
+) {
+ return math::blackbody( mxp_temperature);
+}
+
+// Supportive struct type for the two outputs of mx_artistic_ior
+export struct mx_artistic_ior__result {
+ color mxp_ior;
+ color mxp_extinction;
+};
+
+// Converts the artistic parameterization reflectivity and edgecolor
+// to complex IOR values; this is the inverse of the ​complex_ior​ node.
+export mx_artistic_ior__result mx_artistic_ior(
+ color mxp_reflectivity = color(0.947, 0.776, 0.371),
+ color mxp_edge_color = color(1.0, 0.982, 0.753)
+) {
+ color r = math::clamp( mxp_reflectivity, color(0.0), color(0.99));
+ color r_sqrt = math::sqrt(r);
+ color n_min = (1.0 - r) / (1.0 + r);
+ color n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt);
+ color n = math::lerp(n_max, n_min, mxp_edge_color);
+ color np1 = n + 1.0;
+ color nm1 = n - 1.0;
+ color k2 = (np1*np1 * r - nm1*nm1) / (1.0 - r);
+ k2 = math::max(k2, 0.0);
+ color k = math::sqrt(k2);
+ return mx_artistic_ior__result(n,k);
+}
diff --git a/Sources/MXResources/libraries/mdl/materialx/pbrlib_1_7.mdl b/Sources/MXResources/libraries/mdl/materialx/pbrlib_1_7.mdl
new file mode 100644
index 00000000..e7e5526c
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/pbrlib_1_7.mdl
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// MDL implementation of all types and nodes of
+// MaterialX Physically-Based Shading Nodes
+// Document v1.37 REV2, July 16, 2019 (Revised October 17, 2019)
+// see www.materialx.org
+// in
+// NVIDIA Material Definition Language 1.7
+// Language Specification
+// Document version 1.7.2, January 17, 2022
+// www.nvidia.com/mdl
+
+mdl 1.7;
+
+// Changes since MDL 1.6
+// - Support for unbounded_mix to implement add_bsdf, add_edf, and add_vdf
+// - Support for df::sheen_bsdf with a custom base BSDF
+// - Support for df::directional_factor on EDFs to implement generalized_schlick_edf
+// - Support for emission on VDFs
+
+import ::anno::*;
+import ::df::*;
+import ::math::*;
+import ::state::*;
+
+// forward all unchanged definitions from the previous version
+export using .::pbrlib_1_6 import mx_scatter_mode;
+export using .::pbrlib_1_6 import mx_map_scatter_mode;
+export using .::pbrlib_1_6 import mx_oren_nayar_diffuse_bsdf;
+export using .::pbrlib_1_6 import mx_burley_diffuse_bsdf;
+export using .::pbrlib_1_6 import mx_translucent_bsdf;
+export using .::pbrlib_1_6 import mx_dielectric_bsdf;
+export using .::pbrlib_1_6 import mx_conductor_bsdf;
+export using .::pbrlib_1_6 import mx_generalized_schlick_bsdf;
+export using .::pbrlib_1_6 import mx_subsurface_bsdf;
+export using .::pbrlib_1_6 import mx_thin_film_bsdf;
+export using .::pbrlib_1_6 import mx_uniform_edf;
+export using .::pbrlib_1_6 import mx_conical_edf;
+export using .::pbrlib_1_6 import mx_measured_edf;
+export using .::pbrlib_1_6 import mx_absorption_vdf;
+export using .::pbrlib_1_6 import mx_anisotropic_vdf;
+export using .::pbrlib_1_6 import mx_surface;
+export using .::pbrlib_1_6 import mx_thin_surface;
+export using .::pbrlib_1_6 import mx_light;
+export using .::pbrlib_1_6 import mx_displacement_float;
+export using .::pbrlib_1_6 import mx_displacement_vector3;
+export using .::pbrlib_1_6 import volume_mix_return;
+export using .::pbrlib_1_6 import volume_mix;
+export using .::pbrlib_1_6 import mx_mix_bsdf;
+export using .::pbrlib_1_6 import mx_mix_vdf;
+export using .::pbrlib_1_6 import mx_multiply_bsdf_color3;
+export using .::pbrlib_1_6 import mx_multiply_bsdf_float;
+export using .::pbrlib_1_6 import mx_multiply_edf_color3;
+export using .::pbrlib_1_6 import mx_multiply_edf_float;
+export using .::pbrlib_1_6 import mx_multiply_vdf_color3;
+export using .::pbrlib_1_6 import mx_multiply_vdf_float;
+export using .::pbrlib_1_6 import mx_roughness_anisotropy;
+export using .::pbrlib_1_6 import mx_roughness_dual;
+export using .::pbrlib_1_6 import mx_blackbody;
+export using .::pbrlib_1_6 import mx_artistic_ior__result ;
+export using .::pbrlib_1_6 import mx_artistic_ior;
+
+
+
+// To match with OSL, the sheen weight is scaled with average color as approximation of albedo.
+// OSL uses the layer operator which mixes based on albedo.
+export material mx_sheen_bsdf(
+ float mxp_weight = 1.0,
+ color mxp_color = color(1.0),
+ float mxp_roughness = 0.2,
+ float3 mxp_normal = state::normal(),
+ material mxp_base = material(
+ surface: material_surface(
+ scattering: df::diffuse_reflection_bsdf(
+ ))) [[ anno::usage( "materialx:bsdf") ]]
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= material(
+ surface: material_surface(
+ // using the mix seems to fit OSL best, at least in the test cases
+ scattering: df::weighted_layer(
+ weight: math::average(mxp_color) * mxp_weight,
+ layer: df::sheen_bsdf(
+ roughness: mxp_roughness,
+ tint: mxp_color,
+ multiscatter_tint: color(1.0),
+ multiscatter: mxp_base.surface.scattering
+ ),
+ base: mxp_base.surface.scattering,
+ normal: mxp_normal)),
+ // we need to carry volume properties along for SSS
+ ior: mxp_base.ior,
+ volume: mxp_base.volume
+);
+
+
+// NOTE: Adding two BSDFs is not supported in MDL, the generator would best
+// analyze the context for mixing weights and replace the add with a mix.
+// The provided implementation just mixes the BSDFs with equal weight.
+export material mx_add_bsdf(
+ material mxp_in1 = material() [[ anno::usage( "materialx:bsdf") ]],
+ material mxp_in2 = material() [[ anno::usage( "materialx:bsdf") ]]
+) [[
+ anno::usage( "materialx:bsdf")
+]]
+= let {
+ volume_mix_return v = volume_mix(
+ mxp_in1.volume.scattering_coefficient, 1.0f,
+ mxp_in2.volume.scattering_coefficient, 1.0f);
+} in material(
+ surface: material_surface(
+ scattering: df::unbounded_mix(
+ df::bsdf_component[](
+ df::bsdf_component( 1.0, mxp_in1.surface.scattering),
+ df::bsdf_component( 1.0, mxp_in2.surface.scattering)
+ )
+ )
+ ),
+ // we need to carry volume properties along for SSS
+ volume: material_volume(
+ scattering: df::unbounded_mix(
+ df::vdf_component[](
+ df::vdf_component( v.mix_weight1, mxp_in1.volume.scattering),
+ df::vdf_component( 1.0 - v.mix_weight1, mxp_in2.volume.scattering))
+ ),
+ absorption_coefficient: mxp_in1.volume.absorption_coefficient +
+ mxp_in2.volume.absorption_coefficient,
+ scattering_coefficient: v.scattering_coefficient
+ )
+);
+
+// NOTE: Adding two EDFs is not supported in MDL, the generator would best
+// analyze the context for mixing weights and replace the add with a mix.
+// The provided implementation just mixes the EDFs with equal weight
+// and adds the intensities.
+export material mx_add_edf(
+ material mxp_in1 = material() [[ anno::usage( "materialx:edf") ]],
+ material mxp_in2 = material() [[ anno::usage( "materialx:edf") ]]
+) [[
+ anno::usage( "materialx:edf")
+]]
+= material(
+ surface: material_surface(
+ emission: material_emission(
+ emission: df::unbounded_mix(
+ df::edf_component[](
+ df::edf_component( 1.0, mxp_in1.surface.emission.emission),
+ df::edf_component( 1.0, mxp_in2.surface.emission.emission))
+ ),
+ intensity: mxp_in1.surface.emission.intensity + mxp_in2.surface.emission.intensity
+ )
+ )
+);
+
+export material mx_mix_edf(
+ material mxp_fg = material() [[ anno::usage( "materialx:edf") ]],
+ material mxp_bg = material() [[ anno::usage( "materialx:edf") ]],
+ float mxp_mix = 0.0
+) [[
+ anno::usage( "materialx:edf")
+]]
+= let {
+ float mix = math::saturate(mxp_mix);
+} in material(
+ surface: material_surface(
+ emission: material_emission(
+ emission: df::unbounded_mix(
+ df::edf_component[](
+ df::edf_component( mix, mxp_fg.surface.emission.emission),
+ df::edf_component( 1.0 - mix, mxp_bg.surface.emission.emission))
+ ),
+ intensity: mix * mxp_fg.surface.emission.intensity +
+ (1.0 - mix) * mxp_bg.surface.emission.intensity
+ )
+ )
+);
+
+// NOTE: Adding two VDFs is not supported in MDL, the generator would best
+// analyze the context for mixing weights and replace the add with a mix.
+// The provided implementation just mixes the VDFs with equal weight.
+export material mx_add_vdf(
+ material mxp_in1 = material() [[ anno::usage( "materialx:vdf") ]],
+ material mxp_in2 = material() [[ anno::usage( "materialx:vdf") ]]
+) [[
+ anno::usage( "materialx:vdf")
+]]
+= let {
+ volume_mix_return v = volume_mix(
+ mxp_in1.volume.scattering_coefficient, 1.0f,
+ mxp_in2.volume.scattering_coefficient, 1.0f);
+} in material(
+ // assuming mixing the IOR is the best we can do here
+ ior: 0.5 * mxp_in1.ior + 0.5 * mxp_in2.ior,
+ volume: material_volume(
+ scattering: df::unbounded_mix(
+ df::vdf_component[](
+ df::vdf_component( v.mix_weight1, mxp_in1.volume.scattering),
+ df::vdf_component( 1.0 - v.mix_weight1, mxp_in2.volume.scattering))
+ ),
+ absorption_coefficient: mxp_in1.volume.absorption_coefficient +
+ mxp_in2.volume.absorption_coefficient,
+ scattering_coefficient: v.scattering_coefficient
+ )
+);
+
+export material mx_generalized_schlick_edf(
+ color mxp_color0 = color(1.0),
+ color mxp_color90 = color(1.0),
+ float mxp_exponent = 5.0,
+ material mxp_base = material() [[ anno::usage( "materialx:bsdf") ]]
+) [[
+ anno::usage( "materialx:edf")
+]]
+= material(
+ thin_walled: mxp_base.thin_walled,
+ surface: material_surface(
+ scattering: mxp_base.surface.scattering,
+ emission: material_emission(
+ emission: df::directional_factor(mxp_color0, mxp_color90, mxp_exponent, mxp_base.surface.emission.emission),
+ intensity: mxp_base.surface.emission.intensity,
+ mode: mxp_base.surface.emission.mode)
+ ),
+ backface: mxp_base.backface,
+ ior: mxp_base.ior,
+ volume: mxp_base.volume,
+ geometry: mxp_base.geometry,
+ hair: mxp_base.hair
+);
+
+// MDL 1.7, Volumes do support emission, but not as EDF, just emission intensity.
+// A uniform emission DF is the only practical DF here.
+export material mx_volume(
+ material mxp_vdf = material() [[ anno::usage( "materialx:vdf") ]],
+ material mxp_edf = material() [[ anno::usage( "materialx:edf") ]]
+) [[
+ anno::usage( "materialx:volumeshader")
+]]
+= material(
+ volume: material_volume(
+ absorption_coefficient: mxp_vdf.volume.absorption_coefficient,
+ scattering_coefficient: mxp_vdf.volume.scattering_coefficient,
+ emission_intensity: mxp_edf.surface.emission.intensity
+ )
+);
diff --git a/Sources/MXResources/libraries/mdl/materialx/pbrlib_1_8.mdl b/Sources/MXResources/libraries/mdl/materialx/pbrlib_1_8.mdl
new file mode 100644
index 00000000..fb77e482
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/pbrlib_1_8.mdl
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// MDL implementation of all types and nodes of
+// MaterialX Physically-Based Shading Nodes
+// Document v1.37 REV2, July 16, 2019 (Revised October 17, 2019)
+// see www.materialx.org
+// in
+// NVIDIA Material Definition Language 1.8
+// Language Specification
+// Document version 1.8.2, May 24, 2023
+// www.nvidia.com/mdl
+
+mdl 1.8;
+
+// Changes since MDL 1.7
+// - Support thin-film on custom curve layer to improve generalized_schlick_bsdf,
+// no new implementation required
+
+// forward all unchanged definitions from the previous version
+export using .::pbrlib_1_7 import *;
+
+// without changing any source code
diff --git a/Sources/MXResources/libraries/mdl/materialx/sampling.mdl b/Sources/MXResources/libraries/mdl/materialx/sampling.mdl
new file mode 100644
index 00000000..18095036
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/sampling.mdl
@@ -0,0 +1,181 @@
+//
+// Copyright Contributors to the MaterialX Project
+// SPDX-License-Identifier: Apache-2.0
+//
+
+mdl 1.6;
+
+import ::math::*;
+
+import .::core::*;
+
+// Restrict to 7x7 kernel size for performance reasons
+export const int MX_MAX_SAMPLE_COUNT = 49;
+// Size of all weights for all levels (including level 1)
+export const int MX_WEIGHT_ARRAY_SIZE = 84;
+
+// This is not available in MDL so just use a "small" number
+float2 dFdx(float2 uv)
+{
+ return uv+0.0001;
+}
+
+float2 dFdy(float2 uv)
+{
+ return uv+0.0001;
+}
+
+//
+// Function to compute the sample size relative to a texture coordinate
+//
+export float2 mx_compute_sample_size_uv(float2 uv, float filterSize, float filterOffset)
+{
+ float2 derivUVx = dFdx(uv) * 0.5f;
+ float2 derivUVy = dFdy(uv) * 0.5f;
+ float derivX = ::math::abs(derivUVx.x) + ::math::abs(derivUVy.x);
+ float derivY = ::math::abs(derivUVx.y) + ::math::abs(derivUVy.y);
+ float sampleSizeU = 2.0f * filterSize * derivX + filterOffset;
+ if (sampleSizeU < 1.0E-05f)
+ sampleSizeU = 1.0E-05f;
+ float sampleSizeV = 2.0f * filterSize * derivY + filterOffset;
+ if (sampleSizeV < 1.0E-05f)
+ sampleSizeV = 1.0E-05f;
+ return float2(sampleSizeU, sampleSizeV);
+}
+
+//
+// Compute a normal mapped to 0..1 space based on a set of input
+// samples using a Sobel filter.
+//
+export float3 mx_normal_from_samples_sobel(float[9] S, float scale)
+{
+ float nx = S[0] - S[2] + (2.0*S[3]) - (2.0*S[5]) + S[6] - S[8];
+ float ny = S[0] + (2.0*S[1]) + S[2] - S[6] - (2.0*S[7]) - S[8];
+ float nz = scale * ::math::sqrt(1.0 - nx*nx - ny*ny);
+ float3 norm = ::math::normalize(float3(nx, ny, nz));
+ return (norm + 1.0) * 0.5;
+}
+
+// Kernel weights for box filter
+export float[MX_MAX_SAMPLE_COUNT] mx_get_box_weights(int filterSize)
+{
+ float[MX_MAX_SAMPLE_COUNT] W;
+ int sampleCount = filterSize*filterSize;
+ float value = 1.0 / float(sampleCount);
+ for (int i=0; i= 7)
+ {
+ W[0] = 0.000036; W[1] = 0.000363; W[2] = 0.001446; W[3] = 0.002291; W[4] = 0.001446; W[5] = 0.000363; W[6] = 0.000036;
+ W[7] = 0.000363; W[8] = 0.003676; W[9] = 0.014662; W[10] = 0.023226; W[11] = 0.014662; W[12] = 0.003676; W[13] = 0.000363;
+ W[14] = 0.001446; W[15] = 0.014662; W[16] = 0.058488; W[17] = 0.092651; W[18] = 0.058488; W[19] = 0.014662; W[20] = 0.001446;
+ W[21] = 0.002291; W[22] = 0.023226; W[23] = 0.092651; W[24] = 0.146768; W[25] = 0.092651; W[26] = 0.023226; W[27] = 0.002291;
+ W[28] = 0.001446; W[29] = 0.014662; W[30] = 0.058488; W[31] = 0.092651; W[32] = 0.058488; W[33] = 0.014662; W[34] = 0.001446;
+ W[35] = 0.000363; W[36] = 0.003676; W[37] = 0.014662; W[38] = 0.023226; W[39] = 0.014662; W[40] = 0.003676; W[41] = 0.000363;
+ W[42] = 0.000036; W[43] = 0.000363; W[44] = 0.001446; W[45] = 0.002291; W[46] = 0.001446; W[47] = 0.000363; W[48] = 0.000036;
+ }
+ else if (filterSize >= 5)
+ {
+ W[0] = 0.003765; W[1] = 0.015019; W[2] = 0.023792; W[3] = 0.015019; W[4] = 0.003765;
+ W[5] = 0.015019; W[6] = 0.059912; W[7] = 0.094907; W[8] = 0.059912; W[9] = 0.015019;
+ W[10] = 0.023792; W[11] = 0.094907; W[12] = 0.150342; W[13] = 0.094907; W[14] = 0.023792;
+ W[15] = 0.015019; W[16] = 0.059912; W[17] = 0.094907; W[18] = 0.059912; W[19] = 0.015019;
+ W[20] = 0.003765; W[21] = 0.015019; W[22] = 0.023792; W[23] = 0.015019; W[24] = 0.003765;
+ }
+ else if (filterSize >= 3)
+ {
+ W[0] = 0.0625; W[1] = 0.125; W[2] = 0.0625;
+ W[3] = 0.125; W[4] = 0.25; W[5] = 0.125;
+ W[6] = 0.0625; W[7] = 0.125; W[8] = 0.0625;
+ }
+ else
+ {
+ W[0] = 1.0;
+ }
+ return W;
+}
+
+//
+// Apply filter for float samples S, using weights W.
+// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 }
+//
+export float mx_convolution_float(float[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
+{
+ float result = 0.0;
+ for (int i = 0; i < sampleCount; i++)
+ {
+ result += S[i]*W[i+offset];
+ }
+ return result;
+}
+
+//
+// Apply filter for float2 samples S, using weights W.
+// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 }
+//
+export float2 mx_convolution_float2(float2[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
+{
+ float2 result = float2(0.0);
+ for (int i=0; i 1.0))
+ return mxp_default;
+ if ( mxp_vaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.y < 0.0 || mxp_texcoord.y > 1.0))
+ return mxp_default;
+
+ float returnValue = ::tex::lookup_float(tex: mxp_file,
+ coord: mxp_flip_v
+ ? float2(mxp_texcoord.x, 1.0f - mxp_texcoord.y)
+ : mxp_texcoord,
+ wrap_u: map_addressmode(mxp_uaddressmode),
+ wrap_v: map_addressmode(mxp_vaddressmode));
+ return returnValue;
+}
+
+export color mx_image_color3(
+ uniform texture_2d mxp_file = texture_2d()
+ [[
+ anno::display_name("Filename")
+ ]],
+ uniform string mxp_layer = string("")
+ [[
+ anno::display_name("Layer"), anno::unused()
+ ]],
+ color mxp_default = color(0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Default Color")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+ [[
+ anno::display_name("Texture Coordinates")
+ ]],
+ uniform core::mx_addressmode_type mxp_uaddressmode = core::mx_addressmode_type(core::mx_addressmode_type_periodic)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Address Mode U")
+ ]],
+ uniform core::mx_addressmode_type mxp_vaddressmode = core::mx_addressmode_type(core::mx_addressmode_type_periodic)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Address Mode V")
+ ]],
+ uniform core::mx_filterlookup_type mxp_filtertype = core::mx_filterlookup_type(core::mx_filterlookup_type_linear)
+ [[
+ anno::description("Enumeration {closest,linear,cubic}."),
+ anno::display_name("Filter Type"),
+ anno::unused()
+ ]],
+ uniform string mxp_framerange = string("")
+ [[
+ anno::display_name("Frame Range"),
+ anno::unused()
+ ]],
+ uniform int mxp_frameoffset = int(0)
+ [[
+ anno::display_name("Frame Offset"),
+ anno::unused()
+ ]],
+ uniform core::mx_addressmode_type mxp_frameendaction = core::mx_addressmode_type(core::mx_addressmode_type_constant)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Frame End Action"),
+ anno::unused()
+ ]],
+ uniform bool mxp_flip_v = false
+ [[
+ anno::usage("for applying the 'fileTextureVerticalFlip' shader generator option."),
+ anno::hidden()
+ ]]
+)
+ [[
+ anno::description("Node Group: texture2d")
+ ]]
+{
+ if ( mxp_uaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.x < 0.0 || mxp_texcoord.x > 1.0))
+ return mxp_default;
+ if ( mxp_vaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.y < 0.0 || mxp_texcoord.y > 1.0))
+ return mxp_default;
+
+ color returnValue = ::tex::lookup_color(tex: mxp_file,
+ coord: mxp_flip_v
+ ? float2(mxp_texcoord.x, 1.0f - mxp_texcoord.y)
+ : mxp_texcoord,
+ wrap_u: map_addressmode(mxp_uaddressmode),
+ wrap_v: map_addressmode(mxp_vaddressmode));
+ return returnValue;
+}
+
+export core::color4 mx_image_color4(
+ uniform texture_2d mxp_file = texture_2d()
+ [[
+ anno::display_name("Filename")
+ ]],
+ uniform string mxp_layer = string("")
+ [[
+ anno::display_name("Layer"), anno::unused()
+ ]],
+ core::color4 mxp_default = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Default Color")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+ [[
+ anno::display_name("Texture Coordinates")
+ ]],
+ uniform core::mx_addressmode_type mxp_uaddressmode = core::mx_addressmode_type(core::mx_addressmode_type_periodic)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Address Mode U")
+ ]],
+ uniform core::mx_addressmode_type mxp_vaddressmode = core::mx_addressmode_type(core::mx_addressmode_type_periodic)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Address Mode V")
+ ]],
+ uniform core::mx_filterlookup_type mxp_filtertype = core::mx_filterlookup_type(core::mx_filterlookup_type_linear)
+ [[
+ anno::description("Enumeration {closest,linear,cubic}."),
+ anno::display_name("Filter Type"),
+ anno::unused()
+ ]],
+ uniform string mxp_framerange = string("")
+ [[
+ anno::display_name("Frame Range"),
+ anno::unused()
+ ]],
+ uniform int mxp_frameoffset = int(0)
+ [[
+ anno::display_name("Frame Offset"),
+ anno::unused()
+ ]],
+ uniform core::mx_addressmode_type mxp_frameendaction = core::mx_addressmode_type(core::mx_addressmode_type_constant)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Frame End Action"),
+ anno::unused()
+ ]],
+ uniform bool mxp_flip_v = false
+ [[
+ anno::usage("for applying the 'fileTextureVerticalFlip' shader generator option."),
+ anno::hidden()
+ ]]
+)
+ [[
+ anno::description("Node Group: texture2d")
+ ]]
+{
+ if ( mxp_uaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.x < 0.0 || mxp_texcoord.x > 1.0))
+ return mxp_default;
+ if ( mxp_vaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.y < 0.0 || mxp_texcoord.y > 1.0))
+ return mxp_default;
+
+ core::color4 returnValue = core::mk_color4(::tex::lookup_float4(tex: mxp_file,
+ coord: mxp_flip_v
+ ? float2(mxp_texcoord.x, 1.0f - mxp_texcoord.y)
+ : mxp_texcoord,
+ wrap_u: map_addressmode(mxp_uaddressmode),
+ wrap_v: map_addressmode(mxp_vaddressmode)));
+ return returnValue;
+}
+
+export float2 mx_image_vector2(
+ uniform texture_2d mxp_file = texture_2d()
+ [[
+ anno::display_name("Filename")
+ ]],
+ uniform string mxp_layer = string("")
+ [[
+ anno::display_name("Layer"), anno::unused()
+ ]],
+ float2 mxp_default = float2(0.0, 0.0)
+ [[
+ anno::display_name("Default Color")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+ [[
+ anno::display_name("Texture Coordinates")
+ ]],
+ uniform core::mx_addressmode_type mxp_uaddressmode = core::mx_addressmode_type(core::mx_addressmode_type_periodic)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Address Mode U")
+ ]],
+ uniform core::mx_addressmode_type mxp_vaddressmode = core::mx_addressmode_type(core::mx_addressmode_type_periodic)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Address Mode V")
+ ]],
+ uniform core::mx_filterlookup_type mxp_filtertype = core::mx_filterlookup_type(core::mx_filterlookup_type_linear)
+ [[
+ anno::description("Enumeration {closest,linear,cubic}."),
+ anno::display_name("Filter Type"),
+ anno::unused()
+ ]],
+ uniform string mxp_framerange = string("")
+ [[
+ anno::display_name("Frame Range"),
+ anno::unused()
+ ]],
+ uniform int mxp_frameoffset = int(0)
+ [[
+ anno::display_name("Frame Offset"),
+ anno::unused()
+ ]],
+ uniform core::mx_addressmode_type mxp_frameendaction = core::mx_addressmode_type(core::mx_addressmode_type_constant)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Frame End Action"),
+ anno::unused()
+ ]],
+ uniform bool mxp_flip_v = false
+ [[
+ anno::usage("for applying the 'fileTextureVerticalFlip' shader generator option."),
+ anno::hidden()
+ ]]
+)
+ [[
+ anno::description("Node Group: texture2d")
+ ]]
+{
+ if ( mxp_uaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.x < 0.0 || mxp_texcoord.x > 1.0))
+ return mxp_default;
+ if ( mxp_vaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.y < 0.0 || mxp_texcoord.y > 1.0))
+ return mxp_default;
+
+ float2 returnValue = ::tex::lookup_float2(tex: mxp_file,
+ coord: mxp_flip_v
+ ? float2(mxp_texcoord.x, 1.0f - mxp_texcoord.y)
+ : mxp_texcoord,
+ wrap_u: map_addressmode(mxp_uaddressmode),
+ wrap_v: map_addressmode(mxp_vaddressmode));
+ return returnValue;
+}
+
+export float3 mx_image_vector3(
+ uniform texture_2d mxp_file = texture_2d()
+ [[
+ anno::display_name("Filename")
+ ]],
+ uniform string mxp_layer = string("")
+ [[
+ anno::display_name("Layer"), anno::unused()
+ ]],
+ float3 mxp_default = float3(0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Default Color")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+ [[
+ anno::display_name("Texture Coordinates")
+ ]],
+ uniform core::mx_addressmode_type mxp_uaddressmode = core::mx_addressmode_type(core::mx_addressmode_type_periodic)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Address Mode U")
+ ]],
+ uniform core::mx_addressmode_type mxp_vaddressmode = core::mx_addressmode_type(core::mx_addressmode_type_periodic)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Address Mode V")
+ ]],
+ uniform core::mx_filterlookup_type mxp_filtertype = core::mx_filterlookup_type(core::mx_filterlookup_type_linear)
+ [[
+ anno::description("Enumeration {closest,linear,cubic}."),
+ anno::display_name("Filter Type"),
+ anno::unused()
+ ]],
+ uniform string mxp_framerange = string("")
+ [[
+ anno::display_name("Frame Range"),
+ anno::unused()
+ ]],
+ uniform int mxp_frameoffset = int(0)
+ [[
+ anno::display_name("Frame Offset"),
+ anno::unused()
+ ]],
+ uniform core::mx_addressmode_type mxp_frameendaction = core::mx_addressmode_type(core::mx_addressmode_type_constant)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Frame End Action"),
+ anno::unused()
+ ]],
+ uniform bool mxp_flip_v = false
+ [[
+ anno::usage("for applying the 'fileTextureVerticalFlip' shader generator option."),
+ anno::hidden()
+ ]]
+)
+ [[
+ anno::description("Node Group: texture2d")
+ ]]
+{
+ if ( mxp_uaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.x < 0.0 || mxp_texcoord.x > 1.0))
+ return mxp_default;
+ if ( mxp_vaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.y < 0.0 || mxp_texcoord.y > 1.0))
+ return mxp_default;
+
+ float3 returnValue = ::tex::lookup_float3(tex: mxp_file,
+ coord: mxp_flip_v
+ ? float2(mxp_texcoord.x, 1.0f - mxp_texcoord.y)
+ : mxp_texcoord,
+ wrap_u: map_addressmode(mxp_uaddressmode),
+ wrap_v: map_addressmode(mxp_vaddressmode));
+ return returnValue;
+}
+
+export float4 mx_image_vector4(
+ uniform texture_2d mxp_file = texture_2d()
+ [[
+ anno::display_name("Filename")
+ ]],
+ uniform string mxp_layer = string("")
+ [[
+ anno::display_name("Layer"), anno::unused()
+ ]],
+ float4 mxp_default = float4(0.0, 0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Default Color")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+ [[
+ anno::display_name("Texture Coordinates")
+ ]],
+ uniform core::mx_addressmode_type mxp_uaddressmode = core::mx_addressmode_type(core::mx_addressmode_type_periodic)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Address Mode U")
+ ]],
+ uniform core::mx_addressmode_type mxp_vaddressmode = core::mx_addressmode_type(core::mx_addressmode_type_periodic)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Address Mode V")
+ ]],
+ uniform core::mx_filterlookup_type mxp_filtertype = core::mx_filterlookup_type(core::mx_filterlookup_type_linear)
+ [[
+ anno::description("Enumeration {closest,linear,cubic}."),
+ anno::display_name("Filter Type"),
+ anno::unused()
+ ]],
+ uniform string mxp_framerange = string("")
+ [[
+ anno::display_name("Frame Range"),
+ anno::unused()
+ ]],
+ uniform int mxp_frameoffset = int(0)
+ [[
+ anno::display_name("Frame Offset"),
+ anno::unused()
+ ]],
+ uniform core::mx_addressmode_type mxp_frameendaction = core::mx_addressmode_type(core::mx_addressmode_type_constant)
+ [[
+ anno::description("Enumeration {constant,clamp,periodic,mirror}."),
+ anno::display_name("Frame End Action"),
+ anno::unused()
+ ]],
+ uniform bool mxp_flip_v = false
+ [[
+ anno::usage("for applying the 'fileTextureVerticalFlip' shader generator option."),
+ anno::hidden()
+ ]]
+)
+ [[
+ anno::description("Node Group: texture2d")
+ ]]
+{
+ if ( mxp_uaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.x < 0.0 || mxp_texcoord.x > 1.0))
+ return mxp_default;
+ if ( mxp_vaddressmode == core::mx_addressmode_type_constant
+ && ( mxp_texcoord.y < 0.0 || mxp_texcoord.y > 1.0))
+ return mxp_default;
+
+ float4 returnValue = ::tex::lookup_float4(tex: mxp_file,
+ coord: mxp_flip_v
+ ? float2(mxp_texcoord.x, 1.0f - mxp_texcoord.y)
+ : mxp_texcoord,
+ wrap_u: map_addressmode(mxp_uaddressmode),
+ wrap_v: map_addressmode(mxp_vaddressmode));
+ return returnValue;
+}
+
+// Nodedef: ND_tiledimage_float is represented by a nodegraph: NG_tiledimage_float
+// Nodedef: ND_tiledimage_color3 is represented by a nodegraph: NG_tiledimage_color3
+// Nodedef: ND_tiledimage_color4 is represented by a nodegraph: NG_tiledimage_color4
+// Nodedef: ND_tiledimage_vector2 is represented by a nodegraph: NG_tiledimage_vector2
+// Nodedef: ND_tiledimage_vector3 is represented by a nodegraph: NG_tiledimage_vector3
+// Nodedef: ND_tiledimage_vector4 is represented by a nodegraph: NG_tiledimage_vector4
+// Nodedef: ND_triplanarprojection_float is represented by a nodegraph: NG_triplanarprojection_float
+// Nodedef: ND_triplanarprojection_color3 is represented by a nodegraph: NG_triplanarprojection_color3
+// Nodedef: ND_triplanarprojection_color4 is represented by a nodegraph: NG_triplanarprojection_color4
+// Nodedef: ND_triplanarprojection_vector2 is represented by a nodegraph: NG_triplanarprojection_vector2
+// Nodedef: ND_triplanarprojection_vector3 is represented by a nodegraph: NG_triplanarprojection_vector3
+// Nodedef: ND_triplanarprojection_vector4 is represented by a nodegraph: NG_triplanarprojection_vector4
+
+export float mx_constant_float(
+ float mxp_value = float(0.0)
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export color mx_constant_color3(
+ color mxp_value = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export core::color4 mx_constant_color4(
+ core::color4 mxp_value = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export float2 mx_constant_vector2(
+ float2 mxp_value = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export float3 mx_constant_vector3(
+ float3 mxp_value = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export float4 mx_constant_vector4(
+ float4 mxp_value = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export bool mx_constant_boolean(
+ bool mxp_value = bool(false)
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export int mx_constant_integer(
+ int mxp_value = int(0)
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export float3x3 mx_constant_matrix33(
+ float3x3 mxp_value = float3x3(1.0,0.0,0.0, 0.0,1.0,0.0, 0.0,0.0,1.0)
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export float4x4 mx_constant_matrix44(
+ float4x4 mxp_value = float4x4(1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 0.0,0.0,0.0,1.0)
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export string mx_constant_string(
+ uniform string mxp_value = string("")
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export string mx_constant_filename(
+ uniform string mxp_value = string("")
+)
+ [[
+ anno::description("Node Group: procedural")
+ ]]
+{
+ return mxp_value;
+}
+
+export float mx_ramplr_float(
+ float mxp_valuel = float(0.0),
+ float mxp_valuer = float(0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuel, mxp_valuer, math::clamp(mxp_texcoord.x, 0.0, 1.0));
+}
+
+export color mx_ramplr_color3(
+ color mxp_valuel = color(0.0, 0.0, 0.0),
+ color mxp_valuer = color(0.0, 0.0, 0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuel, mxp_valuer, math::clamp(mxp_texcoord.x, 0.0, 1.0));
+}
+
+export core::color4 mx_ramplr_color4(
+ core::color4 mxp_valuel = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_valuer = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ color rgb = math::lerp(mxp_valuel.rgb, mxp_valuer.rgb, math::clamp(mxp_texcoord.x, 0.0, 1.0));
+ float a = math::lerp(mxp_valuel.a, mxp_valuer.a, math::clamp(mxp_texcoord.x, 0.0, 1.0));
+ return core::color4(rgb, a);}
+
+export float2 mx_ramplr_vector2(
+ float2 mxp_valuel = float2(0.0, 0.0),
+ float2 mxp_valuer = float2(0.0, 0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuel, mxp_valuer, math::clamp(mxp_texcoord.x, 0.0, 1.0));
+}
+
+export float3 mx_ramplr_vector3(
+ float3 mxp_valuel = float3(0.0, 0.0, 0.0),
+ float3 mxp_valuer = float3(0.0, 0.0, 0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuel, mxp_valuer, math::clamp(mxp_texcoord.x, 0.0, 1.0));
+}
+
+export float4 mx_ramplr_vector4(
+ float4 mxp_valuel = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_valuer = float4(0.0, 0.0, 0.0, 0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuel, mxp_valuer, math::clamp(mxp_texcoord.x, 0.0, 1.0));
+}
+
+export float mx_ramptb_float(
+ float mxp_valuet = float(0.0),
+ float mxp_valueb = float(0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuet, mxp_valueb, math::clamp(mxp_texcoord.y, 0.0, 1.0));
+}
+
+export color mx_ramptb_color3(
+ color mxp_valuet = color(0.0, 0.0, 0.0),
+ color mxp_valueb = color(0.0, 0.0, 0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuet, mxp_valueb, math::clamp(mxp_texcoord.y, 0.0, 1.0));
+}
+
+export core::color4 mx_ramptb_color4(
+ core::color4 mxp_valuet = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_valueb = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ color rgb = math::lerp(mxp_valuet.rgb, mxp_valueb.rgb, math::clamp(mxp_texcoord.y, 0.0, 1.0));
+ float a = math::lerp(mxp_valuet.a, mxp_valueb.a, math::clamp(mxp_texcoord.y, 0.0, 1.0));
+ return core::color4(rgb, a);}
+
+export float2 mx_ramptb_vector2(
+ float2 mxp_valuet = float2(0.0, 0.0),
+ float2 mxp_valueb = float2(0.0, 0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuet, mxp_valueb, math::clamp(mxp_texcoord.y, 0.0, 1.0));
+}
+
+export float3 mx_ramptb_vector3(
+ float3 mxp_valuet = float3(0.0, 0.0, 0.0),
+ float3 mxp_valueb = float3(0.0, 0.0, 0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuet, mxp_valueb, math::clamp(mxp_texcoord.y, 0.0, 1.0));
+}
+
+export float4 mx_ramptb_vector4(
+ float4 mxp_valuet = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_valueb = float4(0.0, 0.0, 0.0, 0.0),
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuet, mxp_valueb, math::clamp(mxp_texcoord.y, 0.0, 1.0));
+}
+
+// Nodedef: ND_ramp4_float is represented by a nodegraph: NG_ramp4_float
+// Nodedef: ND_ramp4_color3 is represented by a nodegraph: NG_ramp4_color3
+// Nodedef: ND_ramp4_color4 is represented by a nodegraph: NG_ramp4_color4
+// Nodedef: ND_ramp4_vector2 is represented by a nodegraph: NG_ramp4_vector2
+// Nodedef: ND_ramp4_vector3 is represented by a nodegraph: NG_ramp4_vector3
+// Nodedef: ND_ramp4_vector4 is represented by a nodegraph: NG_ramp4_vector4
+
+export float mx_splitlr_float(
+ float mxp_valuel = float(0.0)
+ [[
+ anno::display_name("Left")
+ ]],
+ float mxp_valuer = float(0.0)
+ [[
+ anno::display_name("Right")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuel, mxp_valuer, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+}
+
+export color mx_splitlr_color3(
+ color mxp_valuel = color(0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Left")
+ ]],
+ color mxp_valuer = color(0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Right")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuel, mxp_valuer, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+}
+
+export core::color4 mx_splitlr_color4(
+ core::color4 mxp_valuel = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Left")
+ ]],
+ core::color4 mxp_valuer = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Right")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ color rgb = math::lerp(mxp_valuel.rgb, mxp_valuer.rgb, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+ float a = math::lerp(mxp_valuel.a, mxp_valuer.a, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+ return core::color4(rgb, a);
+}
+
+export float2 mx_splitlr_vector2(
+ float2 mxp_valuel = float2(0.0, 0.0)
+ [[
+ anno::display_name("Left")
+ ]],
+ float2 mxp_valuer = float2(0.0, 0.0)
+ [[
+ anno::display_name("Right")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuel, mxp_valuer, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+}
+
+export float3 mx_splitlr_vector3(
+ float3 mxp_valuel = float3(0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Left")
+ ]],
+ float3 mxp_valuer = float3(0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Right")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuel, mxp_valuer, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+}
+
+export float4 mx_splitlr_vector4(
+ float4 mxp_valuel = float4(0.0, 0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Left")
+ ]],
+ float4 mxp_valuer = float4(0.0, 0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Right")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuel, mxp_valuer, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+}
+
+export float mx_splittb_float(
+ float mxp_valuet = float(0.0)
+ [[
+ anno::display_name("Top")
+ ]],
+ float mxp_valueb = float(0.0)
+ [[
+ anno::display_name("Bottom")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuet, mxp_valueb, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+}
+
+export color mx_splittb_color3(
+ color mxp_valuet = color(0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Top")
+ ]],
+ color mxp_valueb = color(0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Bottom")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuet, mxp_valueb, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+}
+
+export core::color4 mx_splittb_color4(
+ core::color4 mxp_valuet = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Top")
+ ]],
+ core::color4 mxp_valueb = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Bottom")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ color rgb = math::lerp(mxp_valuet.rgb, mxp_valueb.rgb, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1))); float a = math::lerp(mxp_valuet.a, mxp_valueb.a, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1))); return core::color4(rgb, a);
+}
+
+export float2 mx_splittb_vector2(
+ float2 mxp_valuet = float2(0.0, 0.0)
+ [[
+ anno::display_name("Top")
+ ]],
+ float2 mxp_valueb = float2(0.0, 0.0)
+ [[
+ anno::display_name("Bottom")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuet, mxp_valueb, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+}
+
+export float3 mx_splittb_vector3(
+ float3 mxp_valuet = float3(0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Top")
+ ]],
+ float3 mxp_valueb = float3(0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Bottom")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuet, mxp_valueb, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+}
+
+export float4 mx_splittb_vector4(
+ float4 mxp_valuet = float4(0.0, 0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Top")
+ ]],
+ float4 mxp_valueb = float4(0.0, 0.0, 0.0, 0.0)
+ [[
+ anno::display_name("Bottom")
+ ]],
+ float mxp_center = float(0.5)
+ [[
+ anno::display_name("Center")
+ ]],
+ float2 mxp_texcoord = float2(swizzle::xy(::state::texture_coordinate(0)))
+)
+ [[
+ anno::description("Node Group: procedural2d")
+ ]]
+{
+ return math::lerp(mxp_valuet, mxp_valueb, math::step(mxp_center, math::clamp(mxp_texcoord.x,0,1)));
+}
+
+export float3 mx_position_vector3(
+ uniform core::mx_coordinatespace_type mxp_space = core::mx_coordinatespace_type(core::mx_coordinatespace_type_object)
+ [[
+ anno::description("Enumeration {model,object,world}.")
+ ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ state::coordinate_space fromSpace = ::core::mx_map_space(core::mx_coordinatespace_type_model);
+ state::coordinate_space toSpace = ::core::mx_map_space(mxp_space);
+ return state::transform_point(fromSpace, toSpace, state::position());
+}
+
+export float3 mx_normal_vector3(
+ uniform core::mx_coordinatespace_type mxp_space = core::mx_coordinatespace_type(core::mx_coordinatespace_type_object)
+ [[
+ anno::description("Enumeration {model,object,world}.")
+ ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ state::coordinate_space fromSpace = ::core::mx_map_space(core::mx_coordinatespace_type_model);
+ state::coordinate_space toSpace = ::core::mx_map_space(mxp_space);
+ return state::transform_normal(fromSpace, toSpace, state::normal());
+}
+
+export float3 mx_tangent_vector3(
+ uniform core::mx_coordinatespace_type mxp_space = core::mx_coordinatespace_type(core::mx_coordinatespace_type_object)
+ [[
+ anno::description("Enumeration {model,object,world}.")
+ ]],
+ uniform int mxp_index = int(0)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ state::coordinate_space fromSpace = ::core::mx_map_space(core::mx_coordinatespace_type_model);
+ state::coordinate_space toSpace = ::core::mx_map_space(mxp_space);
+ return ::math::normalize(state::transform_vector(fromSpace, toSpace, state::texture_tangent_u(mxp_index)));
+}
+
+export float3 mx_bitangent_vector3(
+ uniform core::mx_coordinatespace_type mxp_space = core::mx_coordinatespace_type(core::mx_coordinatespace_type_object)
+ [[
+ anno::description("Enumeration {model,object,world}.")
+ ]],
+ uniform int mxp_index = int(0)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ state::coordinate_space fromSpace = ::core::mx_map_space(core::mx_coordinatespace_type_model);
+ state::coordinate_space toSpace = ::core::mx_map_space(mxp_space);
+ return ::math::normalize(state::transform_vector(fromSpace, toSpace, state::texture_tangent_v(mxp_index)));
+}
+
+export float2 mx_texcoord_vector2(
+ uniform int mxp_index = int(0)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ return swizzle::xy((state::texture_coordinate(mxp_index)));
+}
+
+export float3 mx_texcoord_vector3(
+ uniform int mxp_index = int(0)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ return state::texture_coordinate(mxp_index);
+}
+
+export float mx_geomcolor_float(
+ uniform int mxp_index = int(0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geomcolor_float
+ float defaultValue = float(0.0);
+ return defaultValue;
+}
+
+export color mx_geomcolor_color3(
+ uniform int mxp_index = int(0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geomcolor_color3
+ color defaultValue = color(0.0, 0.0, 0.0);
+ return defaultValue;
+}
+
+export core::color4 mx_geomcolor_color4(
+ uniform int mxp_index = int(0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geomcolor_color4
+ core::color4 defaultValue = core::mk_color4(0.0, 0.0, 0.0, 0.0);
+ return defaultValue;
+}
+
+export int mx_geompropvalue_integer(
+ uniform string mxp_geomprop = string("") [[ anno::unused() ]],
+ int mxp_default = int(0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geompropvalue_integer
+ int defaultValue = int(0);
+ return defaultValue;
+}
+
+export bool mx_geompropvalue_boolean(
+ uniform string mxp_geomprop = string("") [[ anno::unused() ]],
+ bool mxp_default = bool(false) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geompropvalue_boolean
+ bool defaultValue = bool(false);
+ return defaultValue;
+}
+
+export string mx_geompropvalue_string(
+ uniform string mxp_geomprop = string("") [[ anno::unused() ]],
+ string mxp_default = string("") [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geompropvalue_string
+ string defaultValue;
+ return defaultValue;
+}
+
+export float mx_geompropvalue_float(
+ uniform string mxp_geomprop = string("") [[ anno::unused() ]],
+ float mxp_default = float(0.0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geompropvalue_float
+ float defaultValue = float(0.0);
+ return defaultValue;
+}
+
+export color mx_geompropvalue_color3(
+ uniform string mxp_geomprop = string("") [[ anno::unused() ]],
+ color mxp_default = color(0.0, 0.0, 0.0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geompropvalue_color3
+ color defaultValue = color(0.0, 0.0, 0.0);
+ return defaultValue;
+}
+
+export core::color4 mx_geompropvalue_color4(
+ uniform string mxp_geomprop = string("") [[ anno::unused() ]],
+ core::color4 mxp_default = core::mk_color4(0.0, 0.0, 0.0, 0.0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geompropvalue_color4
+ core::color4 defaultValue = core::mk_color4(0.0, 0.0, 0.0, 0.0);
+ return defaultValue;
+}
+
+export float2 mx_geompropvalue_vector2(
+ uniform string mxp_geomprop = string("") [[ anno::unused() ]],
+ float2 mxp_default = float2(0.0, 0.0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geompropvalue_vector2
+ float2 defaultValue = float2(0.0, 0.0);
+ return defaultValue;
+}
+
+export float3 mx_geompropvalue_vector3(
+ uniform string mxp_geomprop = string("") [[ anno::unused() ]],
+ float3 mxp_default = float3(0.0, 0.0, 0.0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geompropvalue_vector3
+ float3 defaultValue = float3(0.0, 0.0, 0.0);
+ return defaultValue;
+}
+
+export float4 mx_geompropvalue_vector4(
+ uniform string mxp_geomprop = string("") [[ anno::unused() ]],
+ float4 mxp_default = float4(0.0, 0.0, 0.0, 0.0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ // Not implemented: mx_geompropvalue_vector4
+ float4 defaultValue = float4(0.0, 0.0, 0.0, 0.0);
+ return defaultValue;
+}
+
+export float mx_ambientocclusion_float(
+ float mxp_coneangle = float(90.0)
+ [[
+ anno::description("Unit Type:angle. Unit:degrees."),
+ anno::unused()
+ ]],
+ float mxp_maxdistance = float(1e38) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: global")
+ ]]
+{
+ // Not implemented: mx_ambientocclusion_float
+ float defaultValue = float(1.0);
+ return defaultValue;
+}
+
+export float mx_frame_float(
+)
+ [[
+ anno::description("Node Group: application")
+ ]]
+{
+ // Not implemented: mx_frame_float
+ float defaultValue = float(1.0);
+ return defaultValue;
+}
+
+export float mx_time_float(
+ uniform float mxp_fps = float(24.0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: application")
+ ]]
+{
+ return ::state::animation_time();
+}
+
+export float3 mx_viewdirection_vector3(
+ uniform core::mx_coordinatespace_type mxp_space = core::mx_coordinatespace_type_world
+ [[
+ anno::description("Enumeration {model,object,world}."),
+ anno::unused()
+ ]]
+)
+ [[
+ anno::description("Node Group: nprlib")
+ ]]
+{
+ // Not implemented: mx_viewdirection_vector3
+ float3 defaultValue = float3(0.0, 0.0, 1.0);
+ return defaultValue;
+}
+
+export color mx_modulo_color3(
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ color mxp_in2 = color(1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return color(core::mx_mod(float3(mxp_in1), float3(mxp_in2)));
+}
+
+export core::color4 mx_modulo_color4(
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(1.0, 1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(core::mx_mod(core::mk_float4(mxp_in1), core::mk_float4(mxp_in2)));
+}
+
+export color mx_modulo_color3FA(
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ float mxp_in2 = float(1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return color(core::mx_mod(float3(mxp_in1), float3(mxp_in2)));
+}
+
+export core::color4 mx_modulo_color4FA(
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_in2 = float(1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(core::mx_mod(core::mk_float4(mxp_in1), float4(mxp_in2)));
+}
+
+export core::color4 mx_invert_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_amount = core::mk_color4(1.0, 1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(core::mk_float4(mxp_amount) - core::mk_float4(mxp_in));
+}
+
+export core::color4 mx_invert_color4FA(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_amount = float(1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(float4(mxp_amount) - core::mk_float4(mxp_in));
+}
+
+export core::color4 mx_absval_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::abs(core::mk_float4(mxp_in)));
+}
+
+export color mx_floor_color3(
+ color mxp_in = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return color(::math::floor(float3(mxp_in)));
+}
+
+export core::color4 mx_floor_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::floor(core::mk_float4(mxp_in)));
+}
+
+export color mx_ceil_color3(
+ color mxp_in = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return color(::math::ceil(float3(mxp_in)));
+}
+
+export core::color4 mx_ceil_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::ceil(core::mk_float4(mxp_in)));
+}
+
+export color mx_round_color3(
+ color mxp_in = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return color(::math::round(float3(mxp_in)));
+}
+
+export core::color4 mx_round_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::round(core::mk_float4(mxp_in)));
+}
+
+export core::color4 mx_power_color4(
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(1.0, 1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::pow(core::mk_float4(mxp_in1), core::mk_float4(mxp_in2)));
+}
+
+export core::color4 mx_power_color4FA(
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_in2 = float(1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::pow(core::mk_float4(mxp_in1), float4(mxp_in2)));
+}
+
+export float mx_sin_float(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::sin(mxp_in);
+}
+
+export float mx_cos_float(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::cos(mxp_in);
+}
+
+export float mx_tan_float(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::tan(mxp_in);
+}
+
+export float mx_asin_float(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::asin(mxp_in);
+}
+
+export float mx_acos_float(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::acos(mxp_in);
+}
+
+export float mx_atan2_float(
+ float mxp_in1 = float(1.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::atan2(mxp_in1, mxp_in2);
+}
+
+export float2 mx_sin_vector2(
+ float2 mxp_in = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::sin(mxp_in);
+}
+
+export float2 mx_cos_vector2(
+ float2 mxp_in = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::cos(mxp_in);
+}
+
+export float2 mx_tan_vector2(
+ float2 mxp_in = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::tan(mxp_in);
+}
+
+export float2 mx_asin_vector2(
+ float2 mxp_in = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::asin(mxp_in);
+}
+
+export float2 mx_acos_vector2(
+ float2 mxp_in = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::acos(mxp_in);
+}
+
+export float2 mx_atan2_vector2(
+ float2 mxp_in1 = float2(1.0, 1.0),
+ float2 mxp_in2 = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::atan2(mxp_in1, mxp_in2);
+}
+
+export float3 mx_sin_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::sin(mxp_in);
+}
+
+export float3 mx_cos_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::cos(mxp_in);
+}
+
+export float3 mx_tan_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::tan(mxp_in);
+}
+
+export float3 mx_asin_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::asin(mxp_in);
+}
+
+export float3 mx_acos_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::acos(mxp_in);
+}
+
+export float3 mx_atan2_vector3(
+ float3 mxp_in1 = float3(1.0, 1.0, 1.0),
+ float3 mxp_in2 = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::atan2(mxp_in1, mxp_in2);
+}
+
+export float4 mx_sin_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::sin(mxp_in);
+}
+
+export float4 mx_cos_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::cos(mxp_in);
+}
+
+export float4 mx_tan_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::tan(mxp_in);
+}
+
+export float4 mx_asin_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::asin(mxp_in);
+}
+
+export float4 mx_acos_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::acos(mxp_in);
+}
+
+export float4 mx_atan2_vector4(
+ float4 mxp_in1 = float4(1.0, 1.0, 1.0, 1.0),
+ float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::atan2(mxp_in1, mxp_in2);
+}
+
+export float mx_sqrt_float(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::sqrt(mxp_in);
+}
+
+export float mx_ln_float(
+ float mxp_in = float(1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::log(mxp_in);
+}
+
+export float mx_exp_float(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::exp(mxp_in);
+}
+
+export float2 mx_sqrt_vector2(
+ float2 mxp_in = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::sqrt(mxp_in);
+}
+
+export float2 mx_ln_vector2(
+ float2 mxp_in = float2(1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::log(mxp_in);
+}
+
+export float2 mx_exp_vector2(
+ float2 mxp_in = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::exp(mxp_in);
+}
+
+export float3 mx_sqrt_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::sqrt(mxp_in);
+}
+
+export float3 mx_ln_vector3(
+ float3 mxp_in = float3(1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::log(mxp_in);
+}
+
+export float3 mx_exp_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::exp(mxp_in);
+}
+
+export float4 mx_sqrt_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::sqrt(mxp_in);
+}
+
+export float4 mx_ln_vector4(
+ float4 mxp_in = float4(1.0, 1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::log(mxp_in);
+}
+
+export float4 mx_exp_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::exp(mxp_in);
+}
+
+export color mx_sign_color3(
+ color mxp_in = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return color(::math::sign(float3(mxp_in)));
+}
+
+export core::color4 mx_sign_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::sign(core::mk_float4(mxp_in)));
+}
+
+export core::color4 mx_clamp_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_low = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_high = core::mk_color4(1.0, 1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::clamp(core::mk_float4(mxp_in), core::mk_float4(mxp_low), core::mk_float4(mxp_high)));
+}
+
+export core::color4 mx_clamp_color4FA(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_low = float(0.0),
+ float mxp_high = float(1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::clamp(core::mk_float4(mxp_in), float4(mxp_low), float4(mxp_high)));
+}
+
+export core::color4 mx_min_color4(
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::min(core::mk_float4(mxp_in1), core::mk_float4(mxp_in2)));
+}
+
+export core::color4 mx_min_color4(
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::min(core::mk_float4(mxp_in1), float4(mxp_in2)));
+}
+
+export core::color4 mx_max_color4(
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::max(core::mk_float4(mxp_in1), core::mk_float4(mxp_in2)));
+}
+
+export core::color4 mx_max_color4(
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return core::mk_color4(::math::max(core::mk_float4(mxp_in1), float4(mxp_in2)));
+}
+
+export float3 mx_transformpoint_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ uniform string mxp_fromspace = "object",
+ uniform string mxp_tospace = "world"
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ state::coordinate_space fromSpace = ::core::mx_map_space(mxp_fromspace);
+ state::coordinate_space toSpace = ::core::mx_map_space(mxp_tospace);
+ return state::transform_point(fromSpace, toSpace, mxp_in);
+}
+
+export float3 mx_transformvector_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ uniform string mxp_fromspace = "object",
+ uniform string mxp_tospace = "world"
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ state::coordinate_space fromSpace = ::core::mx_map_space(mxp_fromspace);
+ state::coordinate_space toSpace = ::core::mx_map_space(mxp_tospace);
+ return state::transform_vector(fromSpace, toSpace, mxp_in);
+}
+
+export float3 mx_transformnormal_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 1.0),
+ uniform string mxp_fromspace = "object",
+ uniform string mxp_tospace = "world"
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ state::coordinate_space fromSpace = ::core::mx_map_space(mxp_fromspace);
+ state::coordinate_space toSpace = ::core::mx_map_space(mxp_tospace);
+ return state::transform_normal(fromSpace, toSpace, mxp_in);
+}
+
+export float2 mx_transformmatrix_vector2M3(
+ float2 mxp_in = float2(0.0, 0.0),
+ float3x3 mxp_mat = float3x3(1.0,0.0,0.0, 0.0,1.0,0.0, 0.0,0.0,1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ float3 returnValue = mxp_mat * float3(mxp_in.x, mxp_in.y, 1.0);
+ return float2(returnValue.x, returnValue.y);
+}
+
+export float3 mx_transformmatrix_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ float3x3 mxp_mat = float3x3(1.0,0.0,0.0, 0.0,1.0,0.0, 0.0,0.0,1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return mxp_mat * mxp_in;
+}
+
+export float3 mx_transformmatrix_vector3M4(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ float4x4 mxp_mat = float4x4(1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 0.0,0.0,0.0,1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ float4 returnValue = mxp_mat * float4(mxp_in.x, mxp_in.y, mxp_in.z, 1.0);
+ return float3(returnValue.x, returnValue.y, returnValue.z);
+}
+
+export float4 mx_transformmatrix_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0),
+ float4x4 mxp_mat = float4x4(1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 0.0,0.0,0.0,1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return mxp_mat * mxp_in;
+}
+
+export float3 mx_normalmap_vector2(
+ float3 mxp_in = float3(0.5, 0.5, 1.0),
+ uniform string mxp_space = string("tangent")
+ [[
+ anno::description("Enumeration {tangent, object}.")
+ ]],
+ float2 mxp_scale = float2(1.0, 1.0),
+ float3 mxp_normal = float3(::state::transform_normal(::state::coordinate_internal,::state::coordinate_world,::state::normal())),
+ float3 mxp_tangent = float3(state::transform_vector(::state::coordinate_internal,::state::coordinate_world,::state::texture_tangent_u(0)))
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ if (mxp_space == "tangent")
+ {
+ float3 v = mxp_in * 2.0 - 1.0;
+ float3 binormal = ::math::normalize(::math::cross(mxp_normal, mxp_tangent));
+ return ::math::normalize(mxp_tangent * v.x * mxp_scale.x + binormal * v.y * mxp_scale.y + mxp_normal * v.z);
+ }
+ else
+ {
+ float3 n = mxp_in * 2.0 - 1.0;
+ return ::math::normalize(n);
+ }
+}
+
+export float3 mx_normalmap_float(
+ float3 mxp_in = float3(0.5, 0.5, 1.0),
+ uniform string mxp_space = string("tangent")
+ [[
+ anno::description("Enumeration {tangent, object}.")
+ ]],
+ float mxp_scale = float(1.0),
+ float3 mxp_normal = float3(::state::transform_normal(::state::coordinate_internal,::state::coordinate_world,::state::normal())),
+ float3 mxp_tangent = float3(state::transform_vector(::state::coordinate_internal,::state::coordinate_world,::state::texture_tangent_u(0)))
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return mx_normalmap_vector2(mxp_in, mxp_space, float2(mxp_scale, mxp_scale), mxp_normal, mxp_tangent);
+}
+
+export float3x3 mx_transpose_matrix33(
+ float3x3 mxp_in = float3x3(1.0,0.0,0.0, 0.0,1.0,0.0, 0.0,0.0,1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::transpose(mxp_in);
+}
+
+export float4x4 mx_transpose_matrix44(
+ float4x4 mxp_in = float4x4(1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 0.0,0.0,0.0,1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return ::math::transpose(mxp_in);
+}
+
+export float mx_determinant_matrix33(float3x3 mxp_in)
+[[
+ anno::description("Node Group: math")
+]]
+{
+ return mxp_in[0][0] * (mxp_in[2][2]*mxp_in[1][1] - mxp_in[1][2]*mxp_in[2][1])
+ + mxp_in[0][1] * (mxp_in[1][2]*mxp_in[2][0] - mxp_in[2][2]*mxp_in[1][0])
+ + mxp_in[0][2] * (mxp_in[2][1]*mxp_in[1][0] - mxp_in[1][1]*mxp_in[2][0]);
+}
+
+export float mx_determinant_matrix44(float4x4 mxp_in)
+[[
+ anno::description("Node Group: math")
+]]
+{
+ float
+ b00 = mxp_in[0][0] * mxp_in[1][1] - mxp_in[0][1] * mxp_in[1][0],
+ b01 = mxp_in[0][0] * mxp_in[1][2] - mxp_in[0][2] * mxp_in[1][0],
+ b02 = mxp_in[0][0] * mxp_in[1][3] - mxp_in[0][3] * mxp_in[1][0],
+ b03 = mxp_in[0][1] * mxp_in[1][2] - mxp_in[0][2] * mxp_in[1][1],
+ b04 = mxp_in[0][1] * mxp_in[1][3] - mxp_in[0][3] * mxp_in[1][1],
+ b05 = mxp_in[0][2] * mxp_in[1][3] - mxp_in[0][3] * mxp_in[1][2],
+ b06 = mxp_in[2][0] * mxp_in[3][1] - mxp_in[2][1] * mxp_in[3][0],
+ b07 = mxp_in[2][0] * mxp_in[3][2] - mxp_in[2][2] * mxp_in[3][0],
+ b08 = mxp_in[2][0] * mxp_in[3][3] - mxp_in[2][3] * mxp_in[3][0],
+ b09 = mxp_in[2][1] * mxp_in[3][2] - mxp_in[2][2] * mxp_in[3][1],
+ b10 = mxp_in[2][1] * mxp_in[3][3] - mxp_in[2][3] * mxp_in[3][1],
+ b11 = mxp_in[2][2] * mxp_in[3][3] - mxp_in[2][3] * mxp_in[3][2];
+ return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
+}
+
+export float3x3 mx_invertmatrix_matrix33(
+ float3x3 mxp_in = float3x3(1.0,0.0,0.0, 0.0,1.0,0.0, 0.0,0.0,1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ // Not implemented: mx_invertmatrix_matrix33
+ float3x3 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export float4x4 mx_invertmatrix_matrix44(
+ float4x4 mxp_in = float4x4(1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 0.0,0.0,0.0,1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ // Not implemented: mx_invertmatrix_matrix44
+ float4x4 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export float2 mx_rotate2d_vector2(
+ float2 mxp_in = float2(0.0, 0.0),
+ float mxp_amount = float(0.0)
+ [[
+ anno::description("Unit Type:angle. Unit:degrees.")
+ ]]
+)
+[[
+ anno::description("Node Group: math")
+]]
+{
+ float angleRadians = math::radians(mxp_amount);
+ float sinAngle = math::sin(angleRadians);
+ float cosAngle = math::cos(angleRadians);
+ return float2(cosAngle*mxp_in.x + sinAngle*mxp_in.y, -sinAngle*mxp_in.x + cosAngle*mxp_in.y);
+}
+
+float4x4 mx_rotationMatrix(float3 mxp_axis, float mxp_amount)
+{
+ float sinAngle = math::sin(mxp_amount);
+ float cosAngle = math::cos(mxp_amount);
+ float oc = 1.0 - cosAngle;
+
+ return float4x4(
+ oc * mxp_axis.x * mxp_axis.x + cosAngle, oc * mxp_axis.x * mxp_axis.y - mxp_axis.z * sinAngle, oc * mxp_axis.z * mxp_axis.x + mxp_axis.y * sinAngle, 0.0,
+ oc * mxp_axis.x * mxp_axis.y + mxp_axis.z * sinAngle, oc * mxp_axis.y * mxp_axis.y + cosAngle, oc * mxp_axis.y * mxp_axis.z - mxp_axis.x * sinAngle, 0.0,
+ oc * mxp_axis.z * mxp_axis.x - mxp_axis.y * sinAngle, oc * mxp_axis.y * mxp_axis.z + mxp_axis.x * sinAngle, oc * mxp_axis.z * mxp_axis.z + cosAngle, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+}
+
+export float3 mx_rotate3d_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ float mxp_amount = float(0.0)
+ [[
+ anno::description("Unit Type:angle. Unit:degrees.")
+ ]],
+ float3 mxp_axis = float3(0.0, 1.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ float angleRadians = math::radians(mxp_amount);
+ float4x4 m = mx_rotationMatrix(mxp_axis, angleRadians);
+ float4 v = m * float4(mxp_in.x, mxp_in.y, mxp_in.z, 1.0);
+ return float3(v.x, v.y, v.z);
+}
+
+// Nodedef: ND_place2d_vector2 is represented by a nodegraph: NG_place2d_vector2
+
+export float mx_remap_float(
+ float mxp_in = float(0.0),
+ float mxp_inlow = float(0.0),
+ float mxp_inhigh = float(1.0),
+ float mxp_outlow = float(0.0),
+ float mxp_outhigh = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return mxp_outlow + (mxp_in - mxp_inlow) * (mxp_outhigh - mxp_outlow) / (mxp_inhigh - mxp_inlow);
+}
+
+export color mx_remap_color3(
+ color mxp_in = color(0.0, 0.0, 0.0),
+ color mxp_inlow = color(0.0, 0.0, 0.0),
+ color mxp_inhigh = color(1.0, 1.0, 1.0),
+ color mxp_outlow = color(0.0, 0.0, 0.0),
+ color mxp_outhigh = color(1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return mxp_outlow + (mxp_in - mxp_inlow) * (mxp_outhigh - mxp_outlow) / (mxp_inhigh - mxp_inlow);
+}
+
+export core::color4 mx_remap_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_inlow = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_inhigh = core::mk_color4(1.0, 1.0, 1.0, 1.0),
+ core::color4 mxp_outlow = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_outhigh = core::mk_color4(1.0, 1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ core::color4 val = mxp_outlow;
+ core::color4 val2 = core::mx_add(val, core::mx_subtract(mxp_in, mxp_inlow));
+ core::color4 val3 = core::mx_multiply(val2, core::mx_subtract(mxp_outhigh, mxp_outlow));
+ return core::mx_divide(val3, core::mx_subtract(mxp_inhigh, mxp_inlow));
+}
+
+export float2 mx_remap_vector2(
+ float2 mxp_in = float2(0.0, 0.0),
+ float2 mxp_inlow = float2(0.0, 0.0),
+ float2 mxp_inhigh = float2(1.0, 1.0),
+ float2 mxp_outlow = float2(0.0, 0.0),
+ float2 mxp_outhigh = float2(1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return mxp_outlow + (mxp_in - mxp_inlow) * (mxp_outhigh - mxp_outlow) / (mxp_inhigh - mxp_inlow);
+}
+
+export float3 mx_remap_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ float3 mxp_inlow = float3(0.0, 0.0, 0.0),
+ float3 mxp_inhigh = float3(1.0, 1.0, 1.0),
+ float3 mxp_outlow = float3(0.0, 0.0, 0.0),
+ float3 mxp_outhigh = float3(1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return mxp_outlow + (mxp_in - mxp_inlow) * (mxp_outhigh - mxp_outlow) / (mxp_inhigh - mxp_inlow);
+}
+
+export float4 mx_remap_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_inlow = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_inhigh = float4(1.0, 1.0, 1.0, 1.0),
+ float4 mxp_outlow = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_outhigh = float4(1.0, 1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return mxp_outlow + (mxp_in - mxp_inlow) * (mxp_outhigh - mxp_outlow) / (mxp_inhigh - mxp_inlow);
+}
+
+export color mx_remap_color3FA(
+ color mxp_in = color(0.0, 0.0, 0.0),
+ float mxp_inlow = float(0.0),
+ float mxp_inhigh = float(1.0),
+ float mxp_outlow = float(0.0),
+ float mxp_outhigh = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return mxp_outlow + (mxp_in - mxp_inlow) * (mxp_outhigh - mxp_outlow) / (mxp_inhigh - mxp_inlow);
+}
+
+export core::color4 mx_remap_color4FA(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_inlow = float(0.0),
+ float mxp_inhigh = float(1.0),
+ float mxp_outlow = float(0.0),
+ float mxp_outhigh = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ core::color4 val = core::mk_color4(mxp_outlow);
+ core::color4 val2 = core::mx_add(val, core::mx_subtract(mxp_in, core::mk_color4(mxp_inlow)));
+ core::color4 val3 = core::mx_multiply(val2, core::mx_subtract(core::mk_color4(mxp_outhigh), core::mk_color4(mxp_outlow)));
+ return core::mx_divide(val3, core::mx_subtract(core::mk_color4(mxp_inhigh), core::mk_color4(mxp_inlow)));
+}
+
+export float2 mx_remap_vector2FA(
+ float2 mxp_in = float2(0.0, 0.0),
+ float mxp_inlow = float(0.0),
+ float mxp_inhigh = float(1.0),
+ float mxp_outlow = float(0.0),
+ float mxp_outhigh = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return mxp_outlow + (mxp_in - mxp_inlow) * (mxp_outhigh - mxp_outlow) / (mxp_inhigh - mxp_inlow);
+}
+
+export float3 mx_remap_vector3FA(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ float mxp_inlow = float(0.0),
+ float mxp_inhigh = float(1.0),
+ float mxp_outlow = float(0.0),
+ float mxp_outhigh = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return mxp_outlow + (mxp_in - mxp_inlow) * (mxp_outhigh - mxp_outlow) / (mxp_inhigh - mxp_inlow);
+}
+
+export float4 mx_remap_vector4FA(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0),
+ float mxp_inlow = float(0.0),
+ float mxp_inhigh = float(1.0),
+ float mxp_outlow = float(0.0),
+ float mxp_outhigh = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return mxp_outlow + (mxp_in - mxp_inlow) * (mxp_outhigh - mxp_outlow) / (mxp_inhigh - mxp_inlow);
+}
+
+export float mx_smoothstep_float(
+ float mxp_in = float(0.0),
+ float mxp_low = float(0.0),
+ float mxp_high = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return ::math::smoothstep(float(mxp_low), float(mxp_high), float(mxp_in));
+}
+
+export color mx_smoothstep_color3(
+ color mxp_in = color(0.0, 0.0, 0.0),
+ color mxp_low = color(0.0, 0.0, 0.0),
+ color mxp_high = color(1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return color(::math::smoothstep(float3(mxp_low), float3(mxp_high), float3(mxp_in)));
+}
+
+export core::color4 mx_smoothstep_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_low = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_high = core::mk_color4(1.0, 1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return core::mk_color4(::math::smoothstep(core::mk_float4(mxp_low), core::mk_float4(mxp_high), core::mk_float4(mxp_in)));
+}
+
+export float2 mx_smoothstep_vector2(
+ float2 mxp_in = float2(0.0, 0.0),
+ float2 mxp_low = float2(0.0, 0.0),
+ float2 mxp_high = float2(1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return ::math::smoothstep(float2(mxp_low), float2(mxp_high), float2(mxp_in));
+}
+
+export float3 mx_smoothstep_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ float3 mxp_low = float3(0.0, 0.0, 0.0),
+ float3 mxp_high = float3(1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return ::math::smoothstep(float3(mxp_low), float3(mxp_high), float3(mxp_in));
+}
+
+export float4 mx_smoothstep_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_low = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_high = float4(1.0, 1.0, 1.0, 1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return ::math::smoothstep(float4(mxp_low), float4(mxp_high), float4(mxp_in));
+}
+
+export color mx_smoothstep_color3FA(
+ color mxp_in = color(0.0, 0.0, 0.0),
+ float mxp_low = float(0.0),
+ float mxp_high = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return color(::math::smoothstep(float3(mxp_in), float3(mxp_low), float3(mxp_high)));
+}
+
+export core::color4 mx_smoothstep_color4FA(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_low = float(0.0),
+ float mxp_high = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return core::mk_color4(::math::smoothstep(core::mk_float4(mxp_in), float4(mxp_low), float4(mxp_high)));
+}
+
+export float2 mx_smoothstep_vector2FA(
+ float2 mxp_in = float2(0.0, 0.0),
+ float mxp_low = float(0.0),
+ float mxp_high = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return ::math::smoothstep(float2(mxp_low), float2(mxp_high), float2(mxp_in));
+}
+
+export float3 mx_smoothstep_vector3FA(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ float mxp_low = float(0.0),
+ float mxp_high = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return ::math::smoothstep(float3(mxp_low), float3(mxp_high), float3(mxp_in));
+}
+
+export float4 mx_smoothstep_vector4FA(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0),
+ float mxp_low = float(0.0),
+ float mxp_high = float(1.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return ::math::smoothstep(float4(mxp_low), float4(mxp_high), float4(mxp_in));
+}
+
+export float mx_curveadjust_float(
+ float mxp_in = float(0.0),
+ float2[] mxp_knots = float2[]() [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ // Not implemented: mx_curveadjust_float
+ float defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export color mx_curveadjust_color3(
+ color mxp_in = color(0.0, 0.0, 0.0),
+ float2[] mxp_knots = float2[]() [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ // Not implemented: mx_curveadjust_color3
+ color defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export core::color4 mx_curveadjust_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float2[] mxp_knots = float2[]() [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ // Not implemented: mx_curveadjust_color4
+ core::color4 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export float2 mx_curveadjust_vector2(
+ float2 mxp_in = float2(0.0, 0.0),
+ float2[] mxp_knots = float2[]() [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ // Not implemented: mx_curveadjust_vector2
+ float2 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export float3 mx_curveadjust_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ float2[] mxp_knots = float2[]() [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ // Not implemented: mx_curveadjust_vector3
+ float3 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export float4 mx_curveadjust_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0),
+ float2[] mxp_knots = float2[]() [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ // Not implemented: mx_curveadjust_vector4
+ float4 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export color mx_luminance_color3(
+ color mxp_in = color(0.0, 0.0, 0.0),
+ uniform color mxp_lumacoeffs = color(0.2722287, 0.6740818, 0.0536895)
+ [[
+ anno::description("Enumeration {acescg, rec709, rec2020, rec2100}."),
+ anno::unused()
+ ]]
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return color(::math::luminance(mxp_in));
+}
+
+export core::color4 mx_luminance_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ uniform color mxp_lumacoeffs = color(0.2722287, 0.6740818, 0.0536895)
+ [[
+ anno::description("Enumeration {acescg, rec709, rec2020, rec2100}."),
+ anno::unused()
+ ]]
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ color rgb = color(mxp_in.rgb);
+ core::color4 returnValue = core::mk_color4(::math::luminance(rgb));
+ returnValue.a = mxp_in.a;
+ return returnValue;
+}
+
+export color mx_rgbtohsv_color3(
+ color mxp_in = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return color(::hsv::mx_rgbtohsv(float3(mxp_in)));
+}
+
+export core::color4 mx_rgbtohsv_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ float3 rgb = hsv::mx_rgbtohsv(float3(mxp_in.rgb));
+ return core::color4(color(rgb), mxp_in.a);
+}
+
+export color mx_hsvtorgb_color3(
+ color mxp_in = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ return color(hsv::mx_hsvtorgb(float3(mxp_in)));
+}
+
+export core::color4 mx_hsvtorgb_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: adjustment")
+ ]]
+{
+ float3 rgb = hsv::mx_hsvtorgb(float3(mxp_in.rgb));
+ return core::color4(color(rgb), mxp_in.a);
+}
+
+export core::color4 mx_premult_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ // Not implemented: mx_premult_color4
+ core::color4 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export core::color4 mx_unpremult_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ // Not implemented: mx_unpremult_color4
+ core::color4 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export core::color4 mx_plus_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ color rgb = (mxp_mix*(mxp_bg.rgb + mxp_fg.rgb)) + ((1.0-mxp_mix)*mxp_bg.rgb);
+ float a = (mxp_mix*(mxp_bg.a + mxp_fg.a )) + ((1.0-mxp_mix)*mxp_bg.a );
+ return core::color4(rgb,a);
+}
+
+export core::color4 mx_minus_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ color rgb = (mxp_mix*(mxp_bg.rgb - mxp_fg.rgb)) + ((1.0-mxp_mix)*mxp_bg.rgb);
+ float a = (mxp_mix*(mxp_bg.a - mxp_fg.a )) + ((1.0-mxp_mix)*mxp_bg.a );
+ return core::color4(rgb,a);
+}
+
+export core::color4 mx_difference_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ color rgb = (mxp_mix*math::abs(mxp_bg.rgb - mxp_fg.rgb)) + ((1.0-mxp_mix)*mxp_bg.rgb);
+ float a = (mxp_mix*math::abs(mxp_bg.a - mxp_fg.a )) + ((1.0-mxp_mix)*mxp_bg.a );
+ return core::color4(rgb,a);
+}
+
+export float mx_burn_float(
+ float mxp_fg = 0.0,
+ float mxp_bg = 0.0,
+ float mxp_mix = 1.0
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ if (math::abs(mxp_fg) < core::FLOAT_EPS)
+ {
+ return 0.0;
+ }
+ return mxp_mix*(1.0 - ((1.0 - mxp_bg) / mxp_fg)) + ((1.0 - mxp_mix)*mxp_bg);
+}
+
+export color mx_burn_color3(
+ color mxp_fg = color(0.0),
+ color mxp_bg = color(0.0),
+ float mxp_mix = 1.0
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ float3 fg(mxp_fg);
+ float3 bg(mxp_bg);
+ return color(
+ mx_burn_float(fg.x, bg.x, mxp_mix),
+ mx_burn_float(fg.y, bg.y, mxp_mix),
+ mx_burn_float(fg.z, bg.z, mxp_mix)
+ );
+}
+
+export core::color4 mx_burn_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = 1.0
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ return core::color4(
+ mx_burn_color3(mxp_fg.rgb, mxp_bg.rgb, mxp_mix),
+ mx_burn_float(mxp_fg.a, mxp_bg.a, mxp_mix)
+ );
+}
+
+export float mx_dodge_float(
+ float mxp_fg = float(0.0),
+ float mxp_bg = float(0.0),
+ float mxp_mix = 1.0
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ if (math::abs(1.0 - mxp_fg) < core::FLOAT_EPS)
+ {
+ return 0.0;
+ }
+ return mxp_mix*(mxp_bg / (1.0 - mxp_fg)) + ((1.0-mxp_mix)*mxp_bg);
+}
+
+export color mx_dodge_color3(
+ color mxp_fg = color(0.0),
+ color mxp_bg = color(0.0),
+ float mxp_mix = 1.0
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ float3 fg(mxp_fg);
+ float3 bg(mxp_bg);
+ return color(
+ mx_dodge_float(fg.x, bg.x, mxp_mix),
+ mx_dodge_float(fg.y, bg.y, mxp_mix),
+ mx_dodge_float(fg.z, bg.z, mxp_mix)
+ );
+}
+
+export core::color4 mx_dodge_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ return core::color4(
+ mx_dodge_color3(mxp_fg.rgb, mxp_bg.rgb, mxp_mix),
+ mx_dodge_float(mxp_fg.a, mxp_bg.a, mxp_mix)
+ );
+}
+
+export core::color4 mx_screen_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ color rgb = (mxp_mix*((1.0 - (1.0 - mxp_fg.rgb) * (1 - mxp_bg.rgb)))) + ((1.0-mxp_mix)*mxp_bg.rgb);
+ float a = (mxp_mix*((1.0 - (1.0 - mxp_fg.a ) * (1 - mxp_bg.a )))) + ((1.0-mxp_mix)*mxp_bg.a );
+ return core::color4(rgb,a);
+}
+
+export core::color4 mx_disjointover_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ core::color4 result;
+ float summedAlpha = mxp_fg.a + mxp_bg.a;
+ if (summedAlpha <= 1)
+ {
+ result.rgb = mxp_fg.rgb + mxp_bg.rgb;
+ }
+ else
+ {
+ if (math::abs(mxp_bg.a) < core::FLOAT_EPS)
+ {
+ result.rgb = color(0.0);
+ }
+ else
+ {
+ float x = (1 - mxp_fg.a) / mxp_bg.a;
+ result.rgb = mxp_fg.rgb + mxp_bg.rgb * x;
+ }
+ }
+ result.a = math::min(summedAlpha, 1.0);
+ result.rgb = result.rgb * mxp_mix + (1.0 - mxp_mix) * mxp_bg.rgb;
+ result.a = result.a * mxp_mix + (1.0 - mxp_mix) * mxp_bg.a;
+ return result;
+}
+
+export core::color4 mx_in_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ color rgb = mxp_fg.rgb*mxp_bg.a * mxp_mix + mxp_bg.rgb * (1.0-mxp_mix);
+ float a = mxp_fg.a *mxp_bg.a * mxp_mix + mxp_bg.a * (1.0-mxp_mix);
+ return core::color4(rgb,a);
+}
+
+export core::color4 mx_mask_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ color rgb = mxp_bg.rgb*mxp_fg.a * mxp_mix + mxp_bg.rgb * (1.0-mxp_mix);
+ float a = mxp_bg.a *mxp_fg.a * mxp_mix + mxp_bg.a * (1.0-mxp_mix);
+ return core::color4(rgb,a);
+}
+
+export core::color4 mx_matte_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = 1.0
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ color rgb = (mxp_fg.rgb*mxp_fg.a + mxp_bg.rgb*(1.0-mxp_fg.a)) * mxp_mix + mxp_bg.rgb * (1.0-mxp_mix);
+ float a = (mxp_fg.a + mxp_bg.a*(1.0-mxp_fg.a)) * mxp_mix + mxp_bg.a * (1.0-mxp_mix);
+ return core::color4(rgb, a);
+}
+
+export core::color4 mx_out_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ color rgb = (mxp_fg.rgb*(1.0 - mxp_bg.a) * mxp_mix) + (mxp_bg.rgb * (1.0-mxp_mix));
+ float a = (mxp_fg.a *(1.0 - mxp_bg.a) * mxp_mix) + (mxp_bg.a * (1.0-mxp_mix));
+ return core::color4(rgb,a);
+}
+
+export core::color4 mx_over_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(1.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ color rgb = (mxp_fg.rgb + (mxp_bg.rgb*(1.0-mxp_fg.a))) * mxp_mix + mxp_bg.rgb * (1.0-mxp_mix);
+ float a = (mxp_fg.a + (mxp_bg.a *(1.0-mxp_fg.a))) * mxp_mix + mxp_bg.a * (1.0-mxp_mix);
+ return core::color4(rgb,a);
+}
+
+export core::color4 mx_mix_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_mix = float(0.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ return core::mk_color4(::math::lerp(core::mk_float4(mxp_bg), core::mk_float4(mxp_fg), float4(mxp_mix)));
+}
+
+export core::color4 mx_mix_color4_color4(
+ core::color4 mxp_fg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_bg = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_mix = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: compositing")
+ ]]
+{
+ return core::mk_color4(::math::lerp(core::mk_float4(mxp_bg), core::mk_float4(mxp_fg), core::mk_float4(mxp_mix)));
+}
+
+// mix all parts of the material, bsdf, edf, and vdf, geometry
+export material mx_mix_surfaceshader(
+ material mxp_fg = material() [[ anno::usage( "materialx:surfaceshader") ]],
+ material mxp_bg = material() [[ anno::usage( "materialx:surfaceshader") ]],
+ float mxp_mix = 0.0
+) [[
+ anno::description("Node Group: compositing"),
+ anno::usage( "materialx:surfaceshader")
+]]
+= material(
+ surface: material_surface(
+ scattering: df::weighted_layer(
+ weight: mxp_mix,
+ layer: mxp_fg.surface.scattering,
+ base: mxp_bg.surface.scattering
+ ),
+ emission: material_emission(
+ emission: df::clamped_mix(
+ df::edf_component[](
+ df::edf_component( mxp_mix, mxp_fg.surface.emission.emission),
+ df::edf_component( 1.0 - mxp_mix, mxp_bg.surface.emission.emission))
+ ),
+ intensity: mxp_mix * mxp_fg.surface.emission.intensity +
+ (1.0 - mxp_mix) * mxp_bg.surface.emission.intensity
+ )
+ ),
+
+ // we need to carry volume properties along for SSS
+ ior: mxp_fg.ior, // NOTE: IOR is uniform, cannot mix here
+ volume: material_volume(
+ scattering: df::clamped_mix(
+ df::vdf_component[](
+ df::vdf_component( mxp_mix, mxp_fg.volume.scattering),
+ df::vdf_component( 1.0 - mxp_mix, mxp_bg.volume.scattering))
+ ),
+ absorption_coefficient: mxp_mix * mxp_fg.volume.absorption_coefficient +
+ (1.0 - mxp_mix) * mxp_bg.volume.absorption_coefficient,
+ scattering_coefficient: mxp_mix * mxp_fg.volume.scattering_coefficient +
+ (1.0 - mxp_mix) * mxp_bg.volume.scattering_coefficient
+ ),
+ geometry: material_geometry(
+ displacement: mxp_mix * mxp_fg.geometry.displacement +
+ (1.0 - mxp_mix) * mxp_bg.geometry.displacement,
+ cutout_opacity: mxp_mix * mxp_fg.geometry.cutout_opacity +
+ (1.0 - mxp_mix) * mxp_bg.geometry.cutout_opacity,
+ normal: mxp_mix * mxp_fg.geometry.normal +
+ (1.0 - mxp_mix) * mxp_bg.geometry.normal
+ )
+);
+
+export material mx_mix_volumeshader(
+ material mxp_fg = material() [[ anno::usage( "materialx:volumeshader") ]],
+ material mxp_bg = material() [[ anno::usage( "materialx:volumeshader") ]],
+ float mxp_mix = 0.0
+) [[
+ anno::description("Node Group: compositing"),
+ anno::usage( "materialx:volumeshader")
+]]
+= mx_mix_surfaceshader(
+ mxp_fg: mxp_fg,
+ mxp_bg: mxp_bg,
+ mxp_mix: mxp_mix);
+
+export material mx_mix_displacementshader(
+ material mxp_fg = material() [[ anno::usage( "materialx:displacementshader") ]],
+ material mxp_bg = material() [[ anno::usage( "materialx:displacementshader") ]],
+ float mxp_mix = 0.0
+) [[
+ anno::description("Node Group: compositing"),
+ anno::usage( "materialx:displacementshader")
+]]
+= mx_mix_surfaceshader(
+ mxp_fg: mxp_fg,
+ mxp_bg: mxp_bg,
+ mxp_mix: mxp_mix);
+
+export float mx_ifgreater_float(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export color mx_ifgreater_color3(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ color mxp_in2 = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export core::color4 mx_ifgreater_color4(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float2 mx_ifgreater_vector2(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float3 mx_ifgreater_vector3(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ float3 mxp_in1 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float4 mx_ifgreater_vector4(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ float4 mxp_in1 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float mx_ifgreater_floatI(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export color mx_ifgreater_color3I(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ color mxp_in2 = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export core::color4 mx_ifgreater_color4I(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float2 mx_ifgreater_vector2I(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float3 mx_ifgreater_vector3I(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ float3 mxp_in1 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float4 mx_ifgreater_vector4I(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ float4 mxp_in1 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 > mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float mx_ifgreatereq_float(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export color mx_ifgreatereq_color3(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ color mxp_in2 = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export core::color4 mx_ifgreatereq_color4(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float2 mx_ifgreatereq_vector2(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float3 mx_ifgreatereq_vector3(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ float3 mxp_in1 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float4 mx_ifgreatereq_vector4(
+ float mxp_value1 = float(1.0),
+ float mxp_value2 = float(0.0),
+ float4 mxp_in1 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float mx_ifgreatereq_floatI(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export color mx_ifgreatereq_color3I(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ color mxp_in2 = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export core::color4 mx_ifgreatereq_color4I(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float2 mx_ifgreatereq_vector2I(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float3 mx_ifgreatereq_vector3I(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ float3 mxp_in1 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float4 mx_ifgreatereq_vector4I(
+ int mxp_value1 = int(1),
+ int mxp_value2 = int(0),
+ float4 mxp_in1 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 >= mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float mx_ifequal_float(
+ float mxp_value1 = float(0.0),
+ float mxp_value2 = float(0.0),
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export color mx_ifequal_color3(
+ float mxp_value1 = float(0.0),
+ float mxp_value2 = float(0.0),
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ color mxp_in2 = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export core::color4 mx_ifequal_color4(
+ float mxp_value1 = float(0.0),
+ float mxp_value2 = float(0.0),
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float2 mx_ifequal_vector2(
+ float mxp_value1 = float(0.0),
+ float mxp_value2 = float(0.0),
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float3 mx_ifequal_vector3(
+ float mxp_value1 = float(0.0),
+ float mxp_value2 = float(0.0),
+ float3 mxp_in1 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float4 mx_ifequal_vector4(
+ float mxp_value1 = float(0.0),
+ float mxp_value2 = float(0.0),
+ float4 mxp_in1 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float mx_ifequal_floatI(
+ int mxp_value1 = int(0),
+ int mxp_value2 = int(0),
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export color mx_ifequal_color3I(
+ int mxp_value1 = int(0),
+ int mxp_value2 = int(0),
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ color mxp_in2 = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export core::color4 mx_ifequal_color4I(
+ int mxp_value1 = int(0),
+ int mxp_value2 = int(0),
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float2 mx_ifequal_vector2I(
+ int mxp_value1 = int(0),
+ int mxp_value2 = int(0),
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float3 mx_ifequal_vector3I(
+ int mxp_value1 = int(0),
+ int mxp_value2 = int(0),
+ float3 mxp_in1 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float4 mx_ifequal_vector4I(
+ int mxp_value1 = int(0),
+ int mxp_value2 = int(0),
+ float4 mxp_in1 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float mx_ifequal_floatB(
+ bool mxp_value1 = bool(false),
+ bool mxp_value2 = bool(false),
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export color mx_ifequal_color3B(
+ bool mxp_value1 = bool(false),
+ bool mxp_value2 = bool(false),
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ color mxp_in2 = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export core::color4 mx_ifequal_color4B(
+ bool mxp_value1 = bool(false),
+ bool mxp_value2 = bool(false),
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float2 mx_ifequal_vector2B(
+ bool mxp_value1 = bool(false),
+ bool mxp_value2 = bool(false),
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float3 mx_ifequal_vector3B(
+ bool mxp_value1 = bool(false),
+ bool mxp_value2 = bool(false),
+ float3 mxp_in1 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float4 mx_ifequal_vector4B(
+ bool mxp_value1 = bool(false),
+ bool mxp_value2 = bool(false),
+ float4 mxp_in1 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ if (mxp_value1 == mxp_value2) { return mxp_in1; } return mxp_in2;
+}
+
+export float mx_switch_float(
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0),
+ float mxp_in3 = float(0.0),
+ float mxp_in4 = float(0.0),
+ float mxp_in5 = float(0.0),
+ float mxp_which = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export color mx_switch_color3(
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ color mxp_in2 = color(0.0, 0.0, 0.0),
+ color mxp_in3 = color(0.0, 0.0, 0.0),
+ color mxp_in4 = color(0.0, 0.0, 0.0),
+ color mxp_in5 = color(0.0, 0.0, 0.0),
+ float mxp_which = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ color returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export core::color4 mx_switch_color4(
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in3 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in4 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in5 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_which = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ core::color4 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export float2 mx_switch_vector2(
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0),
+ float2 mxp_in3 = float2(0.0, 0.0),
+ float2 mxp_in4 = float2(0.0, 0.0),
+ float2 mxp_in5 = float2(0.0, 0.0),
+ float mxp_which = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float2 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export float3 mx_switch_vector3(
+ float3 mxp_in1 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in3 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in4 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in5 = float3(0.0, 0.0, 0.0),
+ float mxp_which = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float3 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export float4 mx_switch_vector4(
+ float4 mxp_in1 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in3 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in4 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in5 = float4(0.0, 0.0, 0.0, 0.0),
+ float mxp_which = float(0.0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float4 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export float mx_switch_floatI(
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0),
+ float mxp_in3 = float(0.0),
+ float mxp_in4 = float(0.0),
+ float mxp_in5 = float(0.0),
+ int mxp_which = int(0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export color mx_switch_color3I(
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ color mxp_in2 = color(0.0, 0.0, 0.0),
+ color mxp_in3 = color(0.0, 0.0, 0.0),
+ color mxp_in4 = color(0.0, 0.0, 0.0),
+ color mxp_in5 = color(0.0, 0.0, 0.0),
+ int mxp_which = int(0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ color returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export core::color4 mx_switch_color4I(
+ core::color4 mxp_in1 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in2 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in3 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in4 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ core::color4 mxp_in5 = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ int mxp_which = int(0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ core::color4 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export float2 mx_switch_vector2I(
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0),
+ float2 mxp_in3 = float2(0.0, 0.0),
+ float2 mxp_in4 = float2(0.0, 0.0),
+ float2 mxp_in5 = float2(0.0, 0.0),
+ int mxp_which = int(0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float2 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export float3 mx_switch_vector3I(
+ float3 mxp_in1 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in3 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in4 = float3(0.0, 0.0, 0.0),
+ float3 mxp_in5 = float3(0.0, 0.0, 0.0),
+ int mxp_which = int(0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float3 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export float4 mx_switch_vector4I(
+ float4 mxp_in1 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in2 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in3 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in4 = float4(0.0, 0.0, 0.0, 0.0),
+ float4 mxp_in5 = float4(0.0, 0.0, 0.0, 0.0),
+ int mxp_which = int(0)
+)
+ [[
+ anno::description("Node Group: conditional")
+ ]]
+{
+ float4 returnValue;
+ switch (int(mxp_which)) {
+ case 0: returnValue=mxp_in1; break;
+ case 1: returnValue=mxp_in2; break;
+ case 2: returnValue=mxp_in3; break;
+ case 3: returnValue=mxp_in4; break;
+ case 4: returnValue=mxp_in5; break;
+ default: returnValue=mxp_in1; break;
+ }
+ return returnValue;
+}
+
+export color mx_convert_float_color3(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return color(mxp_in);
+}
+
+export core::color4 mx_convert_float_color4(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return core::mk_color4(mxp_in);
+}
+
+export float2 mx_convert_float_vector2(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float2(mxp_in);
+}
+
+export float3 mx_convert_float_vector3(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float3(mxp_in);
+}
+
+export float4 mx_convert_float_vector4(
+ float mxp_in = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float4(mxp_in);
+}
+
+export float3 mx_convert_vector2_vector3(
+ float2 mxp_in = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float3(mxp_in.x, mxp_in.y, 0.0);
+}
+
+export color mx_convert_vector3_color3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return color(mxp_in);
+}
+
+export float2 mx_convert_vector3_vector2(
+ float3 mxp_in = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float2(mxp_in.x, mxp_in.y);
+}
+
+export float4 mx_convert_vector3_vector4(
+ float3 mxp_in = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float4(mxp_in.x, mxp_in.y, mxp_in.z, 0.0);
+}
+
+export core::color4 mx_convert_vector4_color4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return core::mk_color4(mxp_in);
+}
+
+export float3 mx_convert_vector4_vector3(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float3(mxp_in.x, mxp_in.y, mxp_in.z);
+}
+
+export float3 mx_convert_color3_vector3(
+ color mxp_in = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float3(mxp_in);
+}
+
+export float4 mx_convert_color4_vector4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return core::mk_float4(mxp_in);
+}
+
+export core::color4 mx_convert_color3_color4(
+ color mxp_in = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return core::mk_color4(mxp_in);
+}
+
+export color mx_convert_color4_color3(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return mxp_in.rgb;
+}
+
+export float mx_convert_boolean_float(
+ bool mxp_in = bool(false)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float(mxp_in);
+}
+
+export float mx_convert_integer_float(
+ int mxp_in = int(0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float(mxp_in);
+}
+
+export float2 mx_combine2_vector2(
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float2(mxp_in1, mxp_in2);
+}
+
+export core::color4 mx_combine2_color4CF(
+ color mxp_in1 = color(0.0, 0.0, 0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return core::color4(mxp_in1, mxp_in2);
+}
+
+export float4 mx_combine2_vector4VF(
+ float3 mxp_in1 = float3(0.0, 0.0, 0.0),
+ float mxp_in2 = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float4(mxp_in1.x, mxp_in1.y, mxp_in1.z, mxp_in2);
+}
+
+export core::color4 mx_combine2_color4CC(
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return core::color4(color(mxp_in1.x, mxp_in1.y, mxp_in2.x), mxp_in2.y);
+}
+
+export float4 mx_combine2_vector4VV(
+ float2 mxp_in1 = float2(0.0, 0.0),
+ float2 mxp_in2 = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float4(mxp_in1.x, mxp_in1.y, mxp_in2.x, mxp_in2.y);
+}
+
+export color mx_combine3_color3(
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0),
+ float mxp_in3 = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return color(mxp_in1, mxp_in2, mxp_in3);
+}
+
+export float3 mx_combine3_vector3(
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0),
+ float mxp_in3 = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float3(mxp_in1, mxp_in2, mxp_in3);
+}
+
+export core::color4 mx_combine4_color4(
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0),
+ float mxp_in3 = float(0.0),
+ float mxp_in4 = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return core::mk_color4(mxp_in1, mxp_in2, mxp_in3, mxp_in4);
+}
+
+export float4 mx_combine4_vector4(
+ float mxp_in1 = float(0.0),
+ float mxp_in2 = float(0.0),
+ float mxp_in3 = float(0.0),
+ float mxp_in4 = float(0.0)
+)
+ [[
+ anno::description("Node Group: channel")
+ ]]
+{
+ return float4(mxp_in1, mxp_in2, mxp_in3, mxp_in4);
+}
+
+export float3x3 mx_creatematrix_vector3_matrix33(
+ float3 mxp_in1 = float3(1.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 1.0, 0.0),
+ float3 mxp_in3 = float3(0.0, 0.0, 1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return float3x3(
+ mxp_in1[0], mxp_in1[1], mxp_in1[2],
+ mxp_in2[0], mxp_in2[1], mxp_in2[2],
+ mxp_in3[0], mxp_in3[1], mxp_in3[2]);
+}
+
+
+export float4x4 mx_creatematrix_vector3_matrix44(
+ float3 mxp_in1 = float3(1.0, 0.0, 0.0),
+ float3 mxp_in2 = float3(0.0, 1.0, 0.0),
+ float3 mxp_in3 = float3(0.0, 0.0, 1.0),
+ float3 mxp_in4 = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return float4x4(
+ mxp_in1[0], mxp_in1[1], mxp_in1[2], 0.0,
+ mxp_in2[0], mxp_in2[1], mxp_in2[2], 0.0,
+ mxp_in3[0], mxp_in3[1], mxp_in3[2], 0.0,
+ mxp_in4[0], mxp_in4[1], mxp_in4[2], 1.0);
+}
+
+
+export float4x4 mx_creatematrix_vector4_matrix44(
+ float4 mxp_in1 = float4(1.0, 0.0, 0.0, 0.0),
+ float4 mxp_in2 = float4(0.0, 1.0, 0.0, 0.0),
+ float4 mxp_in3 = float4(0.0, 0.0, 1.0, 0.0),
+ float4 mxp_in4 = float4(0.0, 0.0, 0.0, 1.0)
+)
+ [[
+ anno::description("Node Group: math")
+ ]]
+{
+ return float4x4(
+ mxp_in1[0], mxp_in1[1], mxp_in1[2], mxp_in1[3],
+ mxp_in2[0], mxp_in2[1], mxp_in2[2], mxp_in2[3],
+ mxp_in3[0], mxp_in3[1], mxp_in3[2], mxp_in3[3],
+ mxp_in4[0], mxp_in4[1], mxp_in4[2], mxp_in4[3]);
+}
+
+// Nodedef: ND_extract_color3 is represented by a nodegraph: NG_extract_color3
+// Nodedef: ND_extract_color4 is represented by a nodegraph: NG_extract_color4
+// Nodedef: ND_extract_vector2 is represented by a nodegraph: NG_extract_vector2
+// Nodedef: ND_extract_vector3 is represented by a nodegraph: NG_extract_vector3
+// Nodedef: ND_extract_vector4 is represented by a nodegraph: NG_extract_vector4
+// Nodedef: ND_separate2_vector2 is represented by a nodegraph: NG_separate2_vector2
+// Nodedef: ND_separate3_color3 is represented by a nodegraph: NG_separate3_color3
+// Nodedef: ND_separate3_vector3 is represented by a nodegraph: NG_separate3_vector3
+// Nodedef: ND_separate4_color4 is represented by a nodegraph: NG_separate4_color4
+// Nodedef: ND_separate4_vector4 is represented by a nodegraph: NG_separate4_vector4
+
+export float mx_blur_float(
+ float mxp_in = float(0.0),
+ float mxp_size = float(0.0)
+ [[
+ anno::unused()
+ ]],
+ uniform core::mx_filter_type mxp_filtertype = core::mx_filter_type(core::mx_filter_type_box)
+ [[
+ anno::description("Enumeration {box,gaussian}."),
+ anno::unused()
+ ]]
+)
+ [[
+ anno::description("Node Group: convolution2d")
+ ]]
+{
+ // Not implemented: mx_blur_float
+ float defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export color mx_blur_color3(
+ color mxp_in = color(0.0, 0.0, 0.0),
+ float mxp_size = float(0.0)
+ [[
+ anno::unused()
+ ]],
+ uniform core::mx_filter_type mxp_filtertype = core::mx_filter_type(core::mx_filter_type_box)
+ [[
+ anno::description("Enumeration {box,gaussian}."),
+ anno::unused()
+ ]]
+)
+ [[
+ anno::description("Node Group: convolution2d")
+ ]]
+{
+ // Not implemented: mx_blur_color3
+ color defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export core::color4 mx_blur_color4(
+ core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
+ float mxp_size = float(0.0)
+ [[
+ anno::unused()
+ ]],
+ uniform core::mx_filter_type mxp_filtertype = core::mx_filter_type(core::mx_filter_type_box)
+ [[
+ anno::description("Enumeration {box,gaussian}."),
+ anno::unused()
+ ]]
+)
+ [[
+ anno::description("Node Group: convolution2d")
+ ]]
+{
+ // Not implemented: mx_blur_color4
+ core::color4 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export float2 mx_blur_vector2(
+ float2 mxp_in = float2(0.0, 0.0),
+ float mxp_size = float(0.0)
+ [[
+ anno::unused()
+ ]],
+ uniform core::mx_filter_type mxp_filtertype = core::mx_filter_type(core::mx_filter_type_box)
+ [[
+ anno::description("Enumeration {box,gaussian}."),
+ anno::unused()
+ ]]
+)
+ [[
+ anno::description("Node Group: convolution2d")
+ ]]
+{
+ // Not implemented: mx_blur_vector2
+ float2 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export float3 mx_blur_vector3(
+ float3 mxp_in = float3(0.0, 0.0, 0.0),
+ float mxp_size = float(0.0)
+ [[
+ anno::unused()
+ ]],
+ uniform core::mx_filter_type mxp_filtertype = core::mx_filter_type(core::mx_filter_type_box)
+ [[
+ anno::description("Enumeration {box,gaussian}."),
+ anno::unused()
+ ]]
+)
+ [[
+ anno::description("Node Group: convolution2d")
+ ]]
+{
+ // Not implemented: mx_blur_vector3
+ float3 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export float4 mx_blur_vector4(
+ float4 mxp_in = float4(0.0, 0.0, 0.0, 0.0),
+ float mxp_size = float(0.0)
+ [[
+ anno::unused()
+ ]],
+ uniform core::mx_filter_type mxp_filtertype = core::mx_filter_type(core::mx_filter_type_box)
+ [[
+ anno::description("Enumeration {box,gaussian}."),
+ anno::unused()
+ ]]
+)
+ [[
+ anno::description("Node Group: convolution2d")
+ ]]
+{
+ // Not implemented: mx_blur_vector4
+ float4 defaultValue = mxp_in;
+ return defaultValue;
+}
+
+export float3 mx_heighttonormal_vector3(
+ float mxp_in = float(0.0) [[ anno::unused() ]],
+ float mxp_scale = float(1.0) [[ anno::unused() ]]
+)
+ [[
+ anno::description("Node Group: convolution2d")
+ ]]
+{
+ // Not implemented: mx_heighttonormal_vector3
+ float3 defaultValue = float3(0.0, 1.0, 0.0);
+ return defaultValue;
+}
+
+export float mx_noise2d_float(
+ float mxp_amplitude = 1.0,
+ float mxp_pivot = 0.0,
+ float2 mxp_texcoord = swizzle::xy( ::state::texture_coordinate(0))
+)
+{
+ float value = noise::mx_perlin_noise_float(mxp_texcoord);
+ return value * mxp_amplitude + mxp_pivot;
+}
+
+export float2 mx_noise2d_float2(
+ float2 mxp_amplitude = float2(1.0),
+ float mxp_pivot = 0.0,
+ float2 mxp_texcoord = swizzle::xy( ::state::texture_coordinate(0))
+)
+{
+ float3 value = noise::mx_perlin_noise_float3(mxp_texcoord);
+ return swizzle::xy(value) * mxp_amplitude + mxp_pivot;
+}
+
+export float3 mx_noise2d_float3(
+ float3 mxp_amplitude = float3(1.0),
+ float mxp_pivot = 0.0,
+ float2 mxp_texcoord = swizzle::xy( ::state::texture_coordinate(0))
+)
+{
+ float3 value = noise::mx_perlin_noise_float3(mxp_texcoord);
+ return value * mxp_amplitude + mxp_pivot;
+}
+
+export float4 mx_noise2d_float4(
+ float4 mxp_amplitude = float4(1.0),
+ float mxp_pivot = 0.0,
+ float2 mxp_texcoord = swizzle::xy( ::state::texture_coordinate(0))
+)
+{
+ float3 v = noise::mx_perlin_noise_float3(mxp_texcoord);
+ float w = noise::mx_perlin_noise_float(mxp_texcoord + float2(19, 73));
+ return float4(v.x, v.y, v.z, w) * mxp_amplitude + mxp_pivot;
+}
+
+export float mx_noise3d_float(
+ float mxp_amplitude = 1.0,
+ float mxp_pivot = 0.0,
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position())
+)
+{
+ float value = noise::mx_perlin_noise_float(mxp_position);
+ return value * mxp_amplitude + mxp_pivot;
+}
+
+export float2 mx_noise3d_float2(
+ float2 mxp_amplitude = float2(1.0),
+ float mxp_pivot = 0.0,
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position())
+)
+{
+ float3 value = noise::mx_perlin_noise_float3(mxp_position);
+ return swizzle::xy(value) * mxp_amplitude + mxp_pivot;
+}
+
+export float3 mx_noise3d_float3(
+ float3 mxp_amplitude = float3(1.0),
+ float mxp_pivot = 0.0,
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position())
+)
+{
+ float3 value = noise::mx_perlin_noise_float3(mxp_position);
+ return value * mxp_amplitude + mxp_pivot;
+}
+
+export float4 mx_noise3d_float4(
+ float4 mxp_amplitude = float4(1.0),
+ float mxp_pivot = 0.0,
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position())
+)
+{
+ float3 v = noise::mx_perlin_noise_float3(mxp_position);
+ float w = noise::mx_perlin_noise_float(mxp_position + float3(19, 73, 29));
+ return float4(v.x, v.y, v.z, w) * mxp_amplitude + mxp_pivot;
+}
+
+export float mx_fractal3d_float(
+ float mxp_amplitude = 1.0,
+ int mxp_octaves = 3,
+ float mxp_lacunarity = 2.0,
+ float mxp_diminish= 0.5,
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position())
+)
+{
+ float v = noise::mx_fractal_noise_float(mxp_position, mxp_octaves, mxp_lacunarity, mxp_diminish);
+ return v * mxp_amplitude;
+}
+
+export float2 mx_fractal3d_float2(
+ float2 mxp_amplitude = float2(1.0),
+ int mxp_octaves = 3,
+ float mxp_lacunarity = 2.0,
+ float mxp_diminish= 0.5,
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position())
+)
+{
+ float2 v = noise::mx_fractal_noise_float2(mxp_position, mxp_octaves, mxp_lacunarity, mxp_diminish);
+ return v * mxp_amplitude;
+}
+
+export float3 mx_fractal3d_float3(
+ float3 mxp_amplitude = float3(1.0),
+ int mxp_octaves = 3,
+ float mxp_lacunarity = 2.0,
+ float mxp_diminish= 0.5,
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position())
+)
+{
+ float3 v = noise::mx_fractal_noise_float3(mxp_position, mxp_octaves, mxp_lacunarity, mxp_diminish);
+ return v * mxp_amplitude;
+}
+
+export float4 mx_fractal3d_float4(
+ float4 mxp_amplitude = float4(1.0),
+ int mxp_octaves = 3,
+ float mxp_lacunarity = 2.0,
+ float mxp_diminish= 0.5,
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position())
+)
+{
+ float4 v = noise::mx_fractal_noise_float4(mxp_position, mxp_octaves, mxp_lacunarity, mxp_diminish);
+ return v * mxp_amplitude;
+}
+
+export float mx_cellnoise2d_float(
+ float2 mxp_texcoord = swizzle::xy( ::state::texture_coordinate(0))
+)
+{
+ return noise::mx_cell_noise_float(mxp_texcoord);
+}
+
+export float mx_cellnoise3d_float(
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position())
+)
+{
+ return noise::mx_cell_noise_float(mxp_position);
+}
+
+export float mx_worleynoise2d_float(
+ float2 mxp_texcoord = swizzle::xy( ::state::texture_coordinate(0)),
+ float mxp_jitter = 1.0
+)
+{
+ return noise::mx_worley_noise_float(mxp_texcoord, mxp_jitter, 0);
+}
+
+export float2 mx_worleynoise2d_float2(
+ float2 mxp_texcoord = swizzle::xy( ::state::texture_coordinate(0)),
+ float mxp_jitter = 1.0
+)
+{
+ return noise::mx_worley_noise_float2(mxp_texcoord, mxp_jitter, 0);
+}
+
+export float3 mx_worleynoise2d_float3(
+ float2 mxp_texcoord = swizzle::xy( ::state::texture_coordinate(0)),
+ float mxp_jitter = 1.0
+)
+{
+ return noise::mx_worley_noise_float3(mxp_texcoord, mxp_jitter, 0);
+}
+
+export float mx_worleynoise3d_float(
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
+ float mxp_jitter = 1.0
+)
+{
+ return noise::mx_worley_noise_float(mxp_position, mxp_jitter, 0);
+}
+
+export float2 mx_worleynoise3d_float2(
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
+ float mxp_jitter = 1.0
+)
+{
+ return noise::mx_worley_noise_float2(mxp_position, mxp_jitter, 0);
+}
+
+export float3 mx_worleynoise3d_float3(
+ float3 mxp_position = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
+ float mxp_jitter = 1.0
+)
+{
+ return noise::mx_worley_noise_float3(mxp_position, mxp_jitter, 0);
+}
diff --git a/Sources/MXResources/libraries/mdl/materialx/stdlib_1_7.mdl b/Sources/MXResources/libraries/mdl/materialx/stdlib_1_7.mdl
new file mode 100644
index 00000000..019bbb15
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/stdlib_1_7.mdl
@@ -0,0 +1,18 @@
+//
+// Copyright Contributors to the MaterialX Project
+// SPDX-License-Identifier: Apache-2.0
+//
+// MDL implementation of all Standard Source Nodes of
+// MaterialX: An Open Standard for Network-Based CG Object Looks
+// Document v1.37 REV2, January 19, 2020
+// www.materialx.org
+// in
+// NVIDIA Material Definition Language 1.7
+// Language Specification
+// Document version 1.7.2, January 17, 2022
+// www.nvidia.com/mdl
+
+mdl 1.7;
+
+// forward all unchanged definitions from the previous version
+export using .::stdlib_1_6 import *;
diff --git a/Sources/MXResources/libraries/mdl/materialx/stdlib_1_8.mdl b/Sources/MXResources/libraries/mdl/materialx/stdlib_1_8.mdl
new file mode 100644
index 00000000..0173cfcf
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/stdlib_1_8.mdl
@@ -0,0 +1,449 @@
+//
+// Copyright Contributors to the MaterialX Project
+// SPDX-License-Identifier: Apache-2.0
+//
+// MDL implementation of all Standard Source Nodes of
+// MaterialX: An Open Standard for Network-Based CG Object Looks
+// Document v1.37 REV2, January 19, 2020
+// www.materialx.org
+// in
+// NVIDIA Material Definition Language 1.8
+// Language Specification
+// Document version 1.8.2, May 24, 2023
+// www.nvidia.com/mdl
+
+mdl 1.8;
+
+import ::anno::*;
+import ::math::*;
+import ::scene::*;
+import ::state::*;
+
+import .::core::*;
+import .::noise::*;
+import .::swizzle::*;
+import .::hsv::*;
+
+// Changes since MDL 1.7
+// - Scene data lookups used for PrimVar readers allow non-literal string names
+
+// forward all unchanged definitions from the previous version
+export using .::stdlib_1_7 import mx_surfacematerial;
+export using .::stdlib_1_7 import mx_surface_unlit;
+export using .::stdlib_1_7 import mx_image_float;
+export using .::stdlib_1_7 import mx_image_color3;
+export using .::stdlib_1_7 import mx_image_color4;
+export using .::stdlib_1_7 import mx_image_vector2;
+export using .::stdlib_1_7 import mx_image_vector3;
+export using .::stdlib_1_7 import mx_image_vector4;
+export using .::stdlib_1_7 import mx_constant_float;
+export using .::stdlib_1_7 import mx_constant_color3;
+export using .::stdlib_1_7 import mx_constant_color4;
+export using .::stdlib_1_7 import mx_constant_vector2;
+export using .::stdlib_1_7 import mx_constant_vector3;
+export using .::stdlib_1_7 import mx_constant_vector4;
+export using .::stdlib_1_7 import mx_constant_boolean;
+export using .::stdlib_1_7 import mx_constant_integer;
+export using .::stdlib_1_7 import mx_constant_matrix33;
+export using .::stdlib_1_7 import mx_constant_matrix44;
+export using .::stdlib_1_7 import mx_constant_string;
+export using .::stdlib_1_7 import mx_constant_filename;
+export using .::stdlib_1_7 import mx_ramplr_float;
+export using .::stdlib_1_7 import mx_ramplr_color3;
+export using .::stdlib_1_7 import mx_ramplr_color4;
+export using .::stdlib_1_7 import mx_ramplr_vector2;
+export using .::stdlib_1_7 import mx_ramplr_vector3;
+export using .::stdlib_1_7 import mx_ramplr_vector4;
+export using .::stdlib_1_7 import mx_ramptb_float;
+export using .::stdlib_1_7 import mx_ramptb_color3;
+export using .::stdlib_1_7 import mx_ramptb_color4;
+export using .::stdlib_1_7 import mx_ramptb_vector2;
+export using .::stdlib_1_7 import mx_ramptb_vector3;
+export using .::stdlib_1_7 import mx_ramptb_vector4;
+export using .::stdlib_1_7 import mx_splitlr_float;
+export using .::stdlib_1_7 import mx_splitlr_color3;
+export using .::stdlib_1_7 import mx_splitlr_color4;
+export using .::stdlib_1_7 import mx_splitlr_vector2;
+export using .::stdlib_1_7 import mx_splitlr_vector3;
+export using .::stdlib_1_7 import mx_splitlr_vector4;
+export using .::stdlib_1_7 import mx_splittb_float;
+export using .::stdlib_1_7 import mx_splittb_color3;
+export using .::stdlib_1_7 import mx_splittb_color4;
+export using .::stdlib_1_7 import mx_splittb_vector2;
+export using .::stdlib_1_7 import mx_splittb_vector3;
+export using .::stdlib_1_7 import mx_splittb_vector4;
+export using .::stdlib_1_7 import mx_position_vector3;
+export using .::stdlib_1_7 import mx_normal_vector3;
+export using .::stdlib_1_7 import mx_tangent_vector3;
+export using .::stdlib_1_7 import mx_bitangent_vector3;
+export using .::stdlib_1_7 import mx_texcoord_vector2;
+export using .::stdlib_1_7 import mx_texcoord_vector3;
+export using .::stdlib_1_7 import mx_geomcolor_float;
+export using .::stdlib_1_7 import mx_geomcolor_color3;
+export using .::stdlib_1_7 import mx_geomcolor_color4;
+export using .::stdlib_1_7 import mx_ambientocclusion_float;
+export using .::stdlib_1_7 import mx_frame_float;
+export using .::stdlib_1_7 import mx_time_float;
+export using .::stdlib_1_7 import mx_modulo_color3;
+export using .::stdlib_1_7 import mx_modulo_color4;
+export using .::stdlib_1_7 import mx_modulo_color3FA;
+export using .::stdlib_1_7 import mx_modulo_color4FA;
+export using .::stdlib_1_7 import mx_invert_color4;
+export using .::stdlib_1_7 import mx_invert_color4FA;
+export using .::stdlib_1_7 import mx_absval_color4;
+export using .::stdlib_1_7 import mx_floor_color3;
+export using .::stdlib_1_7 import mx_floor_color4;
+export using .::stdlib_1_7 import mx_ceil_color3;
+export using .::stdlib_1_7 import mx_ceil_color4;
+export using .::stdlib_1_7 import mx_round_color3;
+export using .::stdlib_1_7 import mx_round_color4;
+export using .::stdlib_1_7 import mx_power_color4;
+export using .::stdlib_1_7 import mx_power_color4FA;
+export using .::stdlib_1_7 import mx_sin_float;
+export using .::stdlib_1_7 import mx_cos_float;
+export using .::stdlib_1_7 import mx_tan_float;
+export using .::stdlib_1_7 import mx_asin_float;
+export using .::stdlib_1_7 import mx_acos_float;
+export using .::stdlib_1_7 import mx_atan2_float;
+export using .::stdlib_1_7 import mx_sin_vector2;
+export using .::stdlib_1_7 import mx_cos_vector2;
+export using .::stdlib_1_7 import mx_tan_vector2;
+export using .::stdlib_1_7 import mx_asin_vector2;
+export using .::stdlib_1_7 import mx_acos_vector2;
+export using .::stdlib_1_7 import mx_atan2_vector2;
+export using .::stdlib_1_7 import mx_sin_vector3;
+export using .::stdlib_1_7 import mx_cos_vector3;
+export using .::stdlib_1_7 import mx_tan_vector3;
+export using .::stdlib_1_7 import mx_asin_vector3;
+export using .::stdlib_1_7 import mx_acos_vector3;
+export using .::stdlib_1_7 import mx_atan2_vector3;
+export using .::stdlib_1_7 import mx_sin_vector4;
+export using .::stdlib_1_7 import mx_cos_vector4;
+export using .::stdlib_1_7 import mx_tan_vector4;
+export using .::stdlib_1_7 import mx_asin_vector4;
+export using .::stdlib_1_7 import mx_acos_vector4;
+export using .::stdlib_1_7 import mx_atan2_vector4;
+export using .::stdlib_1_7 import mx_sqrt_float;
+export using .::stdlib_1_7 import mx_ln_float;
+export using .::stdlib_1_7 import mx_exp_float;
+export using .::stdlib_1_7 import mx_sqrt_vector2;
+export using .::stdlib_1_7 import mx_ln_vector2;
+export using .::stdlib_1_7 import mx_exp_vector2;
+export using .::stdlib_1_7 import mx_sqrt_vector3;
+export using .::stdlib_1_7 import mx_ln_vector3;
+export using .::stdlib_1_7 import mx_exp_vector3;
+export using .::stdlib_1_7 import mx_sqrt_vector4;
+export using .::stdlib_1_7 import mx_ln_vector4;
+export using .::stdlib_1_7 import mx_exp_vector4;
+export using .::stdlib_1_7 import mx_sign_color3;
+export using .::stdlib_1_7 import mx_sign_color4;
+export using .::stdlib_1_7 import mx_clamp_color4;
+export using .::stdlib_1_7 import mx_clamp_color4FA;
+export using .::stdlib_1_7 import mx_min_color4;
+export using .::stdlib_1_7 import mx_min_color4;
+export using .::stdlib_1_7 import mx_max_color4;
+export using .::stdlib_1_7 import mx_max_color4;
+export using .::stdlib_1_7 import mx_transformpoint_vector3;
+export using .::stdlib_1_7 import mx_transformvector_vector3;
+export using .::stdlib_1_7 import mx_transformnormal_vector3;
+export using .::stdlib_1_7 import mx_transformmatrix_vector2M3;
+export using .::stdlib_1_7 import mx_transformmatrix_vector3;
+export using .::stdlib_1_7 import mx_transformmatrix_vector3M4;
+export using .::stdlib_1_7 import mx_transformmatrix_vector4;
+export using .::stdlib_1_7 import mx_normalmap_float;
+export using .::stdlib_1_7 import mx_normalmap_vector2;
+export using .::stdlib_1_7 import mx_transpose_matrix33;
+export using .::stdlib_1_7 import mx_transpose_matrix44;
+export using .::stdlib_1_7 import mx_determinant_matrix33;
+export using .::stdlib_1_7 import mx_determinant_matrix44;
+export using .::stdlib_1_7 import mx_invertmatrix_matrix33;
+export using .::stdlib_1_7 import mx_invertmatrix_matrix44;
+export using .::stdlib_1_7 import mx_rotate2d_vector2;
+export using .::stdlib_1_7 import mx_rotate3d_vector3;
+export using .::stdlib_1_7 import mx_remap_float;
+export using .::stdlib_1_7 import mx_remap_color3;
+export using .::stdlib_1_7 import mx_remap_color4;
+export using .::stdlib_1_7 import mx_remap_vector2;
+export using .::stdlib_1_7 import mx_remap_vector3;
+export using .::stdlib_1_7 import mx_remap_vector4;
+export using .::stdlib_1_7 import mx_remap_color3FA;
+export using .::stdlib_1_7 import mx_remap_color4FA;
+export using .::stdlib_1_7 import mx_remap_vector2FA;
+export using .::stdlib_1_7 import mx_remap_vector3FA;
+export using .::stdlib_1_7 import mx_remap_vector4FA;
+export using .::stdlib_1_7 import mx_smoothstep_float;
+export using .::stdlib_1_7 import mx_smoothstep_color3;
+export using .::stdlib_1_7 import mx_smoothstep_color4;
+export using .::stdlib_1_7 import mx_smoothstep_vector2;
+export using .::stdlib_1_7 import mx_smoothstep_vector3;
+export using .::stdlib_1_7 import mx_smoothstep_vector4;
+export using .::stdlib_1_7 import mx_smoothstep_color3FA;
+export using .::stdlib_1_7 import mx_smoothstep_color4FA;
+export using .::stdlib_1_7 import mx_smoothstep_vector2FA;
+export using .::stdlib_1_7 import mx_smoothstep_vector3FA;
+export using .::stdlib_1_7 import mx_smoothstep_vector4FA;
+export using .::stdlib_1_7 import mx_curveadjust_float;
+export using .::stdlib_1_7 import mx_curveadjust_color3;
+export using .::stdlib_1_7 import mx_curveadjust_color4;
+export using .::stdlib_1_7 import mx_curveadjust_vector2;
+export using .::stdlib_1_7 import mx_curveadjust_vector3;
+export using .::stdlib_1_7 import mx_curveadjust_vector4;
+export using .::stdlib_1_7 import mx_luminance_color3;
+export using .::stdlib_1_7 import mx_luminance_color4;
+export using .::stdlib_1_7 import mx_rgbtohsv_color3;
+export using .::stdlib_1_7 import mx_rgbtohsv_color4;
+export using .::stdlib_1_7 import mx_hsvtorgb_color3;
+export using .::stdlib_1_7 import mx_hsvtorgb_color4;
+export using .::stdlib_1_7 import mx_premult_color4;
+export using .::stdlib_1_7 import mx_unpremult_color4;
+export using .::stdlib_1_7 import mx_plus_color4;
+export using .::stdlib_1_7 import mx_minus_color4;
+export using .::stdlib_1_7 import mx_difference_color4;
+export using .::stdlib_1_7 import mx_burn_float;
+export using .::stdlib_1_7 import mx_burn_color3;
+export using .::stdlib_1_7 import mx_burn_color4;
+export using .::stdlib_1_7 import mx_dodge_float;
+export using .::stdlib_1_7 import mx_dodge_color3;
+export using .::stdlib_1_7 import mx_dodge_color4;
+export using .::stdlib_1_7 import mx_screen_color4;
+export using .::stdlib_1_7 import mx_disjointover_color4;
+export using .::stdlib_1_7 import mx_in_color4;
+export using .::stdlib_1_7 import mx_mask_color4;
+export using .::stdlib_1_7 import mx_matte_color4;
+export using .::stdlib_1_7 import mx_out_color4;
+export using .::stdlib_1_7 import mx_over_color4;
+export using .::stdlib_1_7 import mx_mix_color4;
+export using .::stdlib_1_7 import mx_mix_color4_color4;
+export using .::stdlib_1_7 import mx_mix_surfaceshader;
+export using .::stdlib_1_7 import mx_mix_volumeshader;
+export using .::stdlib_1_7 import mx_mix_displacementshader;
+export using .::stdlib_1_7 import mx_ifgreater_float;
+export using .::stdlib_1_7 import mx_ifgreater_color3;
+export using .::stdlib_1_7 import mx_ifgreater_color4;
+export using .::stdlib_1_7 import mx_ifgreater_vector2;
+export using .::stdlib_1_7 import mx_ifgreater_vector3;
+export using .::stdlib_1_7 import mx_ifgreater_vector4;
+export using .::stdlib_1_7 import mx_ifgreater_floatI;
+export using .::stdlib_1_7 import mx_ifgreater_color3I;
+export using .::stdlib_1_7 import mx_ifgreater_color4I;
+export using .::stdlib_1_7 import mx_ifgreater_vector2I;
+export using .::stdlib_1_7 import mx_ifgreater_vector3I;
+export using .::stdlib_1_7 import mx_ifgreater_vector4I;
+export using .::stdlib_1_7 import mx_ifgreatereq_float;
+export using .::stdlib_1_7 import mx_ifgreatereq_color3;
+export using .::stdlib_1_7 import mx_ifgreatereq_color4;
+export using .::stdlib_1_7 import mx_ifgreatereq_vector2;
+export using .::stdlib_1_7 import mx_ifgreatereq_vector3;
+export using .::stdlib_1_7 import mx_ifgreatereq_vector4;
+export using .::stdlib_1_7 import mx_ifgreatereq_floatI;
+export using .::stdlib_1_7 import mx_ifgreatereq_color3I;
+export using .::stdlib_1_7 import mx_ifgreatereq_color4I;
+export using .::stdlib_1_7 import mx_ifgreatereq_vector2I;
+export using .::stdlib_1_7 import mx_ifgreatereq_vector3I;
+export using .::stdlib_1_7 import mx_ifgreatereq_vector4I;
+export using .::stdlib_1_7 import mx_ifequal_float;
+export using .::stdlib_1_7 import mx_ifequal_color3;
+export using .::stdlib_1_7 import mx_ifequal_color4;
+export using .::stdlib_1_7 import mx_ifequal_vector2;
+export using .::stdlib_1_7 import mx_ifequal_vector3;
+export using .::stdlib_1_7 import mx_ifequal_vector4;
+export using .::stdlib_1_7 import mx_ifequal_floatI;
+export using .::stdlib_1_7 import mx_ifequal_color3I;
+export using .::stdlib_1_7 import mx_ifequal_color4I;
+export using .::stdlib_1_7 import mx_ifequal_vector2I;
+export using .::stdlib_1_7 import mx_ifequal_vector3I;
+export using .::stdlib_1_7 import mx_ifequal_vector4I;
+export using .::stdlib_1_7 import mx_ifequal_floatB;
+export using .::stdlib_1_7 import mx_ifequal_color3B;
+export using .::stdlib_1_7 import mx_ifequal_color4B;
+export using .::stdlib_1_7 import mx_ifequal_vector2B;
+export using .::stdlib_1_7 import mx_ifequal_vector3B;
+export using .::stdlib_1_7 import mx_ifequal_vector4B;
+export using .::stdlib_1_7 import mx_switch_float;
+export using .::stdlib_1_7 import mx_switch_color3;
+export using .::stdlib_1_7 import mx_switch_color4;
+export using .::stdlib_1_7 import mx_switch_vector2;
+export using .::stdlib_1_7 import mx_switch_vector3;
+export using .::stdlib_1_7 import mx_switch_vector4;
+export using .::stdlib_1_7 import mx_switch_floatI;
+export using .::stdlib_1_7 import mx_switch_color3I;
+export using .::stdlib_1_7 import mx_switch_color4I;
+export using .::stdlib_1_7 import mx_switch_vector2I;
+export using .::stdlib_1_7 import mx_switch_vector3I;
+export using .::stdlib_1_7 import mx_switch_vector4I;
+export using .::stdlib_1_7 import mx_convert_float_color3;
+export using .::stdlib_1_7 import mx_convert_float_color4;
+export using .::stdlib_1_7 import mx_convert_float_vector2;
+export using .::stdlib_1_7 import mx_convert_float_vector3;
+export using .::stdlib_1_7 import mx_convert_float_vector4;
+export using .::stdlib_1_7 import mx_convert_vector2_vector3;
+export using .::stdlib_1_7 import mx_convert_vector3_color3;
+export using .::stdlib_1_7 import mx_convert_vector3_vector2;
+export using .::stdlib_1_7 import mx_convert_vector3_vector4;
+export using .::stdlib_1_7 import mx_convert_vector4_color4;
+export using .::stdlib_1_7 import mx_convert_vector4_vector3;
+export using .::stdlib_1_7 import mx_convert_color3_vector3;
+export using .::stdlib_1_7 import mx_convert_color4_vector4;
+export using .::stdlib_1_7 import mx_convert_color3_color4;
+export using .::stdlib_1_7 import mx_convert_color4_color3;
+export using .::stdlib_1_7 import mx_convert_boolean_float;
+export using .::stdlib_1_7 import mx_convert_integer_float;
+export using .::stdlib_1_7 import mx_combine2_vector2;
+export using .::stdlib_1_7 import mx_combine2_color4CF;
+export using .::stdlib_1_7 import mx_combine2_vector4VF;
+export using .::stdlib_1_7 import mx_combine2_color4CC;
+export using .::stdlib_1_7 import mx_combine2_vector4VV;
+export using .::stdlib_1_7 import mx_combine3_color3;
+export using .::stdlib_1_7 import mx_combine3_vector3;
+export using .::stdlib_1_7 import mx_combine4_color4;
+export using .::stdlib_1_7 import mx_combine4_vector4;
+export using .::stdlib_1_7 import mx_creatematrix_vector3_matrix33;
+export using .::stdlib_1_7 import mx_creatematrix_vector3_matrix44;
+export using .::stdlib_1_7 import mx_creatematrix_vector4_matrix44;
+export using .::stdlib_1_7 import mx_blur_float;
+export using .::stdlib_1_7 import mx_blur_color3;
+export using .::stdlib_1_7 import mx_blur_color4;
+export using .::stdlib_1_7 import mx_blur_vector2;
+export using .::stdlib_1_7 import mx_blur_vector3;
+export using .::stdlib_1_7 import mx_blur_vector4;
+export using .::stdlib_1_7 import mx_heighttonormal_vector3;
+export using .::stdlib_1_7 import mx_noise2d_float;
+export using .::stdlib_1_7 import mx_noise2d_float2;
+export using .::stdlib_1_7 import mx_noise2d_float3;
+export using .::stdlib_1_7 import mx_noise2d_float4;
+export using .::stdlib_1_7 import mx_noise3d_float;
+export using .::stdlib_1_7 import mx_noise3d_float2;
+export using .::stdlib_1_7 import mx_noise3d_float3;
+export using .::stdlib_1_7 import mx_noise3d_float4;
+export using .::stdlib_1_7 import mx_fractal3d_float;
+export using .::stdlib_1_7 import mx_fractal3d_float2;
+export using .::stdlib_1_7 import mx_fractal3d_float3;
+export using .::stdlib_1_7 import mx_fractal3d_float4;
+export using .::stdlib_1_7 import mx_cellnoise2d_float;
+export using .::stdlib_1_7 import mx_cellnoise3d_float;
+export using .::stdlib_1_7 import mx_worleynoise2d_float;
+export using .::stdlib_1_7 import mx_worleynoise2d_float2;
+export using .::stdlib_1_7 import mx_worleynoise2d_float3;
+export using .::stdlib_1_7 import mx_worleynoise3d_float;
+export using .::stdlib_1_7 import mx_worleynoise3d_float2;
+export using .::stdlib_1_7 import mx_worleynoise3d_float3;
+
+// NOTE: Not planned to be implemented.
+export using .::stdlib_1_7 import mx_geompropvalue_string;
+
+// NOTE: No boolean scene data in MDL so it's mapped to integer.
+// Returns false if the scene data is zero, true otherwise.
+export bool mx_geompropvalue_boolean(
+ uniform string mxp_geomprop = string(""),
+ bool mxp_default = bool(false)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ int defaultValue = mxp_default ? 1 : 0;
+ return scene::data_lookup_int(mxp_geomprop, defaultValue) == 0 ? false : true;
+}
+
+export int mx_geompropvalue_integer(
+ uniform string mxp_geomprop = string(""),
+ int mxp_default = int(0)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ return scene::data_lookup_int(mxp_geomprop, mxp_default);
+}
+
+export float mx_geompropvalue_float(
+ uniform string mxp_geomprop = string(""),
+ float mxp_default = float(0.0)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ return scene::data_lookup_float(mxp_geomprop, mxp_default);
+}
+
+export color mx_geompropvalue_color3(
+ uniform string mxp_geomprop = string(""),
+ color mxp_default = color(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ return scene::data_lookup_color(mxp_geomprop, mxp_default);
+}
+
+export core::color4 mx_geompropvalue_color4(
+ uniform string mxp_geomprop = string(""),
+ core::color4 mxp_default = core::mk_color4(0.0, 0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ float3 rgbValue = float3(mxp_default.rgb);
+ float4 defaultValue = float4(rgbValue.x, rgbValue.y, rgbValue.z, mxp_default.a);
+ float4 value = scene::data_lookup_float4(mxp_geomprop, defaultValue);
+ return core::mk_color4(value.x, value.y, value.z, value.w);
+}
+
+export float2 mx_geompropvalue_vector2(
+ uniform string mxp_geomprop = string(""),
+ float2 mxp_default = float2(0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ return scene::data_lookup_float2(mxp_geomprop, mxp_default);
+}
+
+export float3 mx_geompropvalue_vector3(
+ uniform string mxp_geomprop = string(""),
+ float3 mxp_default = float3(0.0, 0.0, 0.0)
+)
+ [[
+ anno::description("Node Group: geometric")
+ ]]
+{
+ return scene::data_lookup_float3(mxp_geomprop, mxp_default);
+}
+
+export float4 mx_geompropvalue_vector4(
+ uniform string mxp_geomprop = string(""),
+ float4 mxp_default = float4(0.0, 0.0, 0.0, 0.0)
+)
+{
+ return scene::data_lookup_float4(mxp_geomprop, mxp_default);
+}
+
+export float3 mx_viewdirection_vector3(
+ uniform core::mx_coordinatespace_type mxp_space = core::mx_coordinatespace_type_world
+ [[
+ anno::description("Enumeration {model,object,world}."),
+ anno::unused()
+ ]]
+)
+ [[
+ anno::description("Node Group: nprlib")
+ ]]
+{
+ float3 internal_space_direction =
+ state::position() - scene::data_lookup_float3("CAMERA_POSITION", float3(0.0, 0.0, 0.0));
+
+ if (mxp_space == core::mx_coordinatespace_type_world)
+ return math::normalize(state::transform_vector(
+ ::state::coordinate_internal,
+ ::state::coordinate_world,
+ internal_space_direction));
+ else
+ return math::normalize(state::transform_vector(
+ ::state::coordinate_internal,
+ ::state::coordinate_object,
+ internal_space_direction));
+}
diff --git a/Sources/MXResources/libraries/mdl/materialx/swizzle.mdl b/Sources/MXResources/libraries/mdl/materialx/swizzle.mdl
new file mode 100644
index 00000000..fb87022a
--- /dev/null
+++ b/Sources/MXResources/libraries/mdl/materialx/swizzle.mdl
@@ -0,0 +1,1007 @@
+/*
+ * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Support functions to simplify conversions between vector types with swizzles
+// Supported argument types: float (with implied field name x), float2, float3,
+// float4, color, core::color4 (as RGB and RGBA)
+// Supported return types: float, float2, float3, float4
+
+mdl 1.6;
+
+import .::core::*;
+
+// Swizzles with float return type
+export float x( float a) { return a; }
+
+export float x( float2 a) { return a.x; }
+export float y( float2 a) { return a.y; }
+
+export float x( float3 a) { return a.x; }
+export float y( float3 a) { return a.y; }
+export float z( float3 a) { return a.z; }
+
+export float x( float4 a) { return a.x; }
+export float y( float4 a) { return a.y; }
+export float z( float4 a) { return a.z; }
+export float w( float4 a) { return a.w; }
+
+export float x( color a) { return x( float3(a)); }
+export float y( color a) { return y( float3(a)); }
+export float z( color a) { return z( float3(a)); }
+
+export float x( core::color4 a) { return float3( a.rgb).x; }
+export float y( core::color4 a) { return float3( a.rgb).y; }
+export float z( core::color4 a) { return float3( a.rgb).z; }
+export float w( core::color4 a) { return a.a; }
+
+// Swizzles with float2 return type
+export float2 xx( float a) { return float2( a, a); }
+
+export float2 xx( float2 a) { return float2( a.x, a.x); }
+export float2 xy( float2 a) { return float2( a.x, a.y); }
+export float2 yx( float2 a) { return float2( a.y, a.x); }
+export float2 yy( float2 a) { return float2( a.y, a.y); }
+
+export float2 xx( float3 a) { return float2( a.x, a.x); }
+export float2 xy( float3 a) { return float2( a.x, a.y); }
+export float2 xz( float3 a) { return float2( a.x, a.z); }
+export float2 yx( float3 a) { return float2( a.y, a.x); }
+export float2 yy( float3 a) { return float2( a.y, a.y); }
+export float2 yz( float3 a) { return float2( a.y, a.z); }
+export float2 zx( float3 a) { return float2( a.z, a.x); }
+export float2 zy( float3 a) { return float2( a.z, a.y); }
+export float2 zz( float3 a) { return float2( a.z, a.z); }
+
+export float2 xx( float4 a) { return float2( a.x, a.x); }
+export float2 xy( float4 a) { return float2( a.x, a.y); }
+export float2 xz( float4 a) { return float2( a.x, a.z); }
+export float2 xw( float4 a) { return float2( a.x, a.w); }
+export float2 yx( float4 a) { return float2( a.y, a.x); }
+export float2 yy( float4 a) { return float2( a.y, a.y); }
+export float2 yz( float4 a) { return float2( a.y, a.z); }
+export float2 yw( float4 a) { return float2( a.y, a.w); }
+export float2 zx( float4 a) { return float2( a.z, a.x); }
+export float2 zy( float4 a) { return float2( a.z, a.y); }
+export float2 zz( float4 a) { return float2( a.z, a.z); }
+export float2 zw( float4 a) { return float2( a.z, a.w); }
+export float2 wx( float4 a) { return float2( a.w, a.x); }
+export float2 wy( float4 a) { return float2( a.w, a.y); }
+export float2 wz( float4 a) { return float2( a.w, a.z); }
+export float2 ww( float4 a) { return float2( a.w, a.w); }
+
+export float2 xx( color a) { return xx( float3(a)); }
+export float2 xy( color a) { return xy( float3(a)); }
+export float2 xz( color a) { return xz( float3(a)); }
+export float2 yx( color a) { return yx( float3(a)); }
+export float2 yy( color a) { return yy( float3(a)); }
+export float2 yz( color a) { return yz( float3(a)); }
+export float2 zx( color a) { return zx( float3(a)); }
+export float2 zy( color a) { return zy( float3(a)); }
+export float2 zz( color a) { return zz( float3(a)); }
+
+export float2 xx( core::color4 a) { return xx( float3( a.rgb)); }
+export float2 xy( core::color4 a) { return xy( float3( a.rgb)); }
+export float2 xz( core::color4 a) { return xz( float3( a.rgb)); }
+export float2 xw( core::color4 a) { return float2( float3( a.rgb).x, a.a); }
+export float2 yx( core::color4 a) { return yx( float3( a.rgb)); }
+export float2 yy( core::color4 a) { return yy( float3( a.rgb)); }
+export float2 yz( core::color4 a) { return yz( float3( a.rgb)); }
+export float2 yw( core::color4 a) { return float2( float3( a.rgb).y, a.a); }
+export float2 zx( core::color4 a) { return zx( float3( a.rgb)); }
+export float2 zy( core::color4 a) { return zy( float3( a.rgb)); }
+export float2 zz( core::color4 a) { return zz( float3( a.rgb)); }
+export float2 zw( core::color4 a) { return float2( float3( a.rgb).z, a.a); }
+export float2 wx( core::color4 a) { return float2( a.a, float3( a.rgb).x); }
+export float2 wy( core::color4 a) { return float2( a.a, float3( a.rgb).y); }
+export float2 wz( core::color4 a) { return float2( a.a, float3( a.rgb).z); }
+export float2 ww( core::color4 a) { return float2( a.a, a.a); }
+
+// Swizzles with float3 return type
+export float3 xxx( float a) { return float3( a, a, a); }
+
+export float3 xxx( float2 a) { return float3( a.x, a.x, a.x); }
+export float3 xxy( float2 a) { return float3( a.x, a.x, a.y); }
+export float3 xyx( float2 a) { return float3( a.x, a.y, a.x); }
+export float3 xyy( float2 a) { return float3( a.x, a.y, a.y); }
+export float3 yxx( float2 a) { return float3( a.y, a.x, a.x); }
+export float3 yxy( float2 a) { return float3( a.y, a.x, a.y); }
+export float3 yyx( float2 a) { return float3( a.y, a.y, a.x); }
+export float3 yyy( float2 a) { return float3( a.y, a.y, a.y); }
+
+export float3 xxx( float3 a) { return float3( a.x, a.x, a.x); }
+export float3 xxy( float3 a) { return float3( a.x, a.x, a.y); }
+export float3 xxz( float3 a) { return float3( a.x, a.x, a.z); }
+export float3 xyx( float3 a) { return float3( a.x, a.y, a.x); }
+export float3 xyy( float3 a) { return float3( a.x, a.y, a.y); }
+export float3 xyz( float3 a) { return float3( a.x, a.y, a.z); }
+export float3 xzx( float3 a) { return float3( a.x, a.z, a.x); }
+export float3 xzy( float3 a) { return float3( a.x, a.z, a.y); }
+export float3 xzz( float3 a) { return float3( a.x, a.z, a.z); }
+export float3 yxx( float3 a) { return float3( a.y, a.x, a.x); }
+export float3 yxy( float3 a) { return float3( a.y, a.x, a.y); }
+export float3 yxz( float3 a) { return float3( a.y, a.x, a.z); }
+export float3 yyx( float3 a) { return float3( a.y, a.y, a.x); }
+export float3 yyy( float3 a) { return float3( a.y, a.y, a.y); }
+export float3 yyz( float3 a) { return float3( a.y, a.y, a.z); }
+export float3 yzx( float3 a) { return float3( a.y, a.z, a.x); }
+export float3 yzy( float3 a) { return float3( a.y, a.z, a.y); }
+export float3 yzz( float3 a) { return float3( a.y, a.z, a.z); }
+export float3 zxx( float3 a) { return float3( a.z, a.x, a.x); }
+export float3 zxy( float3 a) { return float3( a.z, a.x, a.y); }
+export float3 zxz( float3 a) { return float3( a.z, a.x, a.z); }
+export float3 zyx( float3 a) { return float3( a.z, a.y, a.x); }
+export float3 zyy( float3 a) { return float3( a.z, a.y, a.y); }
+export float3 zyz( float3 a) { return float3( a.z, a.y, a.z); }
+export float3 zzx( float3 a) { return float3( a.z, a.z, a.x); }
+export float3 zzy( float3 a) { return float3( a.z, a.z, a.y); }
+export float3 zzz( float3 a) { return float3( a.z, a.z, a.z); }
+
+export float3 xxx( float4 a) { return float3( a.x, a.x, a.x); }
+export float3 xxy( float4 a) { return float3( a.x, a.x, a.y); }
+export float3 xxz( float4 a) { return float3( a.x, a.x, a.z); }
+export float3 xxw( float4 a) { return float3( a.x, a.x, a.w); }
+export float3 xyx( float4 a) { return float3( a.x, a.y, a.x); }
+export float3 xyy( float4 a) { return float3( a.x, a.y, a.y); }
+export float3 xyz( float4 a) { return float3( a.x, a.y, a.z); }
+export float3 xyw( float4 a) { return float3( a.x, a.y, a.w); }
+export float3 xzx( float4 a) { return float3( a.x, a.z, a.x); }
+export float3 xzy( float4 a) { return float3( a.x, a.z, a.y); }
+export float3 xzz( float4 a) { return float3( a.x, a.z, a.z); }
+export float3 xzw( float4 a) { return float3( a.x, a.z, a.w); }
+export float3 xwx( float4 a) { return float3( a.x, a.w, a.x); }
+export float3 xwy( float4 a) { return float3( a.x, a.w, a.y); }
+export float3 xwz( float4 a) { return float3( a.x, a.w, a.z); }
+export float3 xww( float4 a) { return float3( a.x, a.w, a.w); }
+export float3 yxx( float4 a) { return float3( a.y, a.x, a.x); }
+export float3 yxy( float4 a) { return float3( a.y, a.x, a.y); }
+export float3 yxz( float4 a) { return float3( a.y, a.x, a.z); }
+export float3 yxw( float4 a) { return float3( a.y, a.x, a.w); }
+export float3 yyx( float4 a) { return float3( a.y, a.y, a.x); }
+export float3 yyy( float4 a) { return float3( a.y, a.y, a.y); }
+export float3 yyz( float4 a) { return float3( a.y, a.y, a.z); }
+export float3 yyw( float4 a) { return float3( a.y, a.y, a.w); }
+export float3 yzx( float4 a) { return float3( a.y, a.z, a.x); }
+export float3 yzy( float4 a) { return float3( a.y, a.z, a.y); }
+export float3 yzz( float4 a) { return float3( a.y, a.z, a.z); }
+export float3 yzw( float4 a) { return float3( a.y, a.z, a.w); }
+export float3 ywx( float4 a) { return float3( a.y, a.w, a.x); }
+export float3 ywy( float4 a) { return float3( a.y, a.w, a.y); }
+export float3 ywz( float4 a) { return float3( a.y, a.w, a.z); }
+export float3 yww( float4 a) { return float3( a.y, a.w, a.w); }
+export float3 zxx( float4 a) { return float3( a.z, a.x, a.x); }
+export float3 zxy( float4 a) { return float3( a.z, a.x, a.y); }
+export float3 zxz( float4 a) { return float3( a.z, a.x, a.z); }
+export float3 zxw( float4 a) { return float3( a.z, a.x, a.w); }
+export float3 zyx( float4 a) { return float3( a.z, a.y, a.x); }
+export float3 zyy( float4 a) { return float3( a.z, a.y, a.y); }
+export float3 zyz( float4 a) { return float3( a.z, a.y, a.z); }
+export float3 zyw( float4 a) { return float3( a.z, a.y, a.w); }
+export float3 zzx( float4 a) { return float3( a.z, a.z, a.x); }
+export float3 zzy( float4 a) { return float3( a.z, a.z, a.y); }
+export float3 zzz( float4 a) { return float3( a.z, a.z, a.z); }
+export float3 zzw( float4 a) { return float3( a.z, a.z, a.w); }
+export float3 zwx( float4 a) { return float3( a.z, a.w, a.x); }
+export float3 zwy( float4 a) { return float3( a.z, a.w, a.y); }
+export float3 zwz( float4 a) { return float3( a.z, a.w, a.z); }
+export float3 zww( float4 a) { return float3( a.z, a.w, a.w); }
+export float3 wxx( float4 a) { return float3( a.w, a.x, a.x); }
+export float3 wxy( float4 a) { return float3( a.w, a.x, a.y); }
+export float3 wxz( float4 a) { return float3( a.w, a.x, a.z); }
+export float3 wxw( float4 a) { return float3( a.w, a.x, a.w); }
+export float3 wyx( float4 a) { return float3( a.w, a.y, a.x); }
+export float3 wyy( float4 a) { return float3( a.w, a.y, a.y); }
+export float3 wyz( float4 a) { return float3( a.w, a.y, a.z); }
+export float3 wyw( float4 a) { return float3( a.w, a.y, a.w); }
+export float3 wzx( float4 a) { return float3( a.w, a.z, a.x); }
+export float3 wzy( float4 a) { return float3( a.w, a.z, a.y); }
+export float3 wzz( float4 a) { return float3( a.w, a.z, a.z); }
+export float3 wzw( float4 a) { return float3( a.w, a.z, a.w); }
+export float3 wwx( float4 a) { return float3( a.w, a.w, a.x); }
+export float3 wwy( float4 a) { return float3( a.w, a.w, a.y); }
+export float3 wwz( float4 a) { return float3( a.w, a.w, a.z); }
+export float3 www( float4 a) { return float3( a.w, a.w, a.w); }
+
+export float3 xxx( color a) { return xxx( float3(a)); }
+export float3 xxy( color a) { return xxy( float3(a)); }
+export float3 xxz( color a) { return xxz( float3(a)); }
+export float3 xyx( color a) { return xyx( float3(a)); }
+export float3 xyy( color a) { return xyy( float3(a)); }
+export float3 xyz( color a) { return xyz( float3(a)); }
+export float3 xzx( color a) { return xzx( float3(a)); }
+export float3 xzy( color a) { return xzy( float3(a)); }
+export float3 xzz( color a) { return xzz( float3(a)); }
+export float3 yxx( color a) { return yxx( float3(a)); }
+export float3 yxy( color a) { return yxy( float3(a)); }
+export float3 yxz( color a) { return yxz( float3(a)); }
+export float3 yyx( color a) { return yyx( float3(a)); }
+export float3 yyy( color a) { return yyy( float3(a)); }
+export float3 yyz( color a) { return yyz( float3(a)); }
+export float3 yzx( color a) { return yzx( float3(a)); }
+export float3 yzy( color a) { return yzy( float3(a)); }
+export float3 yzz( color a) { return yzz( float3(a)); }
+export float3 zxx( color a) { return zxx( float3(a)); }
+export float3 zxy( color a) { return zxy( float3(a)); }
+export float3 zxz( color a) { return zxz( float3(a)); }
+export float3 zyx( color a) { return zyx( float3(a)); }
+export float3 zyy( color a) { return zyy( float3(a)); }
+export float3 zyz( color a) { return zyz( float3(a)); }
+export float3 zzx( color a) { return zzx( float3(a)); }
+export float3 zzy( color a) { return zzy( float3(a)); }
+export float3 zzz( color a) { return zzz( float3(a)); }
+
+export float3 xxx( core::color4 a) { return xxx( float3( a.rgb)); }
+export float3 xxy( core::color4 a) { return xxy( float3( a.rgb)); }
+export float3 xxz( core::color4 a) { return xxz( float3( a.rgb)); }
+export float3 xxw( core::color4 a) { return float3( float3( a.rgb).x, float3( a.rgb).x, a.a); }
+export float3 xyx( core::color4 a) { return xyx( float3( a.rgb)); }
+export float3 xyy( core::color4 a) { return xyy( float3( a.rgb)); }
+export float3 xyz( core::color4 a) { return xyz( float3( a.rgb)); }
+export float3 xyw( core::color4 a) { return float3( float3( a.rgb).x, float3( a.rgb).y, a.a); }
+export float3 xzx( core::color4 a) { return xzx( float3( a.rgb)); }
+export float3 xzy( core::color4 a) { return xzy( float3( a.rgb)); }
+export float3 xzz( core::color4 a) { return xzz( float3( a.rgb)); }
+export float3 xzw( core::color4 a) { return float3( float3( a.rgb).x, float3( a.rgb).z, a.a); }
+export float3 xwx( core::color4 a) { return float3( float3( a.rgb).x, a.a, float3( a.rgb).x); }
+export float3 xwy( core::color4 a) { return float3( float3( a.rgb).x, a.a, float3( a.rgb).y); }
+export float3 xwz( core::color4 a) { return float3( float3( a.rgb).x, a.a, float3( a.rgb).z); }
+export float3 xww( core::color4 a) { return float3( float3( a.rgb).x, a.a, a.a); }
+export float3 yxx( core::color4 a) { return yxx( float3( a.rgb)); }
+export float3 yxy( core::color4 a) { return yxy( float3( a.rgb)); }
+export float3 yxz( core::color4 a) { return yxz( float3( a.rgb)); }
+export float3 yxw( core::color4 a) { return float3( float3( a.rgb).y, float3( a.rgb).x, a.a); }
+export float3 yyx( core::color4 a) { return yyx( float3( a.rgb)); }
+export float3 yyy( core::color4 a) { return yyy( float3( a.rgb)); }
+export float3 yyz( core::color4 a) { return yyz( float3( a.rgb)); }
+export float3 yyw( core::color4 a) { return float3( float3( a.rgb).y, float3( a.rgb).y, a.a); }
+export float3 yzx( core::color4 a) { return yzx( float3( a.rgb)); }
+export float3 yzy( core::color4 a) { return yzy( float3( a.rgb)); }
+export float3 yzz( core::color4 a) { return yzz( float3( a.rgb)); }
+export float3 yzw( core::color4 a) { return float3( float3( a.rgb).y, float3( a.rgb).z, a.a); }
+export float3 ywx( core::color4 a) { return float3( float3( a.rgb).y, a.a, float3( a.rgb).x); }
+export float3 ywy( core::color4 a) { return float3( float3( a.rgb).y, a.a, float3( a.rgb).y); }
+export float3 ywz( core::color4 a) { return float3( float3( a.rgb).y, a.a, float3( a.rgb).z); }
+export float3 yww( core::color4 a) { return float3( float3( a.rgb).y, a.a, a.a); }
+export float3 zxx( core::color4 a) { return zxx( float3( a.rgb)); }
+export float3 zxy( core::color4 a) { return zxy( float3( a.rgb)); }
+export float3 zxz( core::color4 a) { return zxz( float3( a.rgb)); }
+export float3 zxw( core::color4 a) { return float3( float3( a.rgb).z, float3( a.rgb).x, a.a); }
+export float3 zyx( core::color4 a) { return zyx( float3( a.rgb)); }
+export float3 zyy( core::color4 a) { return zyy( float3( a.rgb)); }
+export float3 zyz( core::color4 a) { return zyz( float3( a.rgb)); }
+export float3 zyw( core::color4 a) { return float3( float3( a.rgb).z, float3( a.rgb).y, a.a); }
+export float3 zzx( core::color4 a) { return zzx( float3( a.rgb)); }
+export float3 zzy( core::color4 a) { return zzy( float3( a.rgb)); }
+export float3 zzz( core::color4 a) { return zzz( float3( a.rgb)); }
+export float3 zzw( core::color4 a) { return float3( float3( a.rgb).z, float3( a.rgb).z, a.a); }
+export float3 zwx( core::color4 a) { return float3( float3( a.rgb).z, a.a, float3( a.rgb).x); }
+export float3 zwy( core::color4 a) { return float3( float3( a.rgb).z, a.a, float3( a.rgb).y); }
+export float3 zwz( core::color4 a) { return float3( float3( a.rgb).z, a.a, float3( a.rgb).z); }
+export float3 zww( core::color4 a) { return float3( float3( a.rgb).z, a.a, a.a); }
+export float3 wxx( core::color4 a) { return float3( a.a, float3( a.rgb).x, float3( a.rgb).x); }
+export float3 wxy( core::color4 a) { return float3( a.a, float3( a.rgb).x, float3( a.rgb).y); }
+export float3 wxz( core::color4 a) { return float3( a.a, float3( a.rgb).x, float3( a.rgb).z); }
+export float3 wxw( core::color4 a) { return float3( a.a, float3( a.rgb).x, a.a); }
+export float3 wyx( core::color4 a) { return float3( a.a, float3( a.rgb).y, float3( a.rgb).x); }
+export float3 wyy( core::color4 a) { return float3( a.a, float3( a.rgb).y, float3( a.rgb).y); }
+export float3 wyz( core::color4 a) { return float3( a.a, float3( a.rgb).y, float3( a.rgb).z); }
+export float3 wyw( core::color4 a) { return float3( a.a, float3( a.rgb).y, a.a); }
+export float3 wzx( core::color4 a) { return float3( a.a, float3( a.rgb).z, float3( a.rgb).x); }
+export float3 wzy( core::color4 a) { return float3( a.a, float3( a.rgb).z, float3( a.rgb).y); }
+export float3 wzz( core::color4 a) { return float3( a.a, float3( a.rgb).z, float3( a.rgb).z); }
+export float3 wzw( core::color4 a) { return float3( a.a, float3( a.rgb).z, a.a); }
+export float3 wwx( core::color4 a) { return float3( a.a, a.a, float3( a.rgb).x); }
+export float3 wwy( core::color4 a) { return float3( a.a, a.a, float3( a.rgb).y); }
+export float3 wwz( core::color4 a) { return float3( a.a, a.a, float3( a.rgb).z); }
+export float3 www( core::color4 a) { return float3( a.a, a.a, a.a); }
+
+// Swizzles with float4 return type
+export float4 xxxx( float a) { return float4( a, a, a, a); }
+
+export float4 xxxx( float2 a) { return float4( a.x, a.x, a.x, a.x); }
+export float4 xxxy( float2 a) { return float4( a.x, a.x, a.x, a.y); }
+export float4 xxyx( float2 a) { return float4( a.x, a.x, a.y, a.x); }
+export float4 xxyy( float2 a) { return float4( a.x, a.x, a.y, a.y); }
+export float4 xyxx( float2 a) { return float4( a.x, a.y, a.x, a.x); }
+export float4 xyxy( float2 a) { return float4( a.x, a.y, a.x, a.y); }
+export float4 xyyx( float2 a) { return float4( a.x, a.y, a.y, a.x); }
+export float4 xyyy( float2 a) { return float4( a.x, a.y, a.y, a.y); }
+export float4 yxxx( float2 a) { return float4( a.y, a.x, a.x, a.x); }
+export float4 yxxy( float2 a) { return float4( a.y, a.x, a.x, a.y); }
+export float4 yxyx( float2 a) { return float4( a.y, a.x, a.y, a.x); }
+export float4 yxyy( float2 a) { return float4( a.y, a.x, a.y, a.y); }
+export float4 yyxx( float2 a) { return float4( a.y, a.y, a.x, a.x); }
+export float4 yyxy( float2 a) { return float4( a.y, a.y, a.x, a.y); }
+export float4 yyyx( float2 a) { return float4( a.y, a.y, a.y, a.x); }
+export float4 yyyy( float2 a) { return float4( a.y, a.y, a.y, a.y); }
+
+export float4 xxxx( float3 a) { return float4( a.x, a.x, a.x, a.x); }
+export float4 xxxy( float3 a) { return float4( a.x, a.x, a.x, a.y); }
+export float4 xxxz( float3 a) { return float4( a.x, a.x, a.x, a.z); }
+export float4 xxyx( float3 a) { return float4( a.x, a.x, a.y, a.x); }
+export float4 xxyy( float3 a) { return float4( a.x, a.x, a.y, a.y); }
+export float4 xxyz( float3 a) { return float4( a.x, a.x, a.y, a.z); }
+export float4 xxzx( float3 a) { return float4( a.x, a.x, a.z, a.x); }
+export float4 xxzy( float3 a) { return float4( a.x, a.x, a.z, a.y); }
+export float4 xxzz( float3 a) { return float4( a.x, a.x, a.z, a.z); }
+export float4 xyxx( float3 a) { return float4( a.x, a.y, a.x, a.x); }
+export float4 xyxy( float3 a) { return float4( a.x, a.y, a.x, a.y); }
+export float4 xyxz( float3 a) { return float4( a.x, a.y, a.x, a.z); }
+export float4 xyyx( float3 a) { return float4( a.x, a.y, a.y, a.x); }
+export float4 xyyy( float3 a) { return float4( a.x, a.y, a.y, a.y); }
+export float4 xyyz( float3 a) { return float4( a.x, a.y, a.y, a.z); }
+export float4 xyzx( float3 a) { return float4( a.x, a.y, a.z, a.x); }
+export float4 xyzy( float3 a) { return float4( a.x, a.y, a.z, a.y); }
+export float4 xyzz( float3 a) { return float4( a.x, a.y, a.z, a.z); }
+export float4 xzxx( float3 a) { return float4( a.x, a.z, a.x, a.x); }
+export float4 xzxy( float3 a) { return float4( a.x, a.z, a.x, a.y); }
+export float4 xzxz( float3 a) { return float4( a.x, a.z, a.x, a.z); }
+export float4 xzyx( float3 a) { return float4( a.x, a.z, a.y, a.x); }
+export float4 xzyy( float3 a) { return float4( a.x, a.z, a.y, a.y); }
+export float4 xzyz( float3 a) { return float4( a.x, a.z, a.y, a.z); }
+export float4 xzzx( float3 a) { return float4( a.x, a.z, a.z, a.x); }
+export float4 xzzy( float3 a) { return float4( a.x, a.z, a.z, a.y); }
+export float4 xzzz( float3 a) { return float4( a.x, a.z, a.z, a.z); }
+export float4 yxxx( float3 a) { return float4( a.y, a.x, a.x, a.x); }
+export float4 yxxy( float3 a) { return float4( a.y, a.x, a.x, a.y); }
+export float4 yxxz( float3 a) { return float4( a.y, a.x, a.x, a.z); }
+export float4 yxyx( float3 a) { return float4( a.y, a.x, a.y, a.x); }
+export float4 yxyy( float3 a) { return float4( a.y, a.x, a.y, a.y); }
+export float4 yxyz( float3 a) { return float4( a.y, a.x, a.y, a.z); }
+export float4 yxzx( float3 a) { return float4( a.y, a.x, a.z, a.x); }
+export float4 yxzy( float3 a) { return float4( a.y, a.x, a.z, a.y); }
+export float4 yxzz( float3 a) { return float4( a.y, a.x, a.z, a.z); }
+export float4 yyxx( float3 a) { return float4( a.y, a.y, a.x, a.x); }
+export float4 yyxy( float3 a) { return float4( a.y, a.y, a.x, a.y); }
+export float4 yyxz( float3 a) { return float4( a.y, a.y, a.x, a.z); }
+export float4 yyyx( float3 a) { return float4( a.y, a.y, a.y, a.x); }
+export float4 yyyy( float3 a) { return float4( a.y, a.y, a.y, a.y); }
+export float4 yyyz( float3 a) { return float4( a.y, a.y, a.y, a.z); }
+export float4 yyzx( float3 a) { return float4( a.y, a.y, a.z, a.x); }
+export float4 yyzy( float3 a) { return float4( a.y, a.y, a.z, a.y); }
+export float4 yyzz( float3 a) { return float4( a.y, a.y, a.z, a.z); }
+export float4 yzxx( float3 a) { return float4( a.y, a.z, a.x, a.x); }
+export float4 yzxy( float3 a) { return float4( a.y, a.z, a.x, a.y); }
+export float4 yzxz( float3 a) { return float4( a.y, a.z, a.x, a.z); }
+export float4 yzyx( float3 a) { return float4( a.y, a.z, a.y, a.x); }
+export float4 yzyy( float3 a) { return float4( a.y, a.z, a.y, a.y); }
+export float4 yzyz( float3 a) { return float4( a.y, a.z, a.y, a.z); }
+export float4 yzzx( float3 a) { return float4( a.y, a.z, a.z, a.x); }
+export float4 yzzy( float3 a) { return float4( a.y, a.z, a.z, a.y); }
+export float4 yzzz( float3 a) { return float4( a.y, a.z, a.z, a.z); }
+export float4 zxxx( float3 a) { return float4( a.z, a.x, a.x, a.x); }
+export float4 zxxy( float3 a) { return float4( a.z, a.x, a.x, a.y); }
+export float4 zxxz( float3 a) { return float4( a.z, a.x, a.x, a.z); }
+export float4 zxyx( float3 a) { return float4( a.z, a.x, a.y, a.x); }
+export float4 zxyy( float3 a) { return float4( a.z, a.x, a.y, a.y); }
+export float4 zxyz( float3 a) { return float4( a.z, a.x, a.y, a.z); }
+export float4 zxzx( float3 a) { return float4( a.z, a.x, a.z, a.x); }
+export float4 zxzy( float3 a) { return float4( a.z, a.x, a.z, a.y); }
+export float4 zxzz( float3 a) { return float4( a.z, a.x, a.z, a.z); }
+export float4 zyxx( float3 a) { return float4( a.z, a.y, a.x, a.x); }
+export float4 zyxy( float3 a) { return float4( a.z, a.y, a.x, a.y); }
+export float4 zyxz( float3 a) { return float4( a.z, a.y, a.x, a.z); }
+export float4 zyyx( float3 a) { return float4( a.z, a.y, a.y, a.x); }
+export float4 zyyy( float3 a) { return float4( a.z, a.y, a.y, a.y); }
+export float4 zyyz( float3 a) { return float4( a.z, a.y, a.y, a.z); }
+export float4 zyzx( float3 a) { return float4( a.z, a.y, a.z, a.x); }
+export float4 zyzy( float3 a) { return float4( a.z, a.y, a.z, a.y); }
+export float4 zyzz( float3 a) { return float4( a.z, a.y, a.z, a.z); }
+export float4 zzxx( float3 a) { return float4( a.z, a.z, a.x, a.x); }
+export float4 zzxy( float3 a) { return float4( a.z, a.z, a.x, a.y); }
+export float4 zzxz( float3 a) { return float4( a.z, a.z, a.x, a.z); }
+export float4 zzyx( float3 a) { return float4( a.z, a.z, a.y, a.x); }
+export float4 zzyy( float3 a) { return float4( a.z, a.z, a.y, a.y); }
+export float4 zzyz( float3 a) { return float4( a.z, a.z, a.y, a.z); }
+export float4 zzzx( float3 a) { return float4( a.z, a.z, a.z, a.x); }
+export float4 zzzy( float3 a) { return float4( a.z, a.z, a.z, a.y); }
+export float4 zzzz( float3 a) { return float4( a.z, a.z, a.z, a.z); }
+
+export float4 xxxx( float4 a) { return float4( a.x, a.x, a.x, a.x); }
+export float4 xxxy( float4 a) { return float4( a.x, a.x, a.x, a.y); }
+export float4 xxxz( float4 a) { return float4( a.x, a.x, a.x, a.z); }
+export float4 xxxw( float4 a) { return float4( a.x, a.x, a.x, a.w); }
+export float4 xxyx( float4 a) { return float4( a.x, a.x, a.y, a.x); }
+export float4 xxyy( float4 a) { return float4( a.x, a.x, a.y, a.y); }
+export float4 xxyz( float4 a) { return float4( a.x, a.x, a.y, a.z); }
+export float4 xxyw( float4 a) { return float4( a.x, a.x, a.y, a.w); }
+export float4 xxzx( float4 a) { return float4( a.x, a.x, a.z, a.x); }
+export float4 xxzy( float4 a) { return float4( a.x, a.x, a.z, a.y); }
+export float4 xxzz( float4 a) { return float4( a.x, a.x, a.z, a.z); }
+export float4 xxzw( float4 a) { return float4( a.x, a.x, a.z, a.w); }
+export float4 xxwx( float4 a) { return float4( a.x, a.x, a.w, a.x); }
+export float4 xxwy( float4 a) { return float4( a.x, a.x, a.w, a.y); }
+export float4 xxwz( float4 a) { return float4( a.x, a.x, a.w, a.z); }
+export float4 xxww( float4 a) { return float4( a.x, a.x, a.w, a.w); }
+export float4 xyxx( float4 a) { return float4( a.x, a.y, a.x, a.x); }
+export float4 xyxy( float4 a) { return float4( a.x, a.y, a.x, a.y); }
+export float4 xyxz( float4 a) { return float4( a.x, a.y, a.x, a.z); }
+export float4 xyxw( float4 a) { return float4( a.x, a.y, a.x, a.w); }
+export float4 xyyx( float4 a) { return float4( a.x, a.y, a.y, a.x); }
+export float4 xyyy( float4 a) { return float4( a.x, a.y, a.y, a.y); }
+export float4 xyyz( float4 a) { return float4( a.x, a.y, a.y, a.z); }
+export float4 xyyw( float4 a) { return float4( a.x, a.y, a.y, a.w); }
+export float4 xyzx( float4 a) { return float4( a.x, a.y, a.z, a.x); }
+export float4 xyzy( float4 a) { return float4( a.x, a.y, a.z, a.y); }
+export float4 xyzz( float4 a) { return float4( a.x, a.y, a.z, a.z); }
+export float4 xyzw( float4 a) { return float4( a.x, a.y, a.z, a.w); }
+export float4 xywx( float4 a) { return float4( a.x, a.y, a.w, a.x); }
+export float4 xywy( float4 a) { return float4( a.x, a.y, a.w, a.y); }
+export float4 xywz( float4 a) { return float4( a.x, a.y, a.w, a.z); }
+export float4 xyww( float4 a) { return float4( a.x, a.y, a.w, a.w); }
+export float4 xzxx( float4 a) { return float4( a.x, a.z, a.x, a.x); }
+export float4 xzxy( float4 a) { return float4( a.x, a.z, a.x, a.y); }
+export float4 xzxz( float4 a) { return float4( a.x, a.z, a.x, a.z); }
+export float4 xzxw( float4 a) { return float4( a.x, a.z, a.x, a.w); }
+export float4 xzyx( float4 a) { return float4( a.x, a.z, a.y, a.x); }
+export float4 xzyy( float4 a) { return float4( a.x, a.z, a.y, a.y); }
+export float4 xzyz( float4 a) { return float4( a.x, a.z, a.y, a.z); }
+export float4 xzyw( float4 a) { return float4( a.x, a.z, a.y, a.w); }
+export float4 xzzx( float4 a) { return float4( a.x, a.z, a.z, a.x); }
+export float4 xzzy( float4 a) { return float4( a.x, a.z, a.z, a.y); }
+export float4 xzzz( float4 a) { return float4( a.x, a.z, a.z, a.z); }
+export float4 xzzw( float4 a) { return float4( a.x, a.z, a.z, a.w); }
+export float4 xzwx( float4 a) { return float4( a.x, a.z, a.w, a.x); }
+export float4 xzwy( float4 a) { return float4( a.x, a.z, a.w, a.y); }
+export float4 xzwz( float4 a) { return float4( a.x, a.z, a.w, a.z); }
+export float4 xzww( float4 a) { return float4( a.x, a.z, a.w, a.w); }
+export float4 xwxx( float4 a) { return float4( a.x, a.w, a.x, a.x); }
+export float4 xwxy( float4 a) { return float4( a.x, a.w, a.x, a.y); }
+export float4 xwxz( float4 a) { return float4( a.x, a.w, a.x, a.z); }
+export float4 xwxw( float4 a) { return float4( a.x, a.w, a.x, a.w); }
+export float4 xwyx( float4 a) { return float4( a.x, a.w, a.y, a.x); }
+export float4 xwyy( float4 a) { return float4( a.x, a.w, a.y, a.y); }
+export float4 xwyz( float4 a) { return float4( a.x, a.w, a.y, a.z); }
+export float4 xwyw( float4 a) { return float4( a.x, a.w, a.y, a.w); }
+export float4 xwzx( float4 a) { return float4( a.x, a.w, a.z, a.x); }
+export float4 xwzy( float4 a) { return float4( a.x, a.w, a.z, a.y); }
+export float4 xwzz( float4 a) { return float4( a.x, a.w, a.z, a.z); }
+export float4 xwzw( float4 a) { return float4( a.x, a.w, a.z, a.w); }
+export float4 xwwx( float4 a) { return float4( a.x, a.w, a.w, a.x); }
+export float4 xwwy( float4 a) { return float4( a.x, a.w, a.w, a.y); }
+export float4 xwwz( float4 a) { return float4( a.x, a.w, a.w, a.z); }
+export float4 xwww( float4 a) { return float4( a.x, a.w, a.w, a.w); }
+export float4 yxxx( float4 a) { return float4( a.y, a.x, a.x, a.x); }
+export float4 yxxy( float4 a) { return float4( a.y, a.x, a.x, a.y); }
+export float4 yxxz( float4 a) { return float4( a.y, a.x, a.x, a.z); }
+export float4 yxxw( float4 a) { return float4( a.y, a.x, a.x, a.w); }
+export float4 yxyx( float4 a) { return float4( a.y, a.x, a.y, a.x); }
+export float4 yxyy( float4 a) { return float4( a.y, a.x, a.y, a.y); }
+export float4 yxyz( float4 a) { return float4( a.y, a.x, a.y, a.z); }
+export float4 yxyw( float4 a) { return float4( a.y, a.x, a.y, a.w); }
+export float4 yxzx( float4 a) { return float4( a.y, a.x, a.z, a.x); }
+export float4 yxzy( float4 a) { return float4( a.y, a.x, a.z, a.y); }
+export float4 yxzz( float4 a) { return float4( a.y, a.x, a.z, a.z); }
+export float4 yxzw( float4 a) { return float4( a.y, a.x, a.z, a.w); }
+export float4 yxwx( float4 a) { return float4( a.y, a.x, a.w, a.x); }
+export float4 yxwy( float4 a) { return float4( a.y, a.x, a.w, a.y); }
+export float4 yxwz( float4 a) { return float4( a.y, a.x, a.w, a.z); }
+export float4 yxww( float4 a) { return float4( a.y, a.x, a.w, a.w); }
+export float4 yyxx( float4 a) { return float4( a.y, a.y, a.x, a.x); }
+export float4 yyxy( float4 a) { return float4( a.y, a.y, a.x, a.y); }
+export float4 yyxz( float4 a) { return float4( a.y, a.y, a.x, a.z); }
+export float4 yyxw( float4 a) { return float4( a.y, a.y, a.x, a.w); }
+export float4 yyyx( float4 a) { return float4( a.y, a.y, a.y, a.x); }
+export float4 yyyy( float4 a) { return float4( a.y, a.y, a.y, a.y); }
+export float4 yyyz( float4 a) { return float4( a.y, a.y, a.y, a.z); }
+export float4 yyyw( float4 a) { return float4( a.y, a.y, a.y, a.w); }
+export float4 yyzx( float4 a) { return float4( a.y, a.y, a.z, a.x); }
+export float4 yyzy( float4 a) { return float4( a.y, a.y, a.z, a.y); }
+export float4 yyzz( float4 a) { return float4( a.y, a.y, a.z, a.z); }
+export float4 yyzw( float4 a) { return float4( a.y, a.y, a.z, a.w); }
+export float4 yywx( float4 a) { return float4( a.y, a.y, a.w, a.x); }
+export float4 yywy( float4 a) { return float4( a.y, a.y, a.w, a.y); }
+export float4 yywz( float4 a) { return float4( a.y, a.y, a.w, a.z); }
+export float4 yyww( float4 a) { return float4( a.y, a.y, a.w, a.w); }
+export float4 yzxx( float4 a) { return float4( a.y, a.z, a.x, a.x); }
+export float4 yzxy( float4 a) { return float4( a.y, a.z, a.x, a.y); }
+export float4 yzxz( float4 a) { return float4( a.y, a.z, a.x, a.z); }
+export float4 yzxw( float4 a) { return float4( a.y, a.z, a.x, a.w); }
+export float4 yzyx( float4 a) { return float4( a.y, a.z, a.y, a.x); }
+export float4 yzyy( float4 a) { return float4( a.y, a.z, a.y, a.y); }
+export float4 yzyz( float4 a) { return float4( a.y, a.z, a.y, a.z); }
+export float4 yzyw( float4 a) { return float4( a.y, a.z, a.y, a.w); }
+export float4 yzzx( float4 a) { return float4( a.y, a.z, a.z, a.x); }
+export float4 yzzy( float4 a) { return float4( a.y, a.z, a.z, a.y); }
+export float4 yzzz( float4 a) { return float4( a.y, a.z, a.z, a.z); }
+export float4 yzzw( float4 a) { return float4( a.y, a.z, a.z, a.w); }
+export float4 yzwx( float4 a) { return float4( a.y, a.z, a.w, a.x); }
+export float4 yzwy( float4 a) { return float4( a.y, a.z, a.w, a.y); }
+export float4 yzwz( float4 a) { return float4( a.y, a.z, a.w, a.z); }
+export float4 yzww( float4 a) { return float4( a.y, a.z, a.w, a.w); }
+export float4 ywxx( float4 a) { return float4( a.y, a.w, a.x, a.x); }
+export float4 ywxy( float4 a) { return float4( a.y, a.w, a.x, a.y); }
+export float4 ywxz( float4 a) { return float4( a.y, a.w, a.x, a.z); }
+export float4 ywxw( float4 a) { return float4( a.y, a.w, a.x, a.w); }
+export float4 ywyx( float4 a) { return float4( a.y, a.w, a.y, a.x); }
+export float4 ywyy( float4 a) { return float4( a.y, a.w, a.y, a.y); }
+export float4 ywyz( float4 a) { return float4( a.y, a.w, a.y, a.z); }
+export float4 ywyw( float4 a) { return float4( a.y, a.w, a.y, a.w); }
+export float4 ywzx( float4 a) { return float4( a.y, a.w, a.z, a.x); }
+export float4 ywzy( float4 a) { return float4( a.y, a.w, a.z, a.y); }
+export float4 ywzz( float4 a) { return float4( a.y, a.w, a.z, a.z); }
+export float4 ywzw( float4 a) { return float4( a.y, a.w, a.z, a.w); }
+export float4 ywwx( float4 a) { return float4( a.y, a.w, a.w, a.x); }
+export float4 ywwy( float4 a) { return float4( a.y, a.w, a.w, a.y); }
+export float4 ywwz( float4 a) { return float4( a.y, a.w, a.w, a.z); }
+export float4 ywww( float4 a) { return float4( a.y, a.w, a.w, a.w); }
+export float4 zxxx( float4 a) { return float4( a.z, a.x, a.x, a.x); }
+export float4 zxxy( float4 a) { return float4( a.z, a.x, a.x, a.y); }
+export float4 zxxz( float4 a) { return float4( a.z, a.x, a.x, a.z); }
+export float4 zxxw( float4 a) { return float4( a.z, a.x, a.x, a.w); }
+export float4 zxyx( float4 a) { return float4( a.z, a.x, a.y, a.x); }
+export float4 zxyy( float4 a) { return float4( a.z, a.x, a.y, a.y); }
+export float4 zxyz( float4 a) { return float4( a.z, a.x, a.y, a.z); }
+export float4 zxyw( float4 a) { return float4( a.z, a.x, a.y, a.w); }
+export float4 zxzx( float4 a) { return float4( a.z, a.x, a.z, a.x); }
+export float4 zxzy( float4 a) { return float4( a.z, a.x, a.z, a.y); }
+export float4 zxzz( float4 a) { return float4( a.z, a.x, a.z, a.z); }
+export float4 zxzw( float4 a) { return float4( a.z, a.x, a.z, a.w); }
+export float4 zxwx( float4 a) { return float4( a.z, a.x, a.w, a.x); }
+export float4 zxwy( float4 a) { return float4( a.z, a.x, a.w, a.y); }
+export float4 zxwz( float4 a) { return float4( a.z, a.x, a.w, a.z); }
+export float4 zxww( float4 a) { return float4( a.z, a.x, a.w, a.w); }
+export float4 zyxx( float4 a) { return float4( a.z, a.y, a.x, a.x); }
+export float4 zyxy( float4 a) { return float4( a.z, a.y, a.x, a.y); }
+export float4 zyxz( float4 a) { return float4( a.z, a.y, a.x, a.z); }
+export float4 zyxw( float4 a) { return float4( a.z, a.y, a.x, a.w); }
+export float4 zyyx( float4 a) { return float4( a.z, a.y, a.y, a.x); }
+export float4 zyyy( float4 a) { return float4( a.z, a.y, a.y, a.y); }
+export float4 zyyz( float4 a) { return float4( a.z, a.y, a.y, a.z); }
+export float4 zyyw( float4 a) { return float4( a.z, a.y, a.y, a.w); }
+export float4 zyzx( float4 a) { return float4( a.z, a.y, a.z, a.x); }
+export float4 zyzy( float4 a) { return float4( a.z, a.y, a.z, a.y); }
+export float4 zyzz( float4 a) { return float4( a.z, a.y, a.z, a.z); }
+export float4 zyzw( float4 a) { return float4( a.z, a.y, a.z, a.w); }
+export float4 zywx( float4 a) { return float4( a.z, a.y, a.w, a.x); }
+export float4 zywy( float4 a) { return float4( a.z, a.y, a.w, a.y); }
+export float4 zywz( float4 a) { return float4( a.z, a.y, a.w, a.z); }
+export float4 zyww( float4 a) { return float4( a.z, a.y, a.w, a.w); }
+export float4 zzxx( float4 a) { return float4( a.z, a.z, a.x, a.x); }
+export float4 zzxy( float4 a) { return float4( a.z, a.z, a.x, a.y); }
+export float4 zzxz( float4 a) { return float4( a.z, a.z, a.x, a.z); }
+export float4 zzxw( float4 a) { return float4( a.z, a.z, a.x, a.w); }
+export float4 zzyx( float4 a) { return float4( a.z, a.z, a.y, a.x); }
+export float4 zzyy( float4 a) { return float4( a.z, a.z, a.y, a.y); }
+export float4 zzyz( float4 a) { return float4( a.z, a.z, a.y, a.z); }
+export float4 zzyw( float4 a) { return float4( a.z, a.z, a.y, a.w); }
+export float4 zzzx( float4 a) { return float4( a.z, a.z, a.z, a.x); }
+export float4 zzzy( float4 a) { return float4( a.z, a.z, a.z, a.y); }
+export float4 zzzz( float4 a) { return float4( a.z, a.z, a.z, a.z); }
+export float4 zzzw( float4 a) { return float4( a.z, a.z, a.z, a.w); }
+export float4 zzwx( float4 a) { return float4( a.z, a.z, a.w, a.x); }
+export float4 zzwy( float4 a) { return float4( a.z, a.z, a.w, a.y); }
+export float4 zzwz( float4 a) { return float4( a.z, a.z, a.w, a.z); }
+export float4 zzww( float4 a) { return float4( a.z, a.z, a.w, a.w); }
+export float4 zwxx( float4 a) { return float4( a.z, a.w, a.x, a.x); }
+export float4 zwxy( float4 a) { return float4( a.z, a.w, a.x, a.y); }
+export float4 zwxz( float4 a) { return float4( a.z, a.w, a.x, a.z); }
+export float4 zwxw( float4 a) { return float4( a.z, a.w, a.x, a.w); }
+export float4 zwyx( float4 a) { return float4( a.z, a.w, a.y, a.x); }
+export float4 zwyy( float4 a) { return float4( a.z, a.w, a.y, a.y); }
+export float4 zwyz( float4 a) { return float4( a.z, a.w, a.y, a.z); }
+export float4 zwyw( float4 a) { return float4( a.z, a.w, a.y, a.w); }
+export float4 zwzx( float4 a) { return float4( a.z, a.w, a.z, a.x); }
+export float4 zwzy( float4 a) { return float4( a.z, a.w, a.z, a.y); }
+export float4 zwzz( float4 a) { return float4( a.z, a.w, a.z, a.z); }
+export float4 zwzw( float4 a) { return float4( a.z, a.w, a.z, a.w); }
+export float4 zwwx( float4 a) { return float4( a.z, a.w, a.w, a.x); }
+export float4 zwwy( float4 a) { return float4( a.z, a.w, a.w, a.y); }
+export float4 zwwz( float4 a) { return float4( a.z, a.w, a.w, a.z); }
+export float4 zwww( float4 a) { return float4( a.z, a.w, a.w, a.w); }
+export float4 wxxx( float4 a) { return float4( a.w, a.x, a.x, a.x); }
+export float4 wxxy( float4 a) { return float4( a.w, a.x, a.x, a.y); }
+export float4 wxxz( float4 a) { return float4( a.w, a.x, a.x, a.z); }
+export float4 wxxw( float4 a) { return float4( a.w, a.x, a.x, a.w); }
+export float4 wxyx( float4 a) { return float4( a.w, a.x, a.y, a.x); }
+export float4 wxyy( float4 a) { return float4( a.w, a.x, a.y, a.y); }
+export float4 wxyz( float4 a) { return float4( a.w, a.x, a.y, a.z); }
+export float4 wxyw( float4 a) { return float4( a.w, a.x, a.y, a.w); }
+export float4 wxzx( float4 a) { return float4( a.w, a.x, a.z, a.x); }
+export float4 wxzy( float4 a) { return float4( a.w, a.x, a.z, a.y); }
+export float4 wxzz( float4 a) { return float4( a.w, a.x, a.z, a.z); }
+export float4 wxzw( float4 a) { return float4( a.w, a.x, a.z, a.w); }
+export float4 wxwx( float4 a) { return float4( a.w, a.x, a.w, a.x); }
+export float4 wxwy( float4 a) { return float4( a.w, a.x, a.w, a.y); }
+export float4 wxwz( float4 a) { return float4( a.w, a.x, a.w, a.z); }
+export float4 wxww( float4 a) { return float4( a.w, a.x, a.w, a.w); }
+export float4 wyxx( float4 a) { return float4( a.w, a.y, a.x, a.x); }
+export float4 wyxy( float4 a) { return float4( a.w, a.y, a.x, a.y); }
+export float4 wyxz( float4 a) { return float4( a.w, a.y, a.x, a.z); }
+export float4 wyxw( float4 a) { return float4( a.w, a.y, a.x, a.w); }
+export float4 wyyx( float4 a) { return float4( a.w, a.y, a.y, a.x); }
+export float4 wyyy( float4 a) { return float4( a.w, a.y, a.y, a.y); }
+export float4 wyyz( float4 a) { return float4( a.w, a.y, a.y, a.z); }
+export float4 wyyw( float4 a) { return float4( a.w, a.y, a.y, a.w); }
+export float4 wyzx( float4 a) { return float4( a.w, a.y, a.z, a.x); }
+export float4 wyzy( float4 a) { return float4( a.w, a.y, a.z, a.y); }
+export float4 wyzz( float4 a) { return float4( a.w, a.y, a.z, a.z); }
+export float4 wyzw( float4 a) { return float4( a.w, a.y, a.z, a.w); }
+export float4 wywx( float4 a) { return float4( a.w, a.y, a.w, a.x); }
+export float4 wywy( float4 a) { return float4( a.w, a.y, a.w, a.y); }
+export float4 wywz( float4 a) { return float4( a.w, a.y, a.w, a.z); }
+export float4 wyww( float4 a) { return float4( a.w, a.y, a.w, a.w); }
+export float4 wzxx( float4 a) { return float4( a.w, a.z, a.x, a.x); }
+export float4 wzxy( float4 a) { return float4( a.w, a.z, a.x, a.y); }
+export float4 wzxz( float4 a) { return float4( a.w, a.z, a.x, a.z); }
+export float4 wzxw( float4 a) { return float4( a.w, a.z, a.x, a.w); }
+export float4 wzyx( float4 a) { return float4( a.w, a.z, a.y, a.x); }
+export float4 wzyy( float4 a) { return float4( a.w, a.z, a.y, a.y); }
+export float4 wzyz( float4 a) { return float4( a.w, a.z, a.y, a.z); }
+export float4 wzyw( float4 a) { return float4( a.w, a.z, a.y, a.w); }
+export float4 wzzx( float4 a) { return float4( a.w, a.z, a.z, a.x); }
+export float4 wzzy( float4 a) { return float4( a.w, a.z, a.z, a.y); }
+export float4 wzzz( float4 a) { return float4( a.w, a.z, a.z, a.z); }
+export float4 wzzw( float4 a) { return float4( a.w, a.z, a.z, a.w); }
+export float4 wzwx( float4 a) { return float4( a.w, a.z, a.w, a.x); }
+export float4 wzwy( float4 a) { return float4( a.w, a.z, a.w, a.y); }
+export float4 wzwz( float4 a) { return float4( a.w, a.z, a.w, a.z); }
+export float4 wzww( float4 a) { return float4( a.w, a.z, a.w, a.w); }
+export float4 wwxx( float4 a) { return float4( a.w, a.w, a.x, a.x); }
+export float4 wwxy( float4 a) { return float4( a.w, a.w, a.x, a.y); }
+export float4 wwxz( float4 a) { return float4( a.w, a.w, a.x, a.z); }
+export float4 wwxw( float4 a) { return float4( a.w, a.w, a.x, a.w); }
+export float4 wwyx( float4 a) { return float4( a.w, a.w, a.y, a.x); }
+export float4 wwyy( float4 a) { return float4( a.w, a.w, a.y, a.y); }
+export float4 wwyz( float4 a) { return float4( a.w, a.w, a.y, a.z); }
+export float4 wwyw( float4 a) { return float4( a.w, a.w, a.y, a.w); }
+export float4 wwzx( float4 a) { return float4( a.w, a.w, a.z, a.x); }
+export float4 wwzy( float4 a) { return float4( a.w, a.w, a.z, a.y); }
+export float4 wwzz( float4 a) { return float4( a.w, a.w, a.z, a.z); }
+export float4 wwzw( float4 a) { return float4( a.w, a.w, a.z, a.w); }
+export float4 wwwx( float4 a) { return float4( a.w, a.w, a.w, a.x); }
+export float4 wwwy( float4 a) { return float4( a.w, a.w, a.w, a.y); }
+export float4 wwwz( float4 a) { return float4( a.w, a.w, a.w, a.z); }
+export float4 wwww( float4 a) { return float4( a.w, a.w, a.w, a.w); }
+
+export float4 xxxx( color a) { return xxxx( float3(a)); }
+export float4 xxxy( color a) { return xxxy( float3(a)); }
+export float4 xxxz( color a) { return xxxz( float3(a)); }
+export float4 xxyx( color a) { return xxyx( float3(a)); }
+export float4 xxyy( color a) { return xxyy( float3(a)); }
+export float4 xxyz( color a) { return xxyz( float3(a)); }
+export float4 xxzx( color a) { return xxzx( float3(a)); }
+export float4 xxzy( color a) { return xxzy( float3(a)); }
+export float4 xxzz( color a) { return xxzz( float3(a)); }
+export float4 xyxx( color a) { return xyxx( float3(a)); }
+export float4 xyxy( color a) { return xyxy( float3(a)); }
+export float4 xyxz( color a) { return xyxz( float3(a)); }
+export float4 xyyx( color a) { return xyyx( float3(a)); }
+export float4 xyyy( color a) { return xyyy( float3(a)); }
+export float4 xyyz( color a) { return xyyz( float3(a)); }
+export float4 xyzx( color a) { return xyzx( float3(a)); }
+export float4 xyzy( color a) { return xyzy( float3(a)); }
+export float4 xyzz( color a) { return xyzz( float3(a)); }
+export float4 xzxx( color a) { return xzxx( float3(a)); }
+export float4 xzxy( color a) { return xzxy( float3(a)); }
+export float4 xzxz( color a) { return xzxz( float3(a)); }
+export float4 xzyx( color a) { return xzyx( float3(a)); }
+export float4 xzyy( color a) { return xzyy( float3(a)); }
+export float4 xzyz( color a) { return xzyz( float3(a)); }
+export float4 xzzx( color a) { return xzzx( float3(a)); }
+export float4 xzzy( color a) { return xzzy( float3(a)); }
+export float4 xzzz( color a) { return xzzz( float3(a)); }
+export float4 yxxx( color a) { return yxxx( float3(a)); }
+export float4 yxxy( color a) { return yxxy( float3(a)); }
+export float4 yxxz( color a) { return yxxz( float3(a)); }
+export float4 yxyx( color a) { return yxyx( float3(a)); }
+export float4 yxyy( color a) { return yxyy( float3(a)); }
+export float4 yxyz( color a) { return yxyz( float3(a)); }
+export float4 yxzx( color a) { return yxzx( float3(a)); }
+export float4 yxzy( color a) { return yxzy( float3(a)); }
+export float4 yxzz( color a) { return yxzz( float3(a)); }
+export float4 yyxx( color a) { return yyxx( float3(a)); }
+export float4 yyxy( color a) { return yyxy( float3(a)); }
+export float4 yyxz( color a) { return yyxz( float3(a)); }
+export float4 yyyx( color a) { return yyyx( float3(a)); }
+export float4 yyyy( color a) { return yyyy( float3(a)); }
+export float4 yyyz( color a) { return yyyz( float3(a)); }
+export float4 yyzx( color a) { return yyzx( float3(a)); }
+export float4 yyzy( color a) { return yyzy( float3(a)); }
+export float4 yyzz( color a) { return yyzz( float3(a)); }
+export float4 yzxx( color a) { return yzxx( float3(a)); }
+export float4 yzxy( color a) { return yzxy( float3(a)); }
+export float4 yzxz( color a) { return yzxz( float3(a)); }
+export float4 yzyx( color a) { return yzyx( float3(a)); }
+export float4 yzyy( color a) { return yzyy( float3(a)); }
+export float4 yzyz( color a) { return yzyz( float3(a)); }
+export float4 yzzx( color a) { return yzzx( float3(a)); }
+export float4 yzzy( color a) { return yzzy( float3(a)); }
+export float4 yzzz( color a) { return yzzz( float3(a)); }
+export float4 zxxx( color a) { return zxxx( float3(a)); }
+export float4 zxxy( color a) { return zxxy( float3(a)); }
+export float4 zxxz( color a) { return zxxz( float3(a)); }
+export float4 zxyx( color a) { return zxyx( float3(a)); }
+export float4 zxyy( color a) { return zxyy( float3(a)); }
+export float4 zxyz( color a) { return zxyz( float3(a)); }
+export float4 zxzx( color a) { return zxzx( float3(a)); }
+export float4 zxzy( color a) { return zxzy( float3(a)); }
+export float4 zxzz( color a) { return zxzz( float3(a)); }
+export float4 zyxx( color a) { return zyxx( float3(a)); }
+export float4 zyxy( color a) { return zyxy( float3(a)); }
+export float4 zyxz( color a) { return zyxz( float3(a)); }
+export float4 zyyx( color a) { return zyyx( float3(a)); }
+export float4 zyyy( color a) { return zyyy( float3(a)); }
+export float4 zyyz( color a) { return zyyz( float3(a)); }
+export float4 zyzx( color a) { return zyzx( float3(a)); }
+export float4 zyzy( color a) { return zyzy( float3(a)); }
+export float4 zyzz( color a) { return zyzz( float3(a)); }
+export float4 zzxx( color a) { return zzxx( float3(a)); }
+export float4 zzxy( color a) { return zzxy( float3(a)); }
+export float4 zzxz( color a) { return zzxz( float3(a)); }
+export float4 zzyx( color a) { return zzyx( float3(a)); }
+export float4 zzyy( color a) { return zzyy( float3(a)); }
+export float4 zzyz( color a) { return zzyz( float3(a)); }
+export float4 zzzx( color a) { return zzzx( float3(a)); }
+export float4 zzzy( color a) { return zzzy( float3(a)); }
+export float4 zzzz( color a) { return zzzz( float3(a)); }
+
+export float4 xxxx( core::color4 a) { return xxxx( float3( a.rgb)); }
+export float4 xxxy( core::color4 a) { return xxxy( float3( a.rgb)); }
+export float4 xxxz( core::color4 a) { return xxxz( float3( a.rgb)); }
+export float4 xxxw( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).x, float3( a.rgb).x, a.a); }
+export float4 xxyx( core::color4 a) { return xxyx( float3( a.rgb)); }
+export float4 xxyy( core::color4 a) { return xxyy( float3( a.rgb)); }
+export float4 xxyz( core::color4 a) { return xxyz( float3( a.rgb)); }
+export float4 xxyw( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).x, float3( a.rgb).y, a.a); }
+export float4 xxzx( core::color4 a) { return xxzx( float3( a.rgb)); }
+export float4 xxzy( core::color4 a) { return xxzy( float3( a.rgb)); }
+export float4 xxzz( core::color4 a) { return xxzz( float3( a.rgb)); }
+export float4 xxzw( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).x, float3( a.rgb).z, a.a); }
+export float4 xxwx( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).x, a.a, float3( a.rgb).x); }
+export float4 xxwy( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).x, a.a, float3( a.rgb).y); }
+export float4 xxwz( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).x, a.a, float3( a.rgb).z); }
+export float4 xxww( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).x, a.a, a.a); }
+export float4 xyxx( core::color4 a) { return xyxx( float3( a.rgb)); }
+export float4 xyxy( core::color4 a) { return xyxy( float3( a.rgb)); }
+export float4 xyxz( core::color4 a) { return xyxz( float3( a.rgb)); }
+export float4 xyxw( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).y, float3( a.rgb).x, a.a); }
+export float4 xyyx( core::color4 a) { return xyyx( float3( a.rgb)); }
+export float4 xyyy( core::color4 a) { return xyyy( float3( a.rgb)); }
+export float4 xyyz( core::color4 a) { return xyyz( float3( a.rgb)); }
+export float4 xyyw( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).y, float3( a.rgb).y, a.a); }
+export float4 xyzx( core::color4 a) { return xyzx( float3( a.rgb)); }
+export float4 xyzy( core::color4 a) { return xyzy( float3( a.rgb)); }
+export float4 xyzz( core::color4 a) { return xyzz( float3( a.rgb)); }
+export float4 xyzw( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).y, float3( a.rgb).z, a.a); }
+export float4 xywx( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).y, a.a, float3( a.rgb).x); }
+export float4 xywy( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).y, a.a, float3( a.rgb).y); }
+export float4 xywz( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).y, a.a, float3( a.rgb).z); }
+export float4 xyww( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).y, a.a, a.a); }
+export float4 xzxx( core::color4 a) { return xzxx( float3( a.rgb)); }
+export float4 xzxy( core::color4 a) { return xzxy( float3( a.rgb)); }
+export float4 xzxz( core::color4 a) { return xzxz( float3( a.rgb)); }
+export float4 xzxw( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).z, float3( a.rgb).x, a.a); }
+export float4 xzyx( core::color4 a) { return xzyx( float3( a.rgb)); }
+export float4 xzyy( core::color4 a) { return xzyy( float3( a.rgb)); }
+export float4 xzyz( core::color4 a) { return xzyz( float3( a.rgb)); }
+export float4 xzyw( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).z, float3( a.rgb).y, a.a); }
+export float4 xzzx( core::color4 a) { return xzzx( float3( a.rgb)); }
+export float4 xzzy( core::color4 a) { return xzzy( float3( a.rgb)); }
+export float4 xzzz( core::color4 a) { return xzzz( float3( a.rgb)); }
+export float4 xzzw( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).z, float3( a.rgb).z, a.a); }
+export float4 xzwx( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).z, a.a, float3( a.rgb).x); }
+export float4 xzwy( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).z, a.a, float3( a.rgb).y); }
+export float4 xzwz( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).z, a.a, float3( a.rgb).z); }
+export float4 xzww( core::color4 a) { return float4( float3( a.rgb).x, float3( a.rgb).z, a.a, a.a); }
+export float4 xwxx( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).x, float3( a.rgb).x); }
+export float4 xwxy( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).x, float3( a.rgb).y); }
+export float4 xwxz( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).x, float3( a.rgb).z); }
+export float4 xwxw( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).x, a.a); }
+export float4 xwyx( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).y, float3( a.rgb).x); }
+export float4 xwyy( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).y, float3( a.rgb).y); }
+export float4 xwyz( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).y, float3( a.rgb).z); }
+export float4 xwyw( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).y, a.a); }
+export float4 xwzx( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).z, float3( a.rgb).x); }
+export float4 xwzy( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).z, float3( a.rgb).y); }
+export float4 xwzz( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).z, float3( a.rgb).z); }
+export float4 xwzw( core::color4 a) { return float4( float3( a.rgb).x, a.a, float3( a.rgb).z, a.a); }
+export float4 xwwx( core::color4 a) { return float4( float3( a.rgb).x, a.a, a.a, float3( a.rgb).x); }
+export float4 xwwy( core::color4 a) { return float4( float3( a.rgb).x, a.a, a.a, float3( a.rgb).y); }
+export float4 xwwz( core::color4 a) { return float4( float3( a.rgb).x, a.a, a.a, float3( a.rgb).z); }
+export float4 xwww( core::color4 a) { return float4( float3( a.rgb).x, a.a, a.a, a.a); }
+export float4 yxxx( core::color4 a) { return yxxx( float3( a.rgb)); }
+export float4 yxxy( core::color4 a) { return yxxy( float3( a.rgb)); }
+export float4 yxxz( core::color4 a) { return yxxz( float3( a.rgb)); }
+export float4 yxxw( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).x, float3( a.rgb).x, a.a); }
+export float4 yxyx( core::color4 a) { return yxyx( float3( a.rgb)); }
+export float4 yxyy( core::color4 a) { return yxyy( float3( a.rgb)); }
+export float4 yxyz( core::color4 a) { return yxyz( float3( a.rgb)); }
+export float4 yxyw( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).x, float3( a.rgb).y, a.a); }
+export float4 yxzx( core::color4 a) { return yxzx( float3( a.rgb)); }
+export float4 yxzy( core::color4 a) { return yxzy( float3( a.rgb)); }
+export float4 yxzz( core::color4 a) { return yxzz( float3( a.rgb)); }
+export float4 yxzw( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).x, float3( a.rgb).z, a.a); }
+export float4 yxwx( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).x, a.a, float3( a.rgb).x); }
+export float4 yxwy( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).x, a.a, float3( a.rgb).y); }
+export float4 yxwz( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).x, a.a, float3( a.rgb).z); }
+export float4 yxww( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).x, a.a, a.a); }
+export float4 yyxx( core::color4 a) { return yyxx( float3( a.rgb)); }
+export float4 yyxy( core::color4 a) { return yyxy( float3( a.rgb)); }
+export float4 yyxz( core::color4 a) { return yyxz( float3( a.rgb)); }
+export float4 yyxw( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).y, float3( a.rgb).x, a.a); }
+export float4 yyyx( core::color4 a) { return yyyx( float3( a.rgb)); }
+export float4 yyyy( core::color4 a) { return yyyy( float3( a.rgb)); }
+export float4 yyyz( core::color4 a) { return yyyz( float3( a.rgb)); }
+export float4 yyyw( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).y, float3( a.rgb).y, a.a); }
+export float4 yyzx( core::color4 a) { return yyzx( float3( a.rgb)); }
+export float4 yyzy( core::color4 a) { return yyzy( float3( a.rgb)); }
+export float4 yyzz( core::color4 a) { return yyzz( float3( a.rgb)); }
+export float4 yyzw( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).y, float3( a.rgb).z, a.a); }
+export float4 yywx( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).y, a.a, float3( a.rgb).x); }
+export float4 yywy( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).y, a.a, float3( a.rgb).y); }
+export float4 yywz( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).y, a.a, float3( a.rgb).z); }
+export float4 yyww( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).y, a.a, a.a); }
+export float4 yzxx( core::color4 a) { return yzxx( float3( a.rgb)); }
+export float4 yzxy( core::color4 a) { return yzxy( float3( a.rgb)); }
+export float4 yzxz( core::color4 a) { return yzxz( float3( a.rgb)); }
+export float4 yzxw( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).z, float3( a.rgb).x, a.a); }
+export float4 yzyx( core::color4 a) { return yzyx( float3( a.rgb)); }
+export float4 yzyy( core::color4 a) { return yzyy( float3( a.rgb)); }
+export float4 yzyz( core::color4 a) { return yzyz( float3( a.rgb)); }
+export float4 yzyw( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).z, float3( a.rgb).y, a.a); }
+export float4 yzzx( core::color4 a) { return yzzx( float3( a.rgb)); }
+export float4 yzzy( core::color4 a) { return yzzy( float3( a.rgb)); }
+export float4 yzzz( core::color4 a) { return yzzz( float3( a.rgb)); }
+export float4 yzzw( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).z, float3( a.rgb).z, a.a); }
+export float4 yzwx( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).z, a.a, float3( a.rgb).x); }
+export float4 yzwy( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).z, a.a, float3( a.rgb).y); }
+export float4 yzwz( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).z, a.a, float3( a.rgb).z); }
+export float4 yzww( core::color4 a) { return float4( float3( a.rgb).y, float3( a.rgb).z, a.a, a.a); }
+export float4 ywxx( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).x, float3( a.rgb).x); }
+export float4 ywxy( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).x, float3( a.rgb).y); }
+export float4 ywxz( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).x, float3( a.rgb).z); }
+export float4 ywxw( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).x, a.a); }
+export float4 ywyx( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).y, float3( a.rgb).x); }
+export float4 ywyy( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).y, float3( a.rgb).y); }
+export float4 ywyz( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).y, float3( a.rgb).z); }
+export float4 ywyw( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).y, a.a); }
+export float4 ywzx( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).z, float3( a.rgb).x); }
+export float4 ywzy( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).z, float3( a.rgb).y); }
+export float4 ywzz( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).z, float3( a.rgb).z); }
+export float4 ywzw( core::color4 a) { return float4( float3( a.rgb).y, a.a, float3( a.rgb).z, a.a); }
+export float4 ywwx( core::color4 a) { return float4( float3( a.rgb).y, a.a, a.a, float3( a.rgb).x); }
+export float4 ywwy( core::color4 a) { return float4( float3( a.rgb).y, a.a, a.a, float3( a.rgb).y); }
+export float4 ywwz( core::color4 a) { return float4( float3( a.rgb).y, a.a, a.a, float3( a.rgb).z); }
+export float4 ywww( core::color4 a) { return float4( float3( a.rgb).y, a.a, a.a, a.a); }
+export float4 zxxx( core::color4 a) { return zxxx( float3( a.rgb)); }
+export float4 zxxy( core::color4 a) { return zxxy( float3( a.rgb)); }
+export float4 zxxz( core::color4 a) { return zxxz( float3( a.rgb)); }
+export float4 zxxw( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).x, float3( a.rgb).x, a.a); }
+export float4 zxyx( core::color4 a) { return zxyx( float3( a.rgb)); }
+export float4 zxyy( core::color4 a) { return zxyy( float3( a.rgb)); }
+export float4 zxyz( core::color4 a) { return zxyz( float3( a.rgb)); }
+export float4 zxyw( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).x, float3( a.rgb).y, a.a); }
+export float4 zxzx( core::color4 a) { return zxzx( float3( a.rgb)); }
+export float4 zxzy( core::color4 a) { return zxzy( float3( a.rgb)); }
+export float4 zxzz( core::color4 a) { return zxzz( float3( a.rgb)); }
+export float4 zxzw( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).x, float3( a.rgb).z, a.a); }
+export float4 zxwx( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).x, a.a, float3( a.rgb).x); }
+export float4 zxwy( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).x, a.a, float3( a.rgb).y); }
+export float4 zxwz( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).x, a.a, float3( a.rgb).z); }
+export float4 zxww( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).x, a.a, a.a); }
+export float4 zyxx( core::color4 a) { return zyxx( float3( a.rgb)); }
+export float4 zyxy( core::color4 a) { return zyxy( float3( a.rgb)); }
+export float4 zyxz( core::color4 a) { return zyxz( float3( a.rgb)); }
+export float4 zyxw( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).y, float3( a.rgb).x, a.a); }
+export float4 zyyx( core::color4 a) { return zyyx( float3( a.rgb)); }
+export float4 zyyy( core::color4 a) { return zyyy( float3( a.rgb)); }
+export float4 zyyz( core::color4 a) { return zyyz( float3( a.rgb)); }
+export float4 zyyw( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).y, float3( a.rgb).y, a.a); }
+export float4 zyzx( core::color4 a) { return zyzx( float3( a.rgb)); }
+export float4 zyzy( core::color4 a) { return zyzy( float3( a.rgb)); }
+export float4 zyzz( core::color4 a) { return zyzz( float3( a.rgb)); }
+export float4 zyzw( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).y, float3( a.rgb).z, a.a); }
+export float4 zywx( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).y, a.a, float3( a.rgb).x); }
+export float4 zywy( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).y, a.a, float3( a.rgb).y); }
+export float4 zywz( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).y, a.a, float3( a.rgb).z); }
+export float4 zyww( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).y, a.a, a.a); }
+export float4 zzxx( core::color4 a) { return zzxx( float3( a.rgb)); }
+export float4 zzxy( core::color4 a) { return zzxy( float3( a.rgb)); }
+export float4 zzxz( core::color4 a) { return zzxz( float3( a.rgb)); }
+export float4 zzxw( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).z, float3( a.rgb).x, a.a); }
+export float4 zzyx( core::color4 a) { return zzyx( float3( a.rgb)); }
+export float4 zzyy( core::color4 a) { return zzyy( float3( a.rgb)); }
+export float4 zzyz( core::color4 a) { return zzyz( float3( a.rgb)); }
+export float4 zzyw( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).z, float3( a.rgb).y, a.a); }
+export float4 zzzx( core::color4 a) { return zzzx( float3( a.rgb)); }
+export float4 zzzy( core::color4 a) { return zzzy( float3( a.rgb)); }
+export float4 zzzz( core::color4 a) { return zzzz( float3( a.rgb)); }
+export float4 zzzw( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).z, float3( a.rgb).z, a.a); }
+export float4 zzwx( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).z, a.a, float3( a.rgb).x); }
+export float4 zzwy( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).z, a.a, float3( a.rgb).y); }
+export float4 zzwz( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).z, a.a, float3( a.rgb).z); }
+export float4 zzww( core::color4 a) { return float4( float3( a.rgb).z, float3( a.rgb).z, a.a, a.a); }
+export float4 zwxx( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).x, float3( a.rgb).x); }
+export float4 zwxy( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).x, float3( a.rgb).y); }
+export float4 zwxz( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).x, float3( a.rgb).z); }
+export float4 zwxw( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).x, a.a); }
+export float4 zwyx( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).y, float3( a.rgb).x); }
+export float4 zwyy( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).y, float3( a.rgb).y); }
+export float4 zwyz( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).y, float3( a.rgb).z); }
+export float4 zwyw( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).y, a.a); }
+export float4 zwzx( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).z, float3( a.rgb).x); }
+export float4 zwzy( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).z, float3( a.rgb).y); }
+export float4 zwzz( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).z, float3( a.rgb).z); }
+export float4 zwzw( core::color4 a) { return float4( float3( a.rgb).z, a.a, float3( a.rgb).z, a.a); }
+export float4 zwwx( core::color4 a) { return float4( float3( a.rgb).z, a.a, a.a, float3( a.rgb).x); }
+export float4 zwwy( core::color4 a) { return float4( float3( a.rgb).z, a.a, a.a, float3( a.rgb).y); }
+export float4 zwwz( core::color4 a) { return float4( float3( a.rgb).z, a.a, a.a, float3( a.rgb).z); }
+export float4 zwww( core::color4 a) { return float4( float3( a.rgb).z, a.a, a.a, a.a); }
+export float4 wxxx( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).x, float3( a.rgb).x); }
+export float4 wxxy( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).x, float3( a.rgb).y); }
+export float4 wxxz( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).x, float3( a.rgb).z); }
+export float4 wxxw( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).x, a.a); }
+export float4 wxyx( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).y, float3( a.rgb).x); }
+export float4 wxyy( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).y, float3( a.rgb).y); }
+export float4 wxyz( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).y, float3( a.rgb).z); }
+export float4 wxyw( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).y, a.a); }
+export float4 wxzx( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).z, float3( a.rgb).x); }
+export float4 wxzy( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).z, float3( a.rgb).y); }
+export float4 wxzz( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).z, float3( a.rgb).z); }
+export float4 wxzw( core::color4 a) { return float4( a.a, float3( a.rgb).x, float3( a.rgb).z, a.a); }
+export float4 wxwx( core::color4 a) { return float4( a.a, float3( a.rgb).x, a.a, float3( a.rgb).x); }
+export float4 wxwy( core::color4 a) { return float4( a.a, float3( a.rgb).x, a.a, float3( a.rgb).y); }
+export float4 wxwz( core::color4 a) { return float4( a.a, float3( a.rgb).x, a.a, float3( a.rgb).z); }
+export float4 wxww( core::color4 a) { return float4( a.a, float3( a.rgb).x, a.a, a.a); }
+export float4 wyxx( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).x, float3( a.rgb).x); }
+export float4 wyxy( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).x, float3( a.rgb).y); }
+export float4 wyxz( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).x, float3( a.rgb).z); }
+export float4 wyxw( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).x, a.a); }
+export float4 wyyx( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).y, float3( a.rgb).x); }
+export float4 wyyy( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).y, float3( a.rgb).y); }
+export float4 wyyz( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).y, float3( a.rgb).z); }
+export float4 wyyw( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).y, a.a); }
+export float4 wyzx( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).z, float3( a.rgb).x); }
+export float4 wyzy( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).z, float3( a.rgb).y); }
+export float4 wyzz( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).z, float3( a.rgb).z); }
+export float4 wyzw( core::color4 a) { return float4( a.a, float3( a.rgb).y, float3( a.rgb).z, a.a); }
+export float4 wywx( core::color4 a) { return float4( a.a, float3( a.rgb).y, a.a, float3( a.rgb).x); }
+export float4 wywy( core::color4 a) { return float4( a.a, float3( a.rgb).y, a.a, float3( a.rgb).y); }
+export float4 wywz( core::color4 a) { return float4( a.a, float3( a.rgb).y, a.a, float3( a.rgb).z); }
+export float4 wyww( core::color4 a) { return float4( a.a, float3( a.rgb).y, a.a, a.a); }
+export float4 wzxx( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).x, float3( a.rgb).x); }
+export float4 wzxy( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).x, float3( a.rgb).y); }
+export float4 wzxz( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).x, float3( a.rgb).z); }
+export float4 wzxw( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).x, a.a); }
+export float4 wzyx( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).y, float3( a.rgb).x); }
+export float4 wzyy( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).y, float3( a.rgb).y); }
+export float4 wzyz( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).y, float3( a.rgb).z); }
+export float4 wzyw( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).y, a.a); }
+export float4 wzzx( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).z, float3( a.rgb).x); }
+export float4 wzzy( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).z, float3( a.rgb).y); }
+export float4 wzzz( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).z, float3( a.rgb).z); }
+export float4 wzzw( core::color4 a) { return float4( a.a, float3( a.rgb).z, float3( a.rgb).z, a.a); }
+export float4 wzwx( core::color4 a) { return float4( a.a, float3( a.rgb).z, a.a, float3( a.rgb).x); }
+export float4 wzwy( core::color4 a) { return float4( a.a, float3( a.rgb).z, a.a, float3( a.rgb).y); }
+export float4 wzwz( core::color4 a) { return float4( a.a, float3( a.rgb).z, a.a, float3( a.rgb).z); }
+export float4 wzww( core::color4 a) { return float4( a.a, float3( a.rgb).z, a.a, a.a); }
+export float4 wwxx( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).x, float3( a.rgb).x); }
+export float4 wwxy( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).x, float3( a.rgb).y); }
+export float4 wwxz( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).x, float3( a.rgb).z); }
+export float4 wwxw( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).x, a.a); }
+export float4 wwyx( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).y, float3( a.rgb).x); }
+export float4 wwyy( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).y, float3( a.rgb).y); }
+export float4 wwyz( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).y, float3( a.rgb).z); }
+export float4 wwyw( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).y, a.a); }
+export float4 wwzx( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).z, float3( a.rgb).x); }
+export float4 wwzy( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).z, float3( a.rgb).y); }
+export float4 wwzz( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).z, float3( a.rgb).z); }
+export float4 wwzw( core::color4 a) { return float4( a.a, a.a, float3( a.rgb).z, a.a); }
+export float4 wwwx( core::color4 a) { return float4( a.a, a.a, a.a, float3( a.rgb).x); }
+export float4 wwwy( core::color4 a) { return float4( a.a, a.a, a.a, float3( a.rgb).y); }
+export float4 wwwz( core::color4 a) { return float4( a.a, a.a, a.a, float3( a.rgb).z); }
+export float4 wwww( core::color4 a) { return float4( a.a, a.a, a.a, a.a); }
+
diff --git a/Sources/MXResources/libraries/nprlib/genglsl/nprlib_genglsl_impl.mtlx b/Sources/MXResources/libraries/nprlib/genglsl/nprlib_genglsl_impl.mtlx
new file mode 100644
index 00000000..1a96f315
--- /dev/null
+++ b/Sources/MXResources/libraries/nprlib/genglsl/nprlib_genglsl_impl.mtlx
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/libraries/nprlib/genmdl/nprlib_genmdl_impl.mtlx b/Sources/MXResources/libraries/nprlib/genmdl/nprlib_genmdl_impl.mtlx
new file mode 100644
index 00000000..1c1a728b
--- /dev/null
+++ b/Sources/MXResources/libraries/nprlib/genmdl/nprlib_genmdl_impl.mtlx
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/libraries/nprlib/genmsl/nprlib_genmsl_impl.mtlx b/Sources/MXResources/libraries/nprlib/genmsl/nprlib_genmsl_impl.mtlx
new file mode 100644
index 00000000..615e9d8c
--- /dev/null
+++ b/Sources/MXResources/libraries/nprlib/genmsl/nprlib_genmsl_impl.mtlx
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/libraries/nprlib/genosl/nprlib_genosl_impl.mtlx b/Sources/MXResources/libraries/nprlib/genosl/nprlib_genosl_impl.mtlx
new file mode 100644
index 00000000..0b077b64
--- /dev/null
+++ b/Sources/MXResources/libraries/nprlib/genosl/nprlib_genosl_impl.mtlx
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/libraries/nprlib/nprlib_defs.mtlx b/Sources/MXResources/libraries/nprlib/nprlib_defs.mtlx
new file mode 100644
index 00000000..f8770e35
--- /dev/null
+++ b/Sources/MXResources/libraries/nprlib/nprlib_defs.mtlx
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/libraries/nprlib/nprlib_ng.mtlx b/Sources/MXResources/libraries/nprlib/nprlib_ng.mtlx
new file mode 100644
index 00000000..f3db3f51
--- /dev/null
+++ b/Sources/MXResources/libraries/nprlib/nprlib_ng.mtlx
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl b/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl
index 575991e2..0b28f364 100644
--- a/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl
+++ b/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl
@@ -1,15 +1,5 @@
#include "mx_microfacet_specular.glsl"
-// https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch20.html
-// Section 20.4 Equation 13
-float mx_latlong_compute_lod(vec3 dir, float pdf, float maxMipLevel, int envSamples)
-{
- const float MIP_LEVEL_OFFSET = 1.5;
- float effectiveMaxMipLevel = maxMipLevel - MIP_LEVEL_OFFSET;
- float distortion = sqrt(1.0 - mx_square(dir.y));
- return max(effectiveMaxMipLevel - 0.5 * log2(float(envSamples) * pdf * distortion), 0.0);
-}
-
vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distribution, FresnelData fd)
{
// Generate tangent frame.
@@ -69,10 +59,11 @@ vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distributio
radiance /= G1V * float(envRadianceSamples);
// Return the final radiance.
- return radiance;
+ return radiance * $envLightIntensity;
}
vec3 mx_environment_irradiance(vec3 N)
{
- return mx_latlong_map_lookup(N, $envMatrix, 0.0, $envIrradiance);
+ vec3 Li = mx_latlong_map_lookup(N, $envMatrix, 0.0, $envIrradiance);
+ return Li * $envLightIntensity;
}
diff --git a/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl b/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl
index 6def6fb4..778742c4 100644
--- a/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl
+++ b/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl
@@ -1,10 +1,10 @@
#include "mx_microfacet_specular.glsl"
-float mx_latlong_compute_lod(float alpha)
+// Return the mip level associated with the given alpha in a prefiltered environment.
+float mx_latlong_alpha_to_lod(float alpha)
{
- // Select a mip level based on input alpha.
- float lodBias = alpha < 0.25 ? sqrt(alpha) : 0.5*alpha + 0.375;
- return lodBias * float($envRadianceMips);
+ float lodBias = (alpha < 0.25) ? sqrt(alpha) : 0.5 * alpha + 0.375;
+ return lodBias * float($envRadianceMips - 1);
}
vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distribution, FresnelData fd)
@@ -19,11 +19,12 @@ vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distributio
float G = mx_ggx_smith_G2(NdotV, NdotV, avgAlpha);
vec3 FG = fd.refraction ? vec3(1.0) - (F * G) : F * G;
- vec3 Li = mx_latlong_map_lookup(L, $envMatrix, mx_latlong_compute_lod(avgAlpha), $envRadiance);
- return Li * FG;
+ vec3 Li = mx_latlong_map_lookup(L, $envMatrix, mx_latlong_alpha_to_lod(avgAlpha), $envRadiance);
+ return Li * FG * $envLightIntensity;
}
vec3 mx_environment_irradiance(vec3 N)
{
- return mx_latlong_map_lookup(N, $envMatrix, 0.0, $envIrradiance);
+ vec3 Li = mx_latlong_map_lookup(N, $envMatrix, 0.0, $envIrradiance);
+ return Li * $envLightIntensity;
}
diff --git a/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_table.glsl b/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_generate_albedo_table.glsl
similarity index 100%
rename from Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_table.glsl
rename to Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_generate_albedo_table.glsl
diff --git a/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_generate_prefilter_env.glsl b/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_generate_prefilter_env.glsl
new file mode 100644
index 00000000..41bf33aa
--- /dev/null
+++ b/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_generate_prefilter_env.glsl
@@ -0,0 +1,78 @@
+#include "mx_microfacet_specular.glsl"
+
+// Construct an orthonormal basis from a unit vector.
+// https://graphics.pixar.com/library/OrthonormalB/paper.pdf
+mat3 mx_orthonormal_basis(vec3 N)
+{
+ float sign = (N.z < 0.0) ? -1.0 : 1.0;
+ float a = -1.0 / (sign + N.z);
+ float b = N.x * N.y * a;
+ vec3 X = vec3(1.0 + sign * N.x * N.x * a, sign * b, -sign * N.x);
+ vec3 Y = vec3(b, sign + N.y * N.y * a, -N.y);
+ return mat3(X, Y, N);
+}
+
+// Return the alpha associated with the given mip level in a prefiltered environment.
+float mx_latlong_lod_to_alpha(float lod)
+{
+ float lodBias = lod / float($envRadianceMips - 1);
+ return (lodBias < 0.5) ? mx_square(lodBias) : 2.0 * (lodBias - 0.375);
+}
+
+// The inverse of mx_latlong_projection.
+vec3 mx_latlong_map_projection_inverse(vec2 uv)
+{
+ float latitude = (uv.y - 0.5) * M_PI;
+ float longitude = (uv.x - 0.5) * M_PI * 2.0;
+
+ float x = -cos(latitude) * sin(longitude);
+ float y = -sin(latitude);
+ float z = cos(latitude) * cos(longitude);
+
+ return vec3(x, y, z);
+}
+
+vec3 mx_generate_prefilter_env()
+{
+ // The tangent view vector is aligned with the normal.
+ vec3 V = vec3(0.0, 0.0, 1.0);
+ float NdotV = 1.0;
+
+ // Compute derived properties.
+ vec2 uv = gl_FragCoord.xy * pow(2.0, $envPrefilterMip) / vec2(textureSize($envRadiance, 0));
+ vec3 worldN = mx_latlong_map_projection_inverse(uv);
+ mat3 tangentToWorld = mx_orthonormal_basis(worldN);
+ float alpha = mx_latlong_lod_to_alpha(float($envPrefilterMip));
+ float G1V = mx_ggx_smith_G1(NdotV, alpha);
+
+ // Integrate the LD term for the given environment and alpha.
+ vec3 radiance = vec3(0.0, 0.0, 0.0);
+ float weight = 0.0;
+ int envRadianceSamples = 1024;
+ for (int i = 0; i < envRadianceSamples; i++)
+ {
+ vec2 Xi = mx_spherical_fibonacci(i, envRadianceSamples);
+
+ // Compute the half vector and incoming light direction.
+ vec3 H = mx_ggx_importance_sample_VNDF(Xi, V, vec2(alpha));
+ vec3 L = -V + 2.0 * H.z * H;
+
+ // Compute dot products for this sample.
+ float NdotL = clamp(L.z, M_FLOAT_EPS, 1.0);
+
+ // Compute the geometric term.
+ float G = mx_ggx_smith_G2(NdotL, NdotV, alpha);
+
+ // Sample the environment light from the given direction.
+ vec3 Lw = tangentToWorld * L;
+ float pdf = mx_ggx_NDF(H, vec2(alpha)) * G1V / (4.0 * NdotV);
+ float lod = mx_latlong_compute_lod(Lw, pdf, float($envRadianceMips - 1), envRadianceSamples);
+ vec3 sampleColor = mx_latlong_map_lookup(Lw, $envMatrix, lod, $envRadiance);
+
+ // Add the radiance contribution of this sample.
+ radiance += G * sampleColor;
+ weight += G;
+ }
+
+ return radiance / weight;
+}
diff --git a/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl b/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl
index 63aba178..ddbc3f6f 100644
--- a/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl
+++ b/Sources/MXResources/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl
@@ -593,3 +593,14 @@ vec3 mx_latlong_map_lookup(vec3 dir, mat4 transform, float lod, sampler2D envSam
vec2 uv = mx_latlong_projection(envDir);
return textureLod(envSampler, uv, lod).rgb;
}
+
+// Return the mip level with the appropriate coverage for a filtered importance sample.
+// https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch20.html
+// Section 20.4 Equation 13
+float mx_latlong_compute_lod(vec3 dir, float pdf, float maxMipLevel, int envSamples)
+{
+ const float MIP_LEVEL_OFFSET = 1.5;
+ float effectiveMaxMipLevel = maxMipLevel - MIP_LEVEL_OFFSET;
+ float distortion = sqrt(1.0 - mx_square(dir.y));
+ return max(effectiveMaxMipLevel - 0.5 * log2(float(envSamples) * pdf * distortion), 0.0);
+}
diff --git a/Sources/MXResources/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl b/Sources/MXResources/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl
index dcaaadf1..d8bc1ba6 100644
--- a/Sources/MXResources/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl
+++ b/Sources/MXResources/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl
@@ -22,6 +22,7 @@ void mx_dielectric_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, floa
vec3 Ht = vec3(dot(H, X), dot(H, Y), dot(H, N));
FresnelData fd;
+ vec3 safeTint = max(tint, 0.0);
if (bsdf.thickness > 0.0)
{
fd = mx_init_fresnel_dielectric_airy(ior, bsdf.thickness, bsdf.ior);
@@ -40,7 +41,7 @@ void mx_dielectric_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, floa
bsdf.throughput = 1.0 - dirAlbedo * weight;
// Note: NdotL is cancelled out
- bsdf.response = D * F * G * comp * tint * occlusion * weight / (4.0 * NdotV);
+ bsdf.response = D * F * G * comp * safeTint * occlusion * weight / (4.0 * NdotV);
}
void mx_dielectric_bsdf_transmission(vec3 V, float weight, vec3 tint, float ior, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, inout BSDF bsdf)
@@ -54,6 +55,7 @@ void mx_dielectric_bsdf_transmission(vec3 V, float weight, vec3 tint, float ior,
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
FresnelData fd;
+ vec3 safeTint = max(tint, 0.0);
if (bsdf.thickness > 0.0)
{
fd = mx_init_fresnel_dielectric_airy(ior, bsdf.thickness, bsdf.ior);
@@ -74,7 +76,7 @@ void mx_dielectric_bsdf_transmission(vec3 V, float weight, vec3 tint, float ior,
if (scatter_mode != 0)
{
- bsdf.response = mx_surface_transmission(N, V, X, safeAlpha, distribution, fd, tint) * weight;
+ bsdf.response = mx_surface_transmission(N, V, X, safeAlpha, distribution, fd, safeTint) * weight;
}
}
@@ -90,6 +92,7 @@ void mx_dielectric_bsdf_indirect(vec3 V, float weight, vec3 tint, float ior, vec
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
FresnelData fd;
+ vec3 safeTint = max(tint, 0.0);
if (bsdf.thickness > 0.0)
{
fd = mx_init_fresnel_dielectric_airy(ior, bsdf.thickness, bsdf.ior);
@@ -109,5 +112,5 @@ void mx_dielectric_bsdf_indirect(vec3 V, float weight, vec3 tint, float ior, vec
bsdf.throughput = 1.0 - dirAlbedo * weight;
vec3 Li = mx_environment_radiance(N, V, X, safeAlpha, distribution, fd);
- bsdf.response = Li * tint * comp * weight;
+ bsdf.response = Li * safeTint * comp * weight;
}
diff --git a/Sources/MXResources/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl b/Sources/MXResources/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl
index ebeaa66f..544e479f 100644
--- a/Sources/MXResources/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl
+++ b/Sources/MXResources/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl
@@ -22,20 +22,22 @@ void mx_generalized_schlick_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlus
vec3 Ht = vec3(dot(H, X), dot(H, Y), dot(H, N));
FresnelData fd;
+ vec3 safeColor0 = max(color0, 0.0);
+ vec3 safeColor90 = max(color90, 0.0);
if (bsdf.thickness > 0.0)
{
- fd = mx_init_fresnel_schlick_airy(color0, color90, exponent, bsdf.thickness, bsdf.ior);
+ fd = mx_init_fresnel_schlick_airy(safeColor0, safeColor90, exponent, bsdf.thickness, bsdf.ior);
}
else
{
- fd = mx_init_fresnel_schlick(color0, color90, exponent);
+ fd = mx_init_fresnel_schlick(safeColor0, safeColor90, exponent);
}
vec3 F = mx_compute_fresnel(VdotH, fd);
float D = mx_ggx_NDF(Ht, safeAlpha);
float G = mx_ggx_smith_G2(NdotL, NdotV, avgAlpha);
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
- vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, color0, color90) * comp;
+ vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, safeColor0, safeColor90) * comp;
float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0));
bsdf.throughput = vec3(1.0 - avgDirAlbedo * weight);
@@ -54,13 +56,15 @@ void mx_generalized_schlick_bsdf_transmission(vec3 V, float weight, vec3 color0,
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
FresnelData fd;
+ vec3 safeColor0 = max(color0, 0.0);
+ vec3 safeColor90 = max(color90, 0.0);
if (bsdf.thickness > 0.0)
{
- fd = mx_init_fresnel_schlick_airy(color0, color90, exponent, bsdf.thickness, bsdf.ior);
+ fd = mx_init_fresnel_schlick_airy(safeColor0, safeColor90, exponent, bsdf.thickness, bsdf.ior);
}
else
{
- fd = mx_init_fresnel_schlick(color0, color90, exponent);
+ fd = mx_init_fresnel_schlick(safeColor0, safeColor90, exponent);
}
vec3 F = mx_compute_fresnel(NdotV, fd);
@@ -68,15 +72,15 @@ void mx_generalized_schlick_bsdf_transmission(vec3 V, float weight, vec3 color0,
float avgAlpha = mx_average_alpha(safeAlpha);
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
- vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, color0, color90) * comp;
+ vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, safeColor0, safeColor90) * comp;
float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0));
bsdf.throughput = vec3(1.0 - avgDirAlbedo * weight);
if (scatter_mode != 0)
{
- float avgF0 = dot(color0, vec3(1.0 / 3.0));
+ float avgF0 = dot(safeColor0, vec3(1.0 / 3.0));
fd.ior = vec3(mx_f0_to_ior(avgF0));
- bsdf.response = mx_surface_transmission(N, V, X, safeAlpha, distribution, fd, color0) * weight;
+ bsdf.response = mx_surface_transmission(N, V, X, safeAlpha, distribution, fd, safeColor0) * weight;
}
}
@@ -91,20 +95,22 @@ void mx_generalized_schlick_bsdf_indirect(vec3 V, float weight, vec3 color0, vec
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
FresnelData fd;
+ vec3 safeColor0 = max(color0, 0.0);
+ vec3 safeColor90 = max(color90, 0.0);
if (bsdf.thickness > 0.0)
{
- fd = mx_init_fresnel_schlick_airy(color0, color90, exponent, bsdf.thickness, bsdf.ior);
+ fd = mx_init_fresnel_schlick_airy(safeColor0, safeColor90, exponent, bsdf.thickness, bsdf.ior);
}
else
{
- fd = mx_init_fresnel_schlick(color0, color90, exponent);
+ fd = mx_init_fresnel_schlick(safeColor0, safeColor90, exponent);
}
vec3 F = mx_compute_fresnel(NdotV, fd);
vec2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
float avgAlpha = mx_average_alpha(safeAlpha);
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
- vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, color0, color90) * comp;
+ vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, safeColor0, safeColor90) * comp;
float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0));
bsdf.throughput = vec3(1.0 - avgDirAlbedo * weight);
diff --git a/Sources/MXResources/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx b/Sources/MXResources/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx
index 800e32ed..a4277bf6 100644
--- a/Sources/MXResources/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx
+++ b/Sources/MXResources/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx
@@ -2,98 +2,98 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
+
-
+
diff --git a/Sources/MXResources/libraries/pbrlib/genosl/pbrlib_genosl_impl.legacy b/Sources/MXResources/libraries/pbrlib/genosl/pbrlib_genosl_impl.legacy
deleted file mode 100644
index 6ab7cc9e..00000000
--- a/Sources/MXResources/libraries/pbrlib/genosl/pbrlib_genosl_impl.legacy
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_creatematrix_vector3_matrix33.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_creatematrix_vector3_matrix33.glsl
new file mode 100644
index 00000000..aa10ef5b
--- /dev/null
+++ b/Sources/MXResources/libraries/stdlib/genglsl/mx_creatematrix_vector3_matrix33.glsl
@@ -0,0 +1,6 @@
+void mx_creatematrix_vector3_matrix33(vec3 in1, vec3 in2, vec3 in3, out mat3 result)
+{
+ result = mat3(in1.x, in1.y, in1.z,
+ in2.x, in2.y, in2.z,
+ in3.x, in3.y, in3.z);
+}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_creatematrix_vector3_matrix44.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_creatematrix_vector3_matrix44.glsl
new file mode 100644
index 00000000..194fad42
--- /dev/null
+++ b/Sources/MXResources/libraries/stdlib/genglsl/mx_creatematrix_vector3_matrix44.glsl
@@ -0,0 +1,7 @@
+void mx_creatematrix_vector3_matrix44(vec3 in1, vec3 in2, vec3 in3, vec3 in4, out mat4 result)
+{
+ result = mat4(in1.x, in1.y, in1.z, 0.0,
+ in2.x, in2.y, in2.z, 0.0,
+ in3.x, in3.y, in3.z, 0.0,
+ in4.x, in4.y, in4.z, 1.0);
+}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_creatematrix_vector4_matrix44.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_creatematrix_vector4_matrix44.glsl
new file mode 100644
index 00000000..665a2221
--- /dev/null
+++ b/Sources/MXResources/libraries/stdlib/genglsl/mx_creatematrix_vector4_matrix44.glsl
@@ -0,0 +1,7 @@
+void mx_creatematrix_vector4_matrix44(vec4 in1, vec4 in2, vec4 in3, vec4 in4, out mat4 result)
+{
+ result = mat4(in1.x, in1.y, in1.z, in1.w,
+ in2.x, in2.y, in2.z, in2.w,
+ in3.x, in3.y, in3.z, in3.w,
+ in4.x, in4.y, in4.z, in4.w);
+}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_fractal3d_fa_vector2.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_fractal3d_fa_vector2.glsl
deleted file mode 100644
index 59dbbee1..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_fractal3d_fa_vector2.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "lib/mx_noise.glsl"
-
-void mx_fractal3d_fa_vector2(float amplitude, int octaves, float lacunarity, float diminish, vec3 position, out vec2 result)
-{
- vec2 value = mx_fractal_noise_vec2(position, octaves, lacunarity, diminish);
- result = value * amplitude;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_fractal3d_fa_vector3.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_fractal3d_fa_vector3.glsl
deleted file mode 100644
index d0f30def..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_fractal3d_fa_vector3.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "lib/mx_noise.glsl"
-
-void mx_fractal3d_fa_vector3(float amplitude, int octaves, float lacunarity, float diminish, vec3 position, out vec3 result)
-{
- vec3 value = mx_fractal_noise_vec3(position, octaves, lacunarity, diminish);
- result = value * amplitude;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_fractal3d_fa_vector4.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_fractal3d_fa_vector4.glsl
deleted file mode 100644
index b9c66c44..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_fractal3d_fa_vector4.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "lib/mx_noise.glsl"
-
-void mx_fractal3d_fa_vector4(float amplitude, int octaves, float lacunarity, float diminish, vec3 position, out vec4 result)
-{
- vec4 value = mx_fractal_noise_vec4(position, octaves, lacunarity, diminish);
- result = value * amplitude;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl
deleted file mode 100644
index f5a81565..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "lib/mx_noise.glsl"
-
-void mx_noise2d_fa_vector2(float amplitude, float pivot, vec2 texcoord, out vec2 result)
-{
- vec3 value = mx_perlin_noise_vec3(texcoord);
- result = value.xy * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl
deleted file mode 100644
index 0735965c..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "lib/mx_noise.glsl"
-
-void mx_noise2d_fa_vector3(float amplitude, float pivot, vec2 texcoord, out vec3 result)
-{
- vec3 value = mx_perlin_noise_vec3(texcoord);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl
deleted file mode 100644
index 6d51a59e..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "lib/mx_noise.glsl"
-
-void mx_noise2d_fa_vector4(float amplitude, float pivot, vec2 texcoord, out vec4 result)
-{
- vec3 xyz = mx_perlin_noise_vec3(texcoord);
- float w = mx_perlin_noise_float(texcoord + vec2(19, 73));
- result = vec4(xyz, w) * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl
deleted file mode 100644
index 06d91f91..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "lib/mx_noise.glsl"
-
-void mx_noise3d_fa_vector2(float amplitude, float pivot, vec3 position, out vec2 result)
-{
- vec3 value = mx_perlin_noise_vec3(position);
- result = value.xy * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl
deleted file mode 100644
index 168bf572..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "lib/mx_noise.glsl"
-
-void mx_noise3d_fa_vector3(float amplitude, float pivot, vec3 position, out vec3 result)
-{
- vec3 value = mx_perlin_noise_vec3(position);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl
deleted file mode 100644
index 680410f9..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "lib/mx_noise.glsl"
-
-void mx_noise3d_fa_vector4(float amplitude, float pivot, vec3 position, out vec4 result)
-{
- vec3 xyz = mx_perlin_noise_vec3(position);
- float w = mx_perlin_noise_float(position + vec3(19, 73, 29));
- result = vec4(xyz, w) * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_normalmap.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_normalmap.glsl
index 86d5610f..19e0797c 100644
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_normalmap.glsl
+++ b/Sources/MXResources/libraries/stdlib/genglsl/mx_normalmap.glsl
@@ -1,4 +1,4 @@
-void mx_normalmap(vec3 value, int map_space, float normal_scale, vec3 N, vec3 T, out vec3 result)
+void mx_normalmap_vector2(vec3 value, int map_space, vec2 normal_scale, vec3 N, vec3 T, out vec3 result)
{
// Decode the normal map.
value = (value == vec3(0.0f)) ? vec3(0.0, 0.0, 1.0) : value * 2.0 - 1.0;
@@ -14,3 +14,8 @@ void mx_normalmap(vec3 value, int map_space, float normal_scale, vec3 N, vec3 T,
// Normalize the result.
result = normalize(value);
}
+
+void mx_normalmap_float(vec3 value, int map_space, float normal_scale, vec3 N, vec3 T, out vec3 result)
+{
+ mx_normalmap_vector2(value, map_space, vec2(normal_scale), N, T, result);
+}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl
deleted file mode 100644
index 0b16d99e..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "mx_smoothstep_float.glsl"
-
-void mx_smoothstep_vec2FA(vec2 val, float low, float high, out vec2 result)
-{
- mx_smoothstep_float(val.x, low, high, result.x);
- mx_smoothstep_float(val.y, low, high, result.y);
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl
deleted file mode 100644
index ffc913e6..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "mx_smoothstep_float.glsl"
-
-void mx_smoothstep_vec3FA(vec3 val, float low, float high, out vec3 result)
-{
- mx_smoothstep_float(val.x, low, high, result.x);
- mx_smoothstep_float(val.y, low, high, result.y);
- mx_smoothstep_float(val.z, low, high, result.z);
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl
deleted file mode 100644
index e001efd8..00000000
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "mx_smoothstep_float.glsl"
-
-void mx_smoothstep_vec4FA(vec4 val, float low, float high, out vec4 result)
-{
- mx_smoothstep_float(val.x, low, high, result.x);
- mx_smoothstep_float(val.y, low, high, result.y);
- mx_smoothstep_float(val.z, low, high, result.z);
- mx_smoothstep_float(val.w, low, high, result.w);
-}
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vector2.glsl
similarity index 67%
rename from Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl
rename to Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vector2.glsl
index c46152e3..f0e630af 100644
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl
+++ b/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vector2.glsl
@@ -1,6 +1,6 @@
#include "mx_smoothstep_float.glsl"
-void mx_smoothstep_vec2(vec2 val, vec2 low, vec2 high, out vec2 result)
+void mx_smoothstep_vector2(vec2 val, vec2 low, vec2 high, out vec2 result)
{
mx_smoothstep_float(val.x, low.x, high.x, result.x);
mx_smoothstep_float(val.y, low.y, high.y, result.y);
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vector3.glsl
similarity index 73%
rename from Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl
rename to Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vector3.glsl
index ce15fcdd..b6094785 100644
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl
+++ b/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vector3.glsl
@@ -1,6 +1,6 @@
#include "mx_smoothstep_float.glsl"
-void mx_smoothstep_vec3(vec3 val, vec3 low, vec3 high, out vec3 result)
+void mx_smoothstep_vector3(vec3 val, vec3 low, vec3 high, out vec3 result)
{
mx_smoothstep_float(val.x, low.x, high.x, result.x);
mx_smoothstep_float(val.y, low.y, high.y, result.y);
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl b/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vector4.glsl
similarity index 78%
rename from Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl
rename to Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vector4.glsl
index 04609b60..1a2d4a98 100644
--- a/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl
+++ b/Sources/MXResources/libraries/stdlib/genglsl/mx_smoothstep_vector4.glsl
@@ -1,6 +1,6 @@
#include "mx_smoothstep_float.glsl"
-void mx_smoothstep_vec4(vec4 val, vec4 low, vec4 high, out vec4 result)
+void mx_smoothstep_vector4(vec4 val, vec4 low, vec4 high, out vec4 result)
{
mx_smoothstep_float(val.x, low.x, high.x, result.x);
mx_smoothstep_float(val.y, low.y, high.y, result.y);
diff --git a/Sources/MXResources/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx b/Sources/MXResources/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
index 07aae6ce..243a2647 100644
--- a/Sources/MXResources/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
+++ b/Sources/MXResources/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
@@ -42,7 +42,9 @@
-
+
+
+
@@ -96,42 +98,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -321,6 +302,15 @@
+
+
+
+
+
+
+
+
+
@@ -497,16 +487,9 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -748,6 +731,11 @@
+
+
+
+
+
diff --git a/Sources/MXResources/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx b/Sources/MXResources/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
index 022f0896..7d80ecb4 100644
--- a/Sources/MXResources/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
+++ b/Sources/MXResources/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
@@ -15,36 +15,37 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
@@ -65,144 +66,123 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
@@ -274,10 +254,10 @@
-
-
-
-
+
+
+
+
@@ -289,8 +269,8 @@
-
-
+
+
@@ -301,15 +281,15 @@
-
+
-
-
+
+
@@ -317,19 +297,28 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -386,8 +375,8 @@
-
-
+
+
@@ -396,8 +385,8 @@
-
-
+
+
@@ -409,8 +398,8 @@
-
-
+
+
@@ -422,8 +411,8 @@
-
-
+
+
@@ -450,37 +439,37 @@
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
+
-
+
@@ -489,102 +478,95 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -600,85 +582,85 @@
-
-
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -754,6 +736,11 @@
+
+
+
+
+
diff --git a/Sources/MXResources/libraries/stdlib/genmsl/mx_normalmap.metal b/Sources/MXResources/libraries/stdlib/genmsl/mx_normalmap.metal
index c9c7bd55..a3ffedaa 100644
--- a/Sources/MXResources/libraries/stdlib/genmsl/mx_normalmap.metal
+++ b/Sources/MXResources/libraries/stdlib/genmsl/mx_normalmap.metal
@@ -1,4 +1,4 @@
-void mx_normalmap(vec3 value, int map_space, float normal_scale, vec3 N, vec3 T, out vec3 result)
+void mx_normalmap_vector2(vec3 value, int map_space, vec2 normal_scale, vec3 N, vec3 T, out vec3 result)
{
// Decode the normal map.
value = all(value == vec3(0.0f)) ? vec3(0.0, 0.0, 1.0) : value * 2.0 - 1.0;
@@ -14,3 +14,8 @@ void mx_normalmap(vec3 value, int map_space, float normal_scale, vec3 N, vec3 T,
// Normalize the result.
result = normalize(value);
}
+
+void mx_normalmap_float(vec3 value, int map_space, float normal_scale, vec3 N, vec3 T, out vec3 result)
+{
+ mx_normalmap_vector2(value, map_space, vec2(normal_scale), N, T, result);
+}
diff --git a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec2FA.metal b/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec2FA.metal
deleted file mode 100644
index a05a10d7..00000000
--- a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec2FA.metal
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "mx_smoothstep_float.metal"
-
-void mx_smoothstep_vec2FA(vec2 val, float low, float high, out vec2 result)
-{
- float f;
- mx_smoothstep_float(val.x, low, high, f); result.x = f;
- mx_smoothstep_float(val.y, low, high, f); result.y = f;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec3FA.metal b/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec3FA.metal
deleted file mode 100644
index 4a1922d5..00000000
--- a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec3FA.metal
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "mx_smoothstep_float.metal"
-
-void mx_smoothstep_vec3FA(vec3 val, float low, float high, out vec3 result)
-{
- float f;
- mx_smoothstep_float(val.x, low, high, f); result.x = f;
- mx_smoothstep_float(val.y, low, high, f); result.y = f;
- mx_smoothstep_float(val.z, low, high, f); result.z = f;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec4FA.metal b/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec4FA.metal
deleted file mode 100644
index a7c27cb0..00000000
--- a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec4FA.metal
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "mx_smoothstep_float.metal"
-
-void mx_smoothstep_vec4FA(vec4 val, float low, float high, out vec4 result)
-{
- float f;
- mx_smoothstep_float(val.x, low, high, f); result.x = f;
- mx_smoothstep_float(val.y, low, high, f); result.y = f;
- mx_smoothstep_float(val.z, low, high, f); result.z = f;
- mx_smoothstep_float(val.w, low, high, f); result.w = f;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec2.metal b/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vector2.metal
similarity index 70%
rename from Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec2.metal
rename to Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vector2.metal
index 0baa7631..34fec594 100644
--- a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec2.metal
+++ b/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vector2.metal
@@ -1,6 +1,6 @@
#include "mx_smoothstep_float.metal"
-void mx_smoothstep_vec2(vec2 val, vec2 low, vec2 high, out vec2 result)
+void mx_smoothstep_vector2(vec2 val, vec2 low, vec2 high, out vec2 result)
{
float f;
mx_smoothstep_float(val.x, low.x, high.x, f); result.x = f;
diff --git a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec3.metal b/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vector3.metal
similarity index 77%
rename from Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec3.metal
rename to Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vector3.metal
index b0f96975..5b0a9b62 100644
--- a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec3.metal
+++ b/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vector3.metal
@@ -1,6 +1,6 @@
#include "mx_smoothstep_float.metal"
-void mx_smoothstep_vec3(vec3 val, vec3 low, vec3 high, thread vec3& result)
+void mx_smoothstep_vector3(vec3 val, vec3 low, vec3 high, thread vec3& result)
{
float f;
mx_smoothstep_float(val.x, low.x, high.x, f); result.x = f;
diff --git a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec4.metal b/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vector4.metal
similarity index 80%
rename from Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec4.metal
rename to Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vector4.metal
index 8bf2f3d0..04dc7551 100644
--- a/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vec4.metal
+++ b/Sources/MXResources/libraries/stdlib/genmsl/mx_smoothstep_vector4.metal
@@ -1,6 +1,6 @@
#include "mx_smoothstep_float.metal"
-void mx_smoothstep_vec4(vec4 val, vec4 low, vec4 high, out vec4 result)
+void mx_smoothstep_vector4(vec4 val, vec4 low, vec4 high, out vec4 result)
{
float f;
mx_smoothstep_float(val.x, low.x, high.x, f); result.x = f;
diff --git a/Sources/MXResources/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx b/Sources/MXResources/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
index dea1c496..e8b61108 100644
--- a/Sources/MXResources/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
+++ b/Sources/MXResources/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
@@ -42,7 +42,8 @@
-
+
+
@@ -96,42 +97,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -322,6 +302,15 @@
+
+
+
+
+
+
+
+
+
@@ -498,16 +487,9 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -748,6 +730,11 @@
+
+
+
+
+
diff --git a/Sources/MXResources/libraries/stdlib/genosl/include/color4.h b/Sources/MXResources/libraries/stdlib/genosl/include/color4.h
index 78b06b24..dcee1012 100644
--- a/Sources/MXResources/libraries/stdlib/genosl/include/color4.h
+++ b/Sources/MXResources/libraries/stdlib/genosl/include/color4.h
@@ -151,6 +151,11 @@ color4 ceil(color4 a)
return color4(ceil(a.rgb), ceil(a.a));
}
+color4 round(color4 a)
+{
+ return color4(round(a.rgb), round(a.a));
+}
+
color4 floor(color4 a)
{
return color4(floor(a.rgb), floor(a.a));
diff --git a/Sources/MXResources/libraries/stdlib/genosl/include/vector2.h b/Sources/MXResources/libraries/stdlib/genosl/include/vector2.h
index f819dd14..83fad034 100644
--- a/Sources/MXResources/libraries/stdlib/genosl/include/vector2.h
+++ b/Sources/MXResources/libraries/stdlib/genosl/include/vector2.h
@@ -151,6 +151,11 @@ vector2 ceil(vector2 a)
return vector2 (ceil(a.x), ceil(a.y));
}
+vector2 round(vector2 a)
+{
+ return vector2 (round(a.x), round(a.y));
+}
+
vector2 floor(vector2 a)
{
return vector2 (floor(a.x), floor(a.y));
diff --git a/Sources/MXResources/libraries/stdlib/genosl/include/vector4.h b/Sources/MXResources/libraries/stdlib/genosl/include/vector4.h
index 56b64b0c..6c8b3996 100644
--- a/Sources/MXResources/libraries/stdlib/genosl/include/vector4.h
+++ b/Sources/MXResources/libraries/stdlib/genosl/include/vector4.h
@@ -160,6 +160,14 @@ vector4 ceil(vector4 in)
ceil(in.w));
}
+vector4 round(vector4 in)
+{
+ return vector4 (round(in.x),
+ round(in.y),
+ round(in.z),
+ round(in.w));
+}
+
vector4 floor(vector4 in)
{
return vector4 (floor(in.x),
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_creatematrix.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_creatematrix.osl
new file mode 100644
index 00000000..3e567d3b
--- /dev/null
+++ b/Sources/MXResources/libraries/stdlib/genosl/mx_creatematrix.osl
@@ -0,0 +1,23 @@
+void mx_creatematrix_vector3_matrix33(vector in1, vector in2, vector in3, output matrix result)
+{
+ result = matrix(in1.x, in1.y, in1.z, 0.0,
+ in2.x, in2.y, in2.z, 0.0,
+ in3.x, in3.y, in3.z, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+}
+
+void mx_creatematrix_vector3_matrix44(vector in1, vector in2, vector in3, vector in4, output matrix result)
+{
+ result = matrix(in1.x, in1.y, in1.z, 0.0,
+ in2.x, in2.y, in2.z, 0.0,
+ in3.x, in3.y, in3.z, 0.0,
+ in4.x, in4.y, in4.z, 1.0);
+}
+
+void mx_creatematrix_vector4_matrix44(vector4 in1, vector4 in2, vector4 in3, vector4 in4, output matrix result)
+{
+ result = matrix(in1.x, in1.y, in1.z, in1.w,
+ in2.x, in2.y, in2.z, in2.w,
+ in3.x, in3.y, in3.z, in3.w,
+ in4.x, in4.y, in4.z, in4.w);
+}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_color3.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_color3.osl
deleted file mode 100644
index bf174489..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_color3.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_fractal3d_color3(vector amplitude, int octaves, float lacunarity, float diminish, vector position, output color result)
-{
- color f = mx_fbm(position, octaves, lacunarity, diminish, "snoise");
- result = f * amplitude;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_color4.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_color4.osl
deleted file mode 100644
index 9943a92d..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_color4.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_fractal3d_color4(vector4 amplitude, int octaves, float lacunarity, float diminish, vector position, output color4 result)
-{
- color4 f = mx_fbm(position, octaves, lacunarity, diminish, "snoise");
- result = f * color4(color(amplitude.x, amplitude.y, amplitude.z), amplitude.w);
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_color3.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_color3.osl
deleted file mode 100644
index 889848c6..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_color3.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_fractal3d_fa_color3(float amplitude, int octaves, float lacunarity, float diminish, vector position, output color result)
-{
- color f = mx_fbm(position, octaves, lacunarity, diminish, "snoise");
- result = f * amplitude;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_color4.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_color4.osl
deleted file mode 100644
index d2a8f492..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_color4.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_fractal3d_fa_color4(float amplitude, int octaves, float lacunarity, float diminish, vector position, output color4 result)
-{
- color4 f = mx_fbm(position, octaves, lacunarity, diminish, "snoise");
- result = f * amplitude;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_vector2.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_vector2.osl
deleted file mode 100644
index c1266d47..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_vector2.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_fractal3d_fa_vector2(float amplitude, int octaves, float lacunarity, float diminish, vector position, output vector2 result)
-{
- vector2 f = mx_fbm(position, octaves, lacunarity, diminish, "snoise");
- result = f * amplitude;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_vector3.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_vector3.osl
deleted file mode 100644
index 34f6515c..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_vector3.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_fractal3d_fa_vector3(float amplitude, int octaves, float lacunarity, float diminish, vector position, output vector result)
-{
- vector f = mx_fbm(position, octaves, lacunarity, diminish, "snoise");
- result = f * amplitude;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_vector4.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_vector4.osl
deleted file mode 100644
index fb5a8c73..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_fractal3d_fa_vector4.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_fractal3d_fa_vector4(float amplitude, int octaves, float lacunarity, float diminish, vector position, output vector4 result)
-{
- vector4 f = mx_fbm(position, octaves, lacunarity, diminish, "snoise");
- result = f * amplitude;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_color3.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_color3.osl
deleted file mode 100644
index 37421ee8..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_color3.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise2d_color3(vector amplitude, float pivot, vector2 texcoord, output color result)
-{
- color value = noise("snoise", texcoord.x, texcoord.y);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_color4.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_color4.osl
deleted file mode 100644
index ec8064c5..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_color4.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise2d_color4(vector4 amplitude, float pivot, vector2 texcoord, output color4 result)
-{
- color4 value = mx_noise("snoise", texcoord.x, texcoord.y);
- result = value * color4(color(amplitude.x, amplitude.y, amplitude.z), amplitude.w) + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl
deleted file mode 100644
index 29c09c1a..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise2d_fa_color3(float amplitude, float pivot, vector2 texcoord, output color result)
-{
- color value = noise("snoise", texcoord.x, texcoord.y);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl
deleted file mode 100644
index 35d3463f..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise2d_fa_color4(float amplitude, float pivot, vector2 texcoord, output color4 result)
-{
- color4 value = mx_noise("snoise", texcoord.x, texcoord.y);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl
deleted file mode 100644
index b64dc6de..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise2d_fa_vector2(float amplitude, float pivot, vector2 texcoord, output vector2 result)
-{
- vector2 value = mx_noise("snoise", texcoord.x, texcoord.y);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl
deleted file mode 100644
index c1f060a2..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise2d_fa_vector3(float amplitude, float pivot, vector2 texcoord, output vector result)
-{
- vector value = noise("snoise", texcoord.x, texcoord.y);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl
deleted file mode 100644
index 9cb9f57c..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise2d_fa_vector4(float amplitude, float pivot, vector2 texcoord, output vector4 result)
-{
- vector4 value = mx_noise("snoise", texcoord.x, texcoord.y);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_color3.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_color3.osl
deleted file mode 100644
index f4649a59..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_color3.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise3d_color3(vector amplitude, float pivot, vector position, output color result)
-{
- color value = noise("snoise", position);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_color4.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_color4.osl
deleted file mode 100644
index c522f814..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_color4.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise3d_color4(vector4 amplitude, float pivot, vector position, output color4 result)
-{
- color4 value = mx_noise("snoise", position);
- result = value * color4(color(amplitude.x, amplitude.y, amplitude.z), amplitude.w) + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl
deleted file mode 100644
index 83b777b2..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise3d_fa_color3(float amplitude, float pivot, vector position, output color result)
-{
- color value = noise("snoise", position);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl
deleted file mode 100644
index ee1a48ea..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise3d_fa_color4(float amplitude, float pivot, vector position, output color4 result)
-{
- color4 value = mx_noise("snoise", position);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl
deleted file mode 100644
index 9317d893..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise3d_fa_vector2(float amplitude, float pivot, vector position, output vector2 result)
-{
- vector2 value = mx_noise("snoise", position);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl
deleted file mode 100644
index 4e235feb..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise3d_fa_vector3(float amplitude, float pivot, vector position, output vector result)
-{
- vector value = noise("snoise", position);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl
deleted file mode 100644
index 177fc3f2..00000000
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl
+++ /dev/null
@@ -1,5 +0,0 @@
-void mx_noise3d_fa_vector4(float amplitude, float pivot, vector position, output vector4 result)
-{
- vector4 value = mx_noise("snoise", position);
- result = value * amplitude + pivot;
-}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/mx_normalmap.osl b/Sources/MXResources/libraries/stdlib/genosl/mx_normalmap.osl
index a1f276fa..79b31df6 100644
--- a/Sources/MXResources/libraries/stdlib/genosl/mx_normalmap.osl
+++ b/Sources/MXResources/libraries/stdlib/genosl/mx_normalmap.osl
@@ -1,4 +1,4 @@
-void mx_normalmap(vector value, string map_space, float normal_scale, vector N, vector U, output vector result)
+void mx_normalmap_vector2(vector value, string map_space, vector2 normal_scale, vector N, vector U, output vector result)
{
// Tangent space
if (map_space == "tangent")
@@ -6,7 +6,7 @@ void mx_normalmap(vector value, string map_space, float normal_scale, vector N,
vector v = value * 2.0 - 1.0;
vector T = normalize(U - dot(U, N) * N);
vector B = normalize(cross(N, T));
- result = normalize(T * v[0] * normal_scale + B * v[1] * normal_scale + N * v[2]);
+ result = normalize(T * v[0] * normal_scale.x + B * v[1] * normal_scale.y + N * v[2]);
}
// Object space
else
@@ -15,3 +15,8 @@ void mx_normalmap(vector value, string map_space, float normal_scale, vector N,
result = normalize(n);
}
}
+
+void mx_normalmap_float(vector value, string map_space, float normal_scale, vector N, vector U, output vector result)
+{
+ mx_normalmap_vector2(value, map_space, vector2(normal_scale, normal_scale), N, U, result);
+}
diff --git a/Sources/MXResources/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx b/Sources/MXResources/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
index 42828ce6..c916eb30 100644
--- a/Sources/MXResources/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
+++ b/Sources/MXResources/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
@@ -44,7 +44,8 @@
-
+
+
@@ -98,42 +99,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -324,6 +304,15 @@
+
+
+
+
+
+
+
+
+
@@ -498,16 +487,9 @@
-
-
-
-
-
-
-
@@ -751,6 +733,11 @@
+
+
+
+
+
diff --git a/Sources/MXResources/libraries/stdlib/stdlib_defs.mtlx b/Sources/MXResources/libraries/stdlib/stdlib_defs.mtlx
index 3f187e2b..7433b0a2 100644
--- a/Sources/MXResources/libraries/stdlib/stdlib_defs.mtlx
+++ b/Sources/MXResources/libraries/stdlib/stdlib_defs.mtlx
@@ -1914,6 +1914,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -4359,6 +4483,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -196,7 +196,7 @@
@@ -1309,6 +1309,200 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1576,7 +1770,7 @@
@@ -1669,7 +1863,7 @@
-
+
@@ -2361,11 +2555,14 @@
-
+
+
@@ -2479,7 +2676,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+