Skip to content

Commit

Permalink
[HdSt] Fixing crash if we are unable to generate the MaterialX glslfx…
Browse files Browse the repository at this point in the history
… shader.

See #1636

(Internal change: 2219533)
  • Loading branch information
klucknav authored and pixar-oss committed Mar 11, 2022
1 parent 44447cf commit 528f78e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pxr/imaging/hdSt/materialXFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ HdSt_GenMaterialXShader(
if (typedElem) {
return _GenMaterialXShader(mxContext, typedElem);
}
TF_CODING_ERROR("Unable to generate a shader from the MaterialX Document");
return nullptr;
}

Expand Down Expand Up @@ -612,14 +613,15 @@ HdSt_ApplyMaterialXFilter(
// Load MaterialX Document and generate the glslfxShader
mx::ShaderPtr glslfxShader = HdSt_GenMaterialXShader(mtlxDoc,
searchPath, mxHdInfo);

if (!glslfxShader) {
return;
}
// Add material parameters from the glslfxShader to the materialParams
_AddMaterialXParams(glslfxShader, materialParams);

// Create a new terminal node with the new glslfxSource
const std::string glslfxSource = glslfxShader
? glslfxShader->getSourceCode(mx::Stage::PIXEL)
: mx::EMPTY_STRING;
const std::string glslfxSource =
glslfxShader->getSourceCode(mx::Stage::PIXEL);
SdrShaderNodeConstPtr sdrNode =
sdrRegistry.GetShaderNodeFromSourceCode(glslfxSource,
HioGlslfxTokens->glslfx,
Expand Down

0 comments on commit 528f78e

Please sign in to comment.