From 2a61e63f445fc547b56d479141b10191e4eb31e1 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Fri, 18 Oct 2024 17:27:04 -0700 Subject: [PATCH 1/9] CMake updates for Apple builds (#2077) - Mark the CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY flag as Apple-specific, removing it from CMake interfaces on other platforms. - Simplify comment blocks to highlight key points. - Reorder the order of option declarations for clarity. --- CMakeLists.txt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59afaca01e..31db83e8fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,25 +60,21 @@ option(MATERIALX_DYNAMIC_ANALYSIS "Build MaterialX libraries with dynamic analys option(MATERIALX_OSL_LEGACY_CLOSURES "Build OSL shader generation supporting the legacy OSL closures." OFF) option(MATERIALX_BUILD_IOS "Build MaterialX for iOS. (Deprecated. Set CMAKE_SYSTEM_NAME instead)" OFF) -set(MATERIALX_BUILD_APPLE_EMBEDDED OFF) +option(MATERIALX_BUILD_APPLE_FRAMEWORK "Build MaterialX as an Apple Framework" ${__build_apple_framework}) if (MATERIALX_BUILD_IOS) MESSAGE(WARNING "The MATERIALX_BUILD_IOS is deprecated. Set the CMAKE_SYSTEM_NAME to the platform instead") set(CMAKE_SYSTEM_NAME iOS) endif() -# Cross Compilation detection as defined in CMake docs +# Apple ecosystem cross-compilation # https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-visionos-or-watchos -# Note: All these SDKs may not be supported by MaterialX +set(MATERIALX_BUILD_APPLE_EMBEDDED OFF) set(__build_apple_framework OFF) -if (CMAKE_SYSTEM_NAME MATCHES "iOS" - OR CMAKE_SYSTEM_NAME MATCHES "tvOS" - OR CMAKE_SYSTEM_NAME MATCHES "visionOS" - OR CMAKE_SYSTEM_NAME MATCHES "watchOS") +if (CMAKE_SYSTEM_NAME MATCHES "iOS" OR CMAKE_SYSTEM_NAME MATCHES "tvOS" OR CMAKE_SYSTEM_NAME MATCHES "visionOS" OR CMAKE_SYSTEM_NAME MATCHES "watchOS") set(MATERIALX_BUILD_APPLE_EMBEDDED ON) set(__build_apple_framework ${MATERIALX_BUILD_SHARED_LIBS}) # TARGET_OS_IPHONE refers to all IPHONE derived platforms # https://chaosinmotion.com/2021/08/02/things-to-remember-compiler-conditionals-for-macos-ios-etc/ - # This should be auto-defined, but leaving it in here because it was historically defined add_definitions(-DTARGET_OS_IPHONE=1) set(MATERIALX_BUILD_MONOLITHIC ON) set(MATERIALX_BUILD_PYTHON OFF) @@ -90,8 +86,10 @@ if (CMAKE_SYSTEM_NAME MATCHES "iOS" set(MATERIALX_BUILD_TESTS OFF) endif() -set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-" CACHE STRING "The Codesigning identity needed to sign compiled objects") -option(MATERIALX_BUILD_APPLE_FRAMEWORK "Build MaterialX as an Apple Framework" ${__build_apple_framework}) +# Apple framework handling +if(APPLE) + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-" CACHE STRING "The Codesigning identity needed to sign compiled objects") +endif() if (MATERIALX_BUILD_APPLE_FRAMEWORK) add_definitions(-DBUILD_APPLE_FRAMEWORK) set(MATERIALX_BUILD_MONOLITHIC ON) From 4cb8ef9ed38975dfc01656493b66b62ef63a715d Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Fri, 18 Oct 2024 21:05:18 -0700 Subject: [PATCH 2/9] Simplify material test suite (#2078) - Split adjustment.mtlx into separate documents for each node. - Remove test materials for nodes with graph definitions. --- .../stdlib/adjustment/adjustment.mtlx | 383 ------------------ .../stdlib/adjustment/luminance.mtlx | 15 + .../TestSuite/stdlib/adjustment/remap.mtlx | 113 ++++++ .../TestSuite/stdlib/channel/channel.mtlx | 56 --- .../conditional/conditional_switch.mtlx | 199 --------- .../TestSuite/stdlib/convert/convert.mtlx | 30 -- 6 files changed, 128 insertions(+), 668 deletions(-) delete mode 100644 resources/Materials/TestSuite/stdlib/adjustment/adjustment.mtlx create mode 100644 resources/Materials/TestSuite/stdlib/adjustment/luminance.mtlx create mode 100644 resources/Materials/TestSuite/stdlib/adjustment/remap.mtlx delete mode 100644 resources/Materials/TestSuite/stdlib/conditional/conditional_switch.mtlx delete mode 100644 resources/Materials/TestSuite/stdlib/convert/convert.mtlx diff --git a/resources/Materials/TestSuite/stdlib/adjustment/adjustment.mtlx b/resources/Materials/TestSuite/stdlib/adjustment/adjustment.mtlx deleted file mode 100644 index 83c4b95e9b..0000000000 --- a/resources/Materials/TestSuite/stdlib/adjustment/adjustment.mtlx +++ /dev/null @@ -1,383 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/Materials/TestSuite/stdlib/adjustment/luminance.mtlx b/resources/Materials/TestSuite/stdlib/adjustment/luminance.mtlx new file mode 100644 index 0000000000..6260df8c57 --- /dev/null +++ b/resources/Materials/TestSuite/stdlib/adjustment/luminance.mtlx @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/resources/Materials/TestSuite/stdlib/adjustment/remap.mtlx b/resources/Materials/TestSuite/stdlib/adjustment/remap.mtlx new file mode 100644 index 0000000000..9175411a5d --- /dev/null +++ b/resources/Materials/TestSuite/stdlib/adjustment/remap.mtlx @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/Materials/TestSuite/stdlib/channel/channel.mtlx b/resources/Materials/TestSuite/stdlib/channel/channel.mtlx index 59dbd160eb..57e90acf45 100644 --- a/resources/Materials/TestSuite/stdlib/channel/channel.mtlx +++ b/resources/Materials/TestSuite/stdlib/channel/channel.mtlx @@ -97,60 +97,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/Materials/TestSuite/stdlib/conditional/conditional_switch.mtlx b/resources/Materials/TestSuite/stdlib/conditional/conditional_switch.mtlx deleted file mode 100644 index 38f36a7290..0000000000 --- a/resources/Materials/TestSuite/stdlib/conditional/conditional_switch.mtlx +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/Materials/TestSuite/stdlib/convert/convert.mtlx b/resources/Materials/TestSuite/stdlib/convert/convert.mtlx deleted file mode 100644 index f29b1eaab4..0000000000 --- a/resources/Materials/TestSuite/stdlib/convert/convert.mtlx +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From bec073ba952dcd1ca79279ebc7e2698cbd0a94c3 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Sat, 19 Oct 2024 11:54:31 -0700 Subject: [PATCH 3/9] Additional refinements to GLSL and MSL (#2079) - Provide mx_mod and mx_inverse in both GLSL and MSL. - Remove a legacy preprocessor definition in MSL. --- libraries/stdlib/genglsl/lib/mx_math.glsl | 2 ++ .../stdlib/genglsl/stdlib_genglsl_impl.mtlx | 26 +++++++++---------- .../stdlib/genmsl/stdlib_genmsl_impl.mtlx | 17 ------------ source/MaterialXGenMsl/MslShaderGenerator.cpp | 1 - 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/libraries/stdlib/genglsl/lib/mx_math.glsl b/libraries/stdlib/genglsl/lib/mx_math.glsl index f87e5653da..d196615e70 100644 --- a/libraries/stdlib/genglsl/lib/mx_math.glsl +++ b/libraries/stdlib/genglsl/lib/mx_math.glsl @@ -1,5 +1,7 @@ #define M_FLOAT_EPS 1e-8 +#define mx_mod mod +#define mx_inverse inverse #define mx_inversesqrt inversesqrt #define mx_sin sin #define mx_cos cos diff --git a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx index 765c48c77b..69f8f9a7f8 100644 --- a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx +++ b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx @@ -252,17 +252,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -458,8 +458,8 @@ - - + + diff --git a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx index 1920d04b70..afdfb2cfbb 100644 --- a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx +++ b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx @@ -100,19 +100,6 @@ - - - - - - - - - - - - - @@ -122,10 +109,6 @@ - - - - diff --git a/source/MaterialXGenMsl/MslShaderGenerator.cpp b/source/MaterialXGenMsl/MslShaderGenerator.cpp index 5476b33c90..9511fac7ba 100644 --- a/source/MaterialXGenMsl/MslShaderGenerator.cpp +++ b/source/MaterialXGenMsl/MslShaderGenerator.cpp @@ -944,7 +944,6 @@ void MslShaderGenerator::emitPixelStage(const ShaderGraph& graph, GenContext& co emitLine("{}", stage, false); // Add common math functions - emitLine("#define __DECL_GL_MATH_FUNCTIONS__", stage, false); emitLibraryInclude("stdlib/genmsl/lib/mx_math.metal", context, stage); emitLineBreak(stage); From f6355a66b635d11d20e75d0f2705fba728fb38ad Mon Sep 17 00:00:00 2001 From: Jonathan Feldstein Date: Sat, 19 Oct 2024 14:57:43 -0400 Subject: [PATCH 4/9] Add defaultgeomprop support for nodegraph inputs (#2076) This PR makes it so that defaultgeomprop values can be used with nodegraph inputs as opposed to solely used on nodedef inputs. Includes a test file that is a nodegraph version of a checkerboard nodegraph implementation. The nodegraph exposes a defaultgeomprop value on the nodegraph's texcoord input of "UV0". --- .../defaultgeomprop/defaultgeomprop.mtlx | 41 +++++++++++++++++++ source/MaterialXCore/Interface.cpp | 2 +- source/MaterialXGenShader/ShaderGraph.cpp | 18 +++++++- 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 resources/Materials/TestSuite/stdlib/defaultgeomprop/defaultgeomprop.mtlx diff --git a/resources/Materials/TestSuite/stdlib/defaultgeomprop/defaultgeomprop.mtlx b/resources/Materials/TestSuite/stdlib/defaultgeomprop/defaultgeomprop.mtlx new file mode 100644 index 0000000000..86bddc9650 --- /dev/null +++ b/resources/Materials/TestSuite/stdlib/defaultgeomprop/defaultgeomprop.mtlx @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/MaterialXCore/Interface.cpp b/source/MaterialXCore/Interface.cpp index 24d3ccfe0d..1c12e38ded 100644 --- a/source/MaterialXCore/Interface.cpp +++ b/source/MaterialXCore/Interface.cpp @@ -295,7 +295,7 @@ bool Input::validate(string* message) const if (hasDefaultGeomPropString()) { - validateRequire(parent->isA(), res, message, "Invalid defaultgeomprop on non-definition input"); + validateRequire(parent->isA() || parent->isA(), res, message, "Invalid defaultgeomprop on non-definition and non-nodegraph input"); validateRequire(getDefaultGeomProp() != nullptr, res, message, "Invalid defaultgeomprop string"); } if (parent->isA()) diff --git a/source/MaterialXGenShader/ShaderGraph.cpp b/source/MaterialXGenShader/ShaderGraph.cpp index 0f39b46c32..e9a3b50b79 100644 --- a/source/MaterialXGenShader/ShaderGraph.cpp +++ b/source/MaterialXGenShader/ShaderGraph.cpp @@ -81,7 +81,7 @@ void ShaderGraph::createConnectedNodes(const ElementPtr& downstreamElement, ElementPtr connectingElement, GenContext& context) { - // Create the node if it doesn't exists + // Create the node if it doesn't exist. NodePtr upstreamNode = upstreamElement->asA(); if (!upstreamNode) { @@ -95,6 +95,22 @@ void ShaderGraph::createConnectedNodes(const ElementPtr& downstreamElement, newNode = createNode(upstreamNode, context); } + // Handle interface inputs with default geometric properties. + for (InputPtr activeInput : upstreamNode->getActiveInputs()) + { + if (!activeInput->hasInterfaceName() || activeInput->getConnectedNode()) + { + continue; + } + + InputPtr graphInput = activeInput->getInterfaceInput(); + if (graphInput && graphInput->hasDefaultGeomPropString()) + { + ShaderInput* shaderInput = getNode(upstreamNode->getName())->getInput(activeInput->getName()); + addDefaultGeomNode(shaderInput, *graphInput->getDefaultGeomProp(), context); + } + } + // // Make connections // From a578d8a9758f0a6eefc5a1a5c7ab10727ee11b2d Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Sun, 20 Oct 2024 12:31:54 -0700 Subject: [PATCH 5/9] Simplify material test suite (#2080) - Split channel.mtlx into separate documents for each node. - Remove test materials for nodes with graph definitions. - Reduce coupling of unit tests with material examples. --- libraries/stdlib/stdlib_ng.mtlx | 1 - .../channel/{channel.mtlx => combine.mtlx} | 35 ----------------- .../TestSuite/stdlib/channel/extract.mtlx | 38 +++++++++++++++++++ .../stdlib/compositing/compositing.mtlx | 25 ------------ .../{tokenGraph.mtlx => token_graph.mtlx} | 0 source/MaterialXTest/MaterialXCore/Node.cpp | 37 ------------------ 6 files changed, 38 insertions(+), 98 deletions(-) rename resources/Materials/TestSuite/stdlib/channel/{channel.mtlx => combine.mtlx} (65%) create mode 100644 resources/Materials/TestSuite/stdlib/channel/extract.mtlx rename resources/Materials/TestSuite/stdlib/texture/{tokenGraph.mtlx => token_graph.mtlx} (100%) diff --git a/libraries/stdlib/stdlib_ng.mtlx b/libraries/stdlib/stdlib_ng.mtlx index 893e084b68..ef7f5ebc90 100644 --- a/libraries/stdlib/stdlib_ng.mtlx +++ b/libraries/stdlib/stdlib_ng.mtlx @@ -4386,7 +4386,6 @@ - diff --git a/resources/Materials/TestSuite/stdlib/channel/channel.mtlx b/resources/Materials/TestSuite/stdlib/channel/combine.mtlx similarity index 65% rename from resources/Materials/TestSuite/stdlib/channel/channel.mtlx rename to resources/Materials/TestSuite/stdlib/channel/combine.mtlx index 57e90acf45..403b344226 100644 --- a/resources/Materials/TestSuite/stdlib/channel/channel.mtlx +++ b/resources/Materials/TestSuite/stdlib/channel/combine.mtlx @@ -62,39 +62,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/Materials/TestSuite/stdlib/channel/extract.mtlx b/resources/Materials/TestSuite/stdlib/channel/extract.mtlx new file mode 100644 index 0000000000..467707a47f --- /dev/null +++ b/resources/Materials/TestSuite/stdlib/channel/extract.mtlx @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/Materials/TestSuite/stdlib/compositing/compositing.mtlx b/resources/Materials/TestSuite/stdlib/compositing/compositing.mtlx index 4a2d032be6..b60b9803a9 100644 --- a/resources/Materials/TestSuite/stdlib/compositing/compositing.mtlx +++ b/resources/Materials/TestSuite/stdlib/compositing/compositing.mtlx @@ -8,7 +8,6 @@ - burn - dodge - screen - - overlay - disjointover - mask - matte @@ -181,30 +180,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/Materials/TestSuite/stdlib/texture/tokenGraph.mtlx b/resources/Materials/TestSuite/stdlib/texture/token_graph.mtlx similarity index 100% rename from resources/Materials/TestSuite/stdlib/texture/tokenGraph.mtlx rename to resources/Materials/TestSuite/stdlib/texture/token_graph.mtlx diff --git a/source/MaterialXTest/MaterialXCore/Node.cpp b/source/MaterialXTest/MaterialXCore/Node.cpp index 58ee125bad..ef746bfe05 100644 --- a/source/MaterialXTest/MaterialXCore/Node.cpp +++ b/source/MaterialXTest/MaterialXCore/Node.cpp @@ -627,43 +627,6 @@ TEST_CASE("Organization", "[nodegraph]") CHECK(nodeGraph->getBackdrops().empty()); } -TEST_CASE("Tokens", "[nodegraph]") -{ - mx::FileSearchPath searchPath = mx::getDefaultDataSearchPath(); - mx::DocumentPtr stdlib = mx::createDocument(); - mx::loadLibraries({ "libraries" }, searchPath, stdlib); - - mx::DocumentPtr doc = mx::createDocument(); - mx::readFromXmlFile(doc, "resources/Materials/TestSuite/stdlib/texture/tokenGraph.mtlx", searchPath); - - mx::StringVec graphNames = { "Tokenized_Image_2k_png", "Tokenized_Image_4k_jpg" }; - mx::StringVec resolutionStrings = { "2k", "4k" }; - mx::StringVec extensionStrings = { "png", "jpg" }; - for (size_t i=0; igetNodeGraph(graphNames[i]); - REQUIRE(graph); - std::vector tokens = graph->getActiveTokens(); - - mx::NodePtr imagePtr = graph->getNode("tiledimage"); - REQUIRE(imagePtr); - - mx::InputPtr input = imagePtr->getInput("file"); - REQUIRE(input); - - // Test file name substitution creation. - mx::StringResolverPtr resolver = input->createStringResolver(); - const mx::StringMap& substitutions = resolver->getFilenameSubstitutions(); - const std::string DELIMITER_PREFIX("["); - const std::string DELIMITER_POSTFIX("]"); - for (auto token : tokens) - { - const std::string tokenString = DELIMITER_PREFIX + token->getName() + DELIMITER_POSTFIX; - REQUIRE(substitutions.count(tokenString)); - } - } -} - TEST_CASE("Node Definition Creation", "[nodedef]") { mx::FileSearchPath searchPath = mx::getDefaultDataSearchPath(); From 5d6aa6ec30a7966fae51dc75c6b37d0656300a71 Mon Sep 17 00:00:00 2001 From: Karen Lucknavalai <34335343+klucknav@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:12:08 -0700 Subject: [PATCH 6/9] Update UsdPreviewSurface Nodegraph This PR fixes the cutout issue described in gitIssue #2044. It also updates the nodegraph to reflect the recently updated PreviewSurface v2.6 which removes specular highlights for fully transparent materials. --- libraries/bxdf/usd_preview_surface.mtlx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/libraries/bxdf/usd_preview_surface.mtlx b/libraries/bxdf/usd_preview_surface.mtlx index 7106da779b..d99fab3a8c 100644 --- a/libraries/bxdf/usd_preview_surface.mtlx +++ b/libraries/bxdf/usd_preview_surface.mtlx @@ -6,7 +6,7 @@ - + @@ -152,10 +152,16 @@ + + + + + + - + @@ -170,8 +176,12 @@ + + + + - + @@ -213,8 +223,12 @@ + + + + - + From 5cdb375e81d172048bf881d35d8b22a6c1af5049 Mon Sep 17 00:00:00 2001 From: Masuo Suzuki <153872239+msuzuki-nvidia@users.noreply.github.com> Date: Wed, 23 Oct 2024 18:58:43 -0700 Subject: [PATCH 7/9] Fix hair nodes in MDL backend (#2085) Fix the issue where the generated MDL code with hair nodes does not compile. Also address warnings for unused parameters. --- libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx | 2 +- .../SimpleHair/simple_hair_default.mtlx | 1 + .../mdl/materialx/pbrlib_1_6.mdl | 17 +++++++++-------- .../mdl/materialx/pbrlib_1_7.mdl | 5 +++++ .../mdl/materialx/stdlib_1_6.mdl | 1 + 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx b/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx index 0737ca82ab..c8f23958ae 100644 --- a/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx +++ b/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx @@ -26,7 +26,7 @@ - + diff --git a/resources/Materials/Examples/SimpleHair/simple_hair_default.mtlx b/resources/Materials/Examples/SimpleHair/simple_hair_default.mtlx index 056c79b554..b3dbd80f9a 100644 --- a/resources/Materials/Examples/SimpleHair/simple_hair_default.mtlx +++ b/resources/Materials/Examples/SimpleHair/simple_hair_default.mtlx @@ -45,6 +45,7 @@ + diff --git a/source/MaterialXGenMdl/mdl/materialx/pbrlib_1_6.mdl b/source/MaterialXGenMdl/mdl/materialx/pbrlib_1_6.mdl index b69d59e8b0..e70f849920 100644 --- a/source/MaterialXGenMdl/mdl/materialx/pbrlib_1_6.mdl +++ b/source/MaterialXGenMdl/mdl/materialx/pbrlib_1_6.mdl @@ -430,9 +430,9 @@ export material mx_thin_film_bsdf( export material mx_chiang_hair_bsdf( // TODO: MDL's chiang_hair BSDF has no support tinting each lobes - color mxp_tint_R = color(1.0), - color mxp_tint_TT = color(1.0), - color mxp_tint_TRT = color(1.0), + color mxp_tint_R = color(1.0) [[ anno::unused() ]], + color mxp_tint_TT = color(1.0) [[ anno::unused() ]], + color mxp_tint_TRT = color(1.0) [[ anno::unused() ]], float mxp_ior = 1.55, float2 mxp_roughness_R = float2(0.1, 0.1), float2 mxp_roughness_TT = float2(0.05, 0.05), @@ -452,7 +452,7 @@ export material mx_chiang_hair_bsdf( roughness_TT: mxp_roughness_TT, roughness_TRT: mxp_roughness_TRT, cuticle_angle: mxp_cuticle_angle, - absorption_coefficient: mxp_absorption_coefficient, + absorption_coefficient: color(mxp_absorption_coefficient), ior: mxp_ior ) ); @@ -590,6 +590,7 @@ export material mx_surface( scattering: bsdf_node, emission: edf_node ), + hair: mxp_bsdf.hair, ior: mxp_transmission_ior > 0.0 ? color(mxp_transmission_ior) : mxp_bsdf.ior, volume: bsdf_volume, geometry: material_geometry( @@ -1010,17 +1011,17 @@ export mx_artistic_ior__result mx_artistic_ior( return mx_artistic_ior__result(n,k); } -export float3 mx_dion_hair_absorption_from_melanin( +export float3 mx_deon_hair_absorption_from_melanin( float mxp_melanin_concentration = 0.25, float mxp_melanin_redness = 0.5, color mxp_eumelanin_color = color(0.657704, 0.498077, 0.254107), color mxp_pheomelanin_color = color(0.829444, 0.67032, 0.349938) ) { float melanin = -math::log(math::max(1.0 - mxp_melanin_concentration, 0.0001)); - float eumelanin = melanin * (1.0 = mxp_melanin_redness); + float eumelanin = melanin * (1.0 - mxp_melanin_redness); float pheomelanin = melanin * mxp_melanin_redness; return math::max( - eumelanin * -math::log(mxp_eumelanin_color) + pheomelanin * -math::log(mxp_pheomelanin_color), + eumelanin * -math::log(float3(mxp_eumelanin_color)) + pheomelanin * -math::log(float3(mxp_pheomelanin_color)), float3(0.0) ); } @@ -1038,7 +1039,7 @@ export float3 mx_chiang_hair_absorption_from_color( (10.73 * r2 * mxp_azimuthal_roughness) + (5.574 * r4) + (0.245 * r4 * mxp_azimuthal_roughness); - float3 sigma = math::log(math::min(math::max(mxp_color, 0.001), float3(1.0))) / r_fac; + float3 sigma = math::log(math::min(math::max(float3(mxp_color), 0.001), float3(1.0))) / r_fac; return (sigma * sigma); } diff --git a/source/MaterialXGenMdl/mdl/materialx/pbrlib_1_7.mdl b/source/MaterialXGenMdl/mdl/materialx/pbrlib_1_7.mdl index 2d288ee8f2..bea4e59bf6 100644 --- a/source/MaterialXGenMdl/mdl/materialx/pbrlib_1_7.mdl +++ b/source/MaterialXGenMdl/mdl/materialx/pbrlib_1_7.mdl @@ -48,6 +48,7 @@ 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_chiang_hair_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; @@ -72,6 +73,10 @@ 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; +export using .::pbrlib_1_6 import mx_deon_hair_absorption_from_melanin; +export using .::pbrlib_1_6 import mx_chiang_hair_absorption_from_color; +export using .::pbrlib_1_6 import mx_chiang_hair_roughness__result; +export using .::pbrlib_1_6 import mx_chiang_hair_roughness; diff --git a/source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl b/source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl index f5d661b17e..3815d892a0 100644 --- a/source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl +++ b/source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl @@ -42,6 +42,7 @@ export material mx_surfacematerial( = material( thin_walled: mxp_surfaceshader.thin_walled || mxp_backsurfaceshader.thin_walled, surface: mxp_surfaceshader.surface, + hair: mxp_surfaceshader.hair, backface: mxp_backsurfaceshader.surface, geometry: material_geometry( cutout_opacity: mxp_surfaceshader.geometry.cutout_opacity, From 1734e6dd9d132ddc9abcdd3a095ccf9f37e8fcc5 Mon Sep 17 00:00:00 2001 From: Rui Yang Date: Wed, 23 Oct 2024 19:25:39 -0700 Subject: [PATCH 8/9] Add a combined version define in MaterialX C++ (#2031) PR for https://github.com/AcademySoftwareFoundation/MaterialX/issues/1609 Also added a simple test in source/MaterialXTest/MaterialXCore --- source/MaterialXCore/Library.h | 5 +++++ source/MaterialXTest/MaterialXCore/CoreUtil.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/source/MaterialXCore/Library.h b/source/MaterialXCore/Library.h index 1a92c634a7..571644c098 100644 --- a/source/MaterialXCore/Library.h +++ b/source/MaterialXCore/Library.h @@ -21,6 +21,11 @@ #include +#define MATERIALX_GENERATE_INDEX(major, minor, build) \ + ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(build))) +#define MATERIALX_VERSION_INDEX \ + MATERIALX_GENERATE_INDEX(MATERIALX_MAJOR_VERSION, MATERIALX_MINOR_VERSION, MATERIALX_BUILD_VERSION) + /// Platform-specific macros for declaring imported and exported symbols. #if defined(MATERIALX_BUILD_SHARED_LIBS) #if defined(_WIN32) diff --git a/source/MaterialXTest/MaterialXCore/CoreUtil.cpp b/source/MaterialXTest/MaterialXCore/CoreUtil.cpp index 11aa826d4f..4bc174a690 100644 --- a/source/MaterialXTest/MaterialXCore/CoreUtil.cpp +++ b/source/MaterialXTest/MaterialXCore/CoreUtil.cpp @@ -10,6 +10,12 @@ namespace mx = MaterialX; +TEST_CASE("Version comparison", "[coreutil]") +{ + // Test for version comparison + REQUIRE(MATERIALX_VERSION_INDEX > MATERIALX_GENERATE_INDEX(1, 38, 8)); +} + TEST_CASE("String utilities", "[coreutil]") { std::string invalidName("test.name"); From 593e175f3f17ccd00337cad29682d321643babaa Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Mon, 28 Oct 2024 17:14:33 -0700 Subject: [PATCH 9/9] Restore specular terms of UsdPreviewSurface (#2088) This changelist restores the interpretation of the reflective and transmissive specular terms of UsdPreviewSurface, reverting some unintended changes in PR #2081. --- libraries/bxdf/usd_preview_surface.mtlx | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/libraries/bxdf/usd_preview_surface.mtlx b/libraries/bxdf/usd_preview_surface.mtlx index d99fab3a8c..a521c756bc 100644 --- a/libraries/bxdf/usd_preview_surface.mtlx +++ b/libraries/bxdf/usd_preview_surface.mtlx @@ -152,16 +152,10 @@ - - - - - - - + @@ -176,12 +170,8 @@ - - - - - + @@ -223,12 +213,8 @@ - - - - - +