Context
It is possible for documents to contain connections between mismatched types.
This is not considered to valid based on the MaterialX specification and is caught by validation.
Premise
MaterialX should provide core support to "patch" these mismatched type connections.
The proposal is to add in explicit convert nodes as appropriate noting some conversions
do no make sense since they cannot be type converted.
Work
Part Ia : Core Logic
- Add a new utility function to find type mismatches. e.g.
addExplicitTypeConversions() or
something better :).
- Consider the existing
convert nodes as the set of available supported types. Fail / skip
if not supported.
- Otherwise insert the appropriate
convert node between the existing connection. e.g
if there is a vector3 output connected to a color3 input, then create a convert node which
handles vector3 to colore conversion and insert it between the existing connection.
- It would be useful as feedback to return the list of nodes added w.r.t. the connection, and
a list of connections which cannot be handled.
Note: There is overlap with the existing validate() logic which already performs detection.
It would be desirable to reuse calling into that logic, or refactor to create a separate reusable detection
function.
Part Ib: Test
- Add in some test cases that perform validation, fix, and re-validation to make sure it
works. This can be in C++ as part of unit tests.
- This is a composite of possible connection configurations to test:
- node -> node connections
- input interface -> node connections -> + output interface
- upstream nodes with single / multiple connections ("multioutput")
- node -> input interface connections
- output interface -> node connections
- nesting of
GraphElements : Currently only NodeGraphs under a Document
- fan out from upstream outputs to more than 1 input downstream input.
Part II: API
- Add Python and Javascript bindings.
Part III : API command
- Add in a sample command to perform type connection fixes.
If this is a single day dev-days project then Part I could be considered an initial task.
Context
It is possible for documents to contain connections between mismatched types.
This is not considered to valid based on the MaterialX specification and is caught by validation.
Premise
MaterialX should provide core support to "patch" these mismatched type connections.
The proposal is to add in explicit
convertnodes as appropriate noting some conversionsdo no make sense since they cannot be type converted.
Work
Part Ia : Core Logic
addExplicitTypeConversions()orsomething better :).
convertnodes as the set of available supported types. Fail / skipif not supported.
convertnode between the existing connection. e.gif there is a
vector3output connected to acolor3input, then create a convert node whichhandles
vector3tocoloreconversion and insert it between the existing connection.a list of connections which cannot be handled.
Note: There is overlap with the existing
validate()logic which already performs detection.It would be desirable to reuse calling into that logic, or refactor to create a separate reusable detection
function.
Part Ib: Test
works. This can be in C++ as part of unit tests.
GraphElements : Currently onlyNodeGraphs under aDocumentPart II: API
Part III : API command
If this is a single day dev-days project then Part I could be considered an initial task.