diff --git a/pxr/imaging/hdMtlx/hdMtlx.cpp b/pxr/imaging/hdMtlx/hdMtlx.cpp index ce0ae2c897..8167bae402 100644 --- a/pxr/imaging/hdMtlx/hdMtlx.cpp +++ b/pxr/imaging/hdMtlx/hdMtlx.cpp @@ -35,7 +35,9 @@ PXR_NAMESPACE_OPEN_SCOPE TF_DEFINE_PRIVATE_TOKENS( _tokens, - (index) + (texcoord) + (geompropvalue) + (filename) ); static mx::FileSearchPath @@ -184,12 +186,12 @@ HdMtlxConvertToString(VtValue const& hdParameterValue) } static bool -_ContainsTexcoordNode(mx::NodeDefPtr const& mxNodeDef) +_UsesTexcoordNode(mx::NodeDefPtr const& mxNodeDef) { mx::InterfaceElementPtr impl = mxNodeDef->getImplementation(); if (impl && impl->isA()) { mx::NodeGraphPtr nodegraph = impl->asA(); - if (nodegraph->getNodes("texcoord").size() != 0) { + if (!nodegraph->getNodes(_tokens->texcoord).empty()) { return true; } } @@ -275,7 +277,7 @@ _AddMaterialXNode( // MaterialX nodes that use textures can have more than one filename input if (mxHdData) { for (mx::InputPtr const& mxInput : mxNodeDef->getActiveInputs()) { - if (mxInput->getType() == "filename") { + if (mxInput->getType() == _tokens->filename) { // Save the corresponding Mx and Hydra names for ShaderGen mxHdData->mxHdTextureMap[mxNodeName].insert(mxInput->getName()); // Save the path to adjust parameters after for ShaderGen @@ -285,7 +287,7 @@ _AddMaterialXNode( } // MaterialX primvar node - if (mxNodeCategory == "geompropvalue") { + if (mxNodeCategory == _tokens->geompropvalue) { if (mxHdData) { // Save the path to have the primvarName declared in ShaderGen mxHdData->hdPrimvarNodes.insert(hdNodePath); @@ -294,14 +296,8 @@ _AddMaterialXNode( // Stdlib MaterialX texture coordinate node or a custom node that // uses a texture coordinate node - if (mxNodeCategory == "texcoord" || _ContainsTexcoordNode(mxNodeDef)) { + if (mxNodeCategory == _tokens->texcoord || _UsesTexcoordNode(mxNodeDef)) { if (mxHdData) { - // Make sure it has the index parameter set. - if (std::find(hdNodeParamNames.begin(), hdNodeParamNames.end(), - _tokens->index) == hdNodeParamNames.end()) { - netInterface->SetNodeParameterValue( - hdNodeName, _tokens->index, VtValue(0)); - } // Save the path to have the textureCoord name declared in ShaderGen mxHdData->hdPrimvarNodes.insert(hdNodePath); } diff --git a/pxr/imaging/hdSt/materialXFilter.cpp b/pxr/imaging/hdSt/materialXFilter.cpp index f3f38b18b3..4a3977ef9f 100644 --- a/pxr/imaging/hdSt/materialXFilter.cpp +++ b/pxr/imaging/hdSt/materialXFilter.cpp @@ -495,10 +495,9 @@ _UpdatePrimvarNodes( (*mxHdPrimvarDefaultValueMap)[primvarName] = defaultPrimvarValue; } - // Texcoord nodes will have an index parameter set - primvarNameIt = hdPrimvarNode.parameters.find(_tokens->index); - if (primvarNameIt != hdPrimvarNode.parameters.end()) { - // Get the sdr node for the texcoord node + else { + // Other primvar nodes will be either a texcoord node or a + // custom node that uses a texcoord node. SdrRegistry &sdrRegistry = SdrRegistry::GetInstance(); const SdrShaderNodeConstPtr sdrTexCoordNode = sdrRegistry.GetShaderNodeByIdentifierAndType( @@ -511,12 +510,7 @@ _UpdatePrimvarNodes( texCoordName = metadata[SdrNodeMetadata->Primvars]; } - // Figure out the mx typename - mx::NodeDefPtr mxNodeDef = mxDoc->getNodeDef( - hdPrimvarNode.nodeTypeId.GetString()); - if (mxNodeDef) { - (*mxHdPrimvarMap)[texCoordName] = mxNodeDef->getType(); - } + (*mxHdPrimvarMap)[texCoordName] = mx::Type::VECTOR2->getName(); } } }