Skip to content

Commit

Permalink
Add fallbacks for findUniform methods (#2150)
Browse files Browse the repository at this point in the history
This changelist adds fallbacks to the GlslMaterial::findUniform and MslMaterial::findUniform methods, allowing them to find matches for uniforms that don't yet have a full path.

This addresses issue #1782.
  • Loading branch information
jstone-lucasfilm authored Dec 17, 2024
1 parent 31ca71b commit af74b61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions source/MaterialXRenderGlsl/GlslMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ ShaderPort* GlslMaterial::findUniform(const std::string& path) const
{
return (port && stringEndsWith(port->getPath(), path));
});
if (!port)
{
port = publicUniforms->find([path](ShaderPort* port)
{
return (port && stringEndsWith(path, port->getName()));
});
}

// Check if the uniform exists in the shader program
if (port && !_glProgram->getUniformsList().count(port->getVariable()))
Expand Down
7 changes: 7 additions & 0 deletions source/MaterialXRenderMsl/MslMaterial.mm
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@
{
return (port && stringEndsWith(port->getPath(), path));
});
if (!port)
{
port = publicUniforms->find([path](ShaderPort* port)
{
return (port && stringEndsWith(path, port->getName()));
});
}

// Check if the uniform exists in the shader program
if (port && !_glProgram->getUniformsList().count(
Expand Down

0 comments on commit af74b61

Please sign in to comment.