From 81ed31d43026cc0e475bbdf9b040ccbc17ba60bc Mon Sep 17 00:00:00 2001 From: Chris Rydalch Date: Fri, 13 Dec 2024 21:52:58 -0600 Subject: [PATCH] Add support for geompropvalueuniform node (#2092) Adds a string-/filename-friendly primvar/geompropvalue node, as was proposed for 1.39. --- .../Specification/MaterialX.Proposals.md | 6 ----- .../Specification/MaterialX.Specification.md | 6 +++++ libraries/bxdf/usd_preview_surface.mtlx | 22 ++++++++++++++----- .../stdlib/genglsl/stdlib_genglsl_impl.mtlx | 5 ++++- .../stdlib/genmdl/stdlib_genmdl_impl.mtlx | 5 ++++- .../stdlib/genmsl/stdlib_genmsl_impl.mtlx | 5 ++++- .../stdlib/genosl/stdlib_genosl_impl.mtlx | 5 ++++- libraries/stdlib/stdlib_defs.mtlx | 21 +++++++++++++----- .../stdlib/geometric/geompropvalue.mtlx | 8 +++---- .../MaterialXGenGlsl/GlslShaderGenerator.cpp | 1 + source/MaterialXGenMsl/MslShaderGenerator.cpp | 2 ++ .../MaterialXTest/MaterialXGenGlsl/GenGlsl.h | 2 +- source/MaterialXTest/MaterialXGenMsl/GenMsl.h | 2 +- source/MaterialXTest/MaterialXGenOsl/GenOsl.h | 2 +- 14 files changed, 65 insertions(+), 27 deletions(-) diff --git a/documents/Specification/MaterialX.Proposals.md b/documents/Specification/MaterialX.Proposals.md index d387d28718..1aaa930923 100644 --- a/documents/Specification/MaterialX.Proposals.md +++ b/documents/Specification/MaterialX.Proposals.md @@ -219,12 +219,6 @@ In #1201 it was decided that separate periodic versions of all of the noises is * **`bump`**: Existing node, proposal to add a vector3 `bitangent` input - - -* **`geompropvalueuniform`**: the value of the specified uniform geometric property (defined using <geompropdef>) of the currently-bound geometry. This node's type must match that of the referenced geomprop. - * `geomprop` (uniform string): the geometric property to be referenced. - * `default` (same type as the geomprop's value): a value to return if the specified `geomprop` is not defined on the current geometry. - Note: when <geompropvalueuniform> is added, the text in the first paragraph of the Specification about Node Inputs should be revised to include "<geompropvalueuniform>" as an example of "or any other node whose output is explicitly declared to be uniform". diff --git a/documents/Specification/MaterialX.Specification.md b/documents/Specification/MaterialX.Specification.md index 65027694d8..4ad29dc963 100644 --- a/documents/Specification/MaterialX.Specification.md +++ b/documents/Specification/MaterialX.Specification.md @@ -1091,6 +1091,12 @@ Standard Geometric nodes: * `geomprop` (uniform string): the geometric property to be referenced. * `default` (same type as the geomprop's value): a value to return if the specified `geomprop` is not defined on the current geometry. + + +* **`geompropvalueuniform`**: the value of the specified uniform geometric property (defined using <geompropdef>) of the currently-bound geometry. This node's type must match that of the referenced geomprop. + * `geomprop` (uniform string): the geometric property to be referenced. + * `default` (same type as the geomprop's value): a value to return if the specified `geomprop` is not defined on the current geometry. + Additionally, the `geomcolor` and `geompropvalue` nodes for color3/color4-type properties can take a `colorspace` attribute to declare what colorspace the color property value is in; the default is "none" for no colorspace declaration (and hence no colorspace conversion). diff --git a/libraries/bxdf/usd_preview_surface.mtlx b/libraries/bxdf/usd_preview_surface.mtlx index 4abdb91d9f..afc6954af9 100644 --- a/libraries/bxdf/usd_preview_surface.mtlx +++ b/libraries/bxdf/usd_preview_surface.mtlx @@ -62,8 +62,13 @@ - - + + + + + + + @@ -359,11 +364,18 @@ - + - - + + + + + + + + + diff --git a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx index ad3a21e9cf..0625d17a25 100644 --- a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx +++ b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx @@ -157,7 +157,6 @@ - @@ -165,6 +164,10 @@ + + + + diff --git a/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx b/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx index 6ac2b862dd..05dbc995d6 100644 --- a/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx +++ b/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx @@ -159,7 +159,6 @@ - @@ -167,6 +166,10 @@ + + + + diff --git a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx index 3cb99052cf..ea09880543 100644 --- a/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx +++ b/libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx @@ -73,7 +73,6 @@ - @@ -81,6 +80,10 @@ + + + + diff --git a/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx b/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx index db318976c5..bd2e2540b5 100644 --- a/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx +++ b/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx @@ -159,7 +159,6 @@ - @@ -167,6 +166,10 @@ + + + + diff --git a/libraries/stdlib/stdlib_defs.mtlx b/libraries/stdlib/stdlib_defs.mtlx index 8f86a03b44..7e6be9b050 100644 --- a/libraries/stdlib/stdlib_defs.mtlx +++ b/libraries/stdlib/stdlib_defs.mtlx @@ -1355,11 +1355,6 @@ - - - - - @@ -1391,6 +1386,22 @@ + + + + + + + + + + + + + registerImplementation("IM_frame_float_" + GlslShaderGenerator::TARGET, HwFrameNode::create); diff --git a/source/MaterialXGenMsl/MslShaderGenerator.cpp b/source/MaterialXGenMsl/MslShaderGenerator.cpp index 9511fac7ba..d886d43e96 100644 --- a/source/MaterialXGenMsl/MslShaderGenerator.cpp +++ b/source/MaterialXGenMsl/MslShaderGenerator.cpp @@ -86,6 +86,8 @@ MslShaderGenerator::MslShaderGenerator() : registerImplementation(elementNames, GeomPropValueNodeMsl::create); registerImplementation("IM_geompropvalue_boolean_" + MslShaderGenerator::TARGET, GeomPropValueNodeMslAsUniform::create); registerImplementation("IM_geompropvalue_string_" + MslShaderGenerator::TARGET, GeomPropValueNodeMslAsUniform::create); + registerImplementation("IM_geompropvalue_filename_" + MslShaderGenerator::TARGET, GeomPropValueNodeMslAsUniform::create); + // registerImplementation("IM_frame_float_" + MslShaderGenerator::TARGET, HwFrameNode::create); diff --git a/source/MaterialXTest/MaterialXGenGlsl/GenGlsl.h b/source/MaterialXTest/MaterialXGenGlsl/GenGlsl.h index 8d3e8c8720..9db87197f1 100644 --- a/source/MaterialXTest/MaterialXGenGlsl/GenGlsl.h +++ b/source/MaterialXTest/MaterialXGenGlsl/GenGlsl.h @@ -52,7 +52,7 @@ class GlslShaderGeneratorTester : public GenShaderUtil::ShaderGeneratorTester whiteList = { "volumeshader", "volumematerial", - "IM_constant_", "IM_dot_", "IM_angle", "IM_geompropvalue_boolean", "IM_geompropvalue_string", + "IM_constant_", "IM_dot_", "IM_angle", "IM_geompropvalue_boolean", "IM_geompropvalue_string", "IM_geompropvalue_filename", "IM_light_", "IM_point_light_", "IM_spot_light_", "IM_directional_light_" }; ShaderGeneratorTester::getImplementationWhiteList(whiteList); diff --git a/source/MaterialXTest/MaterialXGenMsl/GenMsl.h b/source/MaterialXTest/MaterialXGenMsl/GenMsl.h index eea7b86acb..c159919773 100644 --- a/source/MaterialXTest/MaterialXGenMsl/GenMsl.h +++ b/source/MaterialXTest/MaterialXGenMsl/GenMsl.h @@ -71,7 +71,7 @@ class MslShaderGeneratorTester : public GenShaderUtil::ShaderGeneratorTester whiteList = { "displacementshader", "volumeshader", "surfacematerial", "volumematerial", - "IM_constant_", "IM_dot_", "IM_angle", "IM_geompropvalue_boolean", "IM_geompropvalue_string", + "IM_constant_", "IM_dot_", "IM_angle", "IM_geompropvalue_boolean", "IM_geompropvalue_string", "IM_geompropvalue_filename", "IM_light_", "IM_point_light_", "IM_spot_light_", "IM_directional_light_", "ND_surfacematerial", "ND_volumematerial" }; diff --git a/source/MaterialXTest/MaterialXGenOsl/GenOsl.h b/source/MaterialXTest/MaterialXGenOsl/GenOsl.h index aa84a62218..d36c571a82 100644 --- a/source/MaterialXTest/MaterialXGenOsl/GenOsl.h +++ b/source/MaterialXTest/MaterialXGenOsl/GenOsl.h @@ -64,7 +64,7 @@ class OslShaderGeneratorTester : public GenShaderUtil::ShaderGeneratorTester whiteList = { "displacementshader", "volumeshader", - "IM_constant_", "IM_dot_", "IM_angle", "IM_geompropvalue" + "IM_constant_", "IM_dot_", "IM_angle", "IM_geompropvalue", "IM_geompropvalueuniform" }; ShaderGeneratorTester::getImplementationWhiteList(whiteList); }