Skip to content

Commit

Permalink
Add support for top level inputs (#1453)
Browse files Browse the repository at this point in the history
Fix so that top level inputs are parsed properly and values and path reflection data is correct (for uniform updates).
  • Loading branch information
kwokcb authored Aug 18, 2023
1 parent 19eb023 commit b23de80
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<materialx version="1.38" colorspace="lin_rec709">
<surfacematerial name="surfacematerial" type="material" xpos="17.246376" ypos="-15.689655">
<input name="surfaceshader" type="surfaceshader" nodename="surface_unlit" />
</surfacematerial>
<input name="input_color3" type="color3" value="0, 0, 1" xpos="10.905797" ypos="-15.982759" />
<surface_unlit name="surface_unlit" type="surfaceshader" xpos="14.231884" ypos="-16.241379">
<input name="emission_color" type="color3" interfacename="input_color3" />
</surface_unlit>
</materialx>
2 changes: 1 addition & 1 deletion source/MaterialXCore/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ InputPtr Input::getInterfaceInput() const
{
if (hasInterfaceName())
{
ConstNodeGraphPtr graph = getAncestorOfType<NodeGraph>();
ConstGraphElementPtr graph = getAncestorOfType<GraphElement>();
if (graph)
{
return graph->getInput(getInterfaceName());
Expand Down
12 changes: 11 additions & 1 deletion source/MaterialXGenShader/ShaderNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,17 @@ void ShaderNode::initialize(const Node& node, const NodeDef& nodeDef, GenContext
ShaderInput* input = getInput(nodeValue->getName());
if (input)
{
input->setPath(nodeValue->getNamePath());
string path = nodeValue->getNamePath();
InputPtr nodeInput = nodeValue->asA<Input>();
if (nodeInput)
{
InputPtr interfaceInput = nodeInput->getInterfaceInput();
if (interfaceInput)
{
path = interfaceInput->getNamePath();
}
}
input->setPath(path);
}
}

Expand Down

0 comments on commit b23de80

Please sign in to comment.