MaterialX icon indicating copy to clipboard operation
MaterialX copied to clipboard

Update API and Traversal to Support Nested NodeGraphs

Open kwokcb opened this issue 2 months ago • 2 comments

Issue

Even though the 1.39 specification notes that nodegraphs may be nested the current API and traversal mechanism implementation does not reflect this.

Changes

  • Move the nodegraph parenting API from Document to GraphElement thus allow for parenting from the derived class NodeGraph
  • Update traversal and connection logic to make connections to nested nodegraphs be supported.
  • Updated API. Should be no API compatibility issues as the interfaces are still available at Document level, but are now available at NodeGraph level.

Tests

  • New nested nodegraph tests added to unit test suite.
graph BT
    subgraph parentNG
    style parentNG_parentNGInput  fill:#09D, color:#FFF
    parentNG_parentNGInput([parentNGInput:1, 1, 0.2])
    style parentNG_parentNGInput2  fill:#09D, color:#FFF
    parentNG_parentNGInput2([parentNGInput2:0.2, 1, 1])
    style parentNG_parentNGInput3  fill:#09D, color:#FFF
    parentNG_parentNGInput3([parentNGInput3:1, 0.2, 1])
    style parentNG_parentNGOutput1  fill:#0C0, color:#FFF
    parentNG_parentNGOutput1([parentNGOutput1])
    style parentNG_parentNGOutput2  fill:#0C0, color:#FFF
    parentNG_parentNGOutput2([parentNGOutput2])
    parentNG_parentmultiplyNode[parentmultiplyNode]
    
    subgraph parentNG_childNG
    style parentNG_childNG_childNGInput  fill:#09D, color:#FFF
    parentNG_childNG_childNGInput([childNGInput])
    style parentNG_childNG_childNGInput2  fill:#09D, color:#FFF
    parentNG_childNG_childNGInput2([childNGInput2])
    parentNG_childNG_multiplyNode[multiplyNode]
    parentNG_childNG_childNGOutput[childNGOutput]
    end
    
    end

nestd_graph_shader[nestd_graph_shader]
    style nested_graph_material  fill:#090, color:#FFF
    nested_graph_material([nested_graph_material])
    nestd_graph_shader2[nestd_graph_shader2]
    style nested_graph_material2  fill:#090, color:#FFF
    nested_graph_material2([nested_graph_material2])
    
    parentNG_parentNGInput --> parentNG_childNG_childNGInput
    parentNG_parentNGInput2 --> parentNG_childNG_childNGInput2
    parentNG_childNG_childNGInput --"in1"--> parentNG_childNG_multiplyNode
    parentNG_childNG_childNGInput2 --"in2"--> parentNG_childNG_multiplyNode
    parentNG_childNG_multiplyNode --> parentNG_childNG_childNGOutput
    parentNG_childNG_childNGOutput--"in1"--> parentNG_parentmultiplyNode
    parentNG_parentNGInput3 --"in2"--> parentNG_parentmultiplyNode
    parentNG_childNG_childNGOutput--> parentNG_parentNGOutput1
    parentNG_parentmultiplyNode --> parentNG_parentNGOutput2
    parentNG_parentNGOutput1 --"base_color"--> nestd_graph_shader
    nestd_graph_shader --"surfaceshader"--> nested_graph_material
    parentNG_parentNGOutput2 --"base_color"--> nestd_graph_shader2
    nestd_graph_shader2 --"surfaceshader"--> nested_graph_material2
  • Ran RTS with GLSL and OSL locally.

kwokcb avatar Apr 24 '24 13:04 kwokcb