AcademySoftwareFoundation / AcademySoftwareFoundation/MaterialX
Shader Translation fails to find upstream connections without explicit outputs
- Dominant language
- C++
- Stars
- 2.3k
- Forks
- 451
- Avg merge
- 6d 6h
- Merged PRs (30d)
- 5
Description
If an upstream node on an input is connected, but that node does not have an explicit "output" child the current
logic will fail. This code it appears is only looking for the upstream node and not the output so should be
able to be changed though the input->output connection dictionary also needs to be maintained.
See this code:
https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/source/MaterialXGenShader/ShaderTranslator.cpp#L26-L44
or
```
OutputPtr connectedOutput = shaderInput->getConnectedOutput();
if (connectedOutput)
{
NodePtr connectedNode = connectedOutput->getConnectedNode(); <-- This can be called directly to get the node
// Nodes with world-space outputs are skipped, with translation being applied to
// the node directly upstream.
NodePtr worldSpaceNode = connectsToWorldSpaceNode(connectedOutput); <-- This signature would need to change to use the node directly
if (worldSpaceNode)
{
NodePtr upstreamNode = worldSpaceNode->getConnectedNode("in");
if (upstreamNode)
{
connectedNode = upstreamNode;
}
}
input->setConnectedNode(connectedNode);
origOutputs.insert(connectedOutput); <-- Unknonw what to do here ?
}
```
A workaround is to create all the explicit outputs on load (or after the fact). There are utilities to do this.
Contributor guide
Research direction
Start in source/MaterialXGenShader/ShaderTranslator.cpp at lines 26-44 and trace getConnectedOutput(), connectsToWorldSpaceNode(), and origOutputs. Reproduce a shader input connected to an upstream node without an explicit output, then follow the input-to-output connection dictionary; done means translation finds the upstream node and preserves the required output tracking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100