PrismPipeline / QuiltiX

QuiltiX is a graphical node editor to edit, and author MaterialX based materials of 3D assets
https://pypi.org/project/QuiltiX
Apache License 2.0
267 stars 29 forks source link

Interface input connections to interior nodes in nodegraphs do not load in #94

Open kwokcb opened 3 weeks ago

kwokcb commented 3 weeks ago

Issue

If you have a document with a nodegraph with inputs which are connected to downstream nodes, these connections are not made when loading in.

Steps

  1. Load in this example file:
    <?xml version="1.0"?>
    <materialx version="1.38">
    <surfacematerial name="USD_Default" type="material" xpos="7.614309946326862" ypos="2.9716248911086702">
    <input name="surfaceshader" type="surfaceshader" nodename="Standard_surface" />
    <output name="out" type="material" />
    </surfacematerial>
    <standard_surface name="Standard_surface" type="surfaceshader" xpos="3.319462081295691" ypos="1.3830203895725879">
    <input name="base_color" type="color3" value="0.8, 0.8, 0.8" nodegraph="Nodegraph" output="out_Add" />  
    <output name="out" type="surfaceshader" />
    </standard_surface>
    <nodegraph name="Nodegraph" xpos="0.7769098475963486" ypos="2.948029272574578">
    <add name="Add" type="color3" xpos="3.5103239549683254" ypos="2.7896954322821355">
      <input name="in1" type="color3" interfacename="in_Add" />
      <input name="in2" type="color3" interfacename="in_Add_1" />
      <output name="out" type="color3" />
    </add>
    <output name="out_Add" type="color3" nodename="Add" />
    <input name="in_Add" type="color3" value="0.094118, 0.74902, 0.313725" />
    <input name="in_Add_1" type="color3" value="0.929412, 0.282353, 0.027451" />
    </nodegraph>
    </materialx>

This example was created in the editor and while creating it seems okay so this appears to be purely a load issue.

  1. When you look at the graph, it looks like this: image

  2. If you example the XML (using text preview):

    <?xml version="1.0"?>
    <materialx version="1.38">
    <surfacematerial name="USD_Default" type="material" xpos="7.614309946326862" ypos="2.9716248911086702">
    <input name="surfaceshader" type="surfaceshader" nodename="Standard_surface" />
    <output name="out" type="material" />
    </surfacematerial>
    <standard_surface name="Standard_surface" type="surfaceshader" xpos="3.319462081295691" ypos="1.3830203895725879">
    <input name="base" type="float" value="1" />
    <input name="base_color" type="color3" value="0.8, 0.8, 0.8" nodegraph="Nodegraph" output="out_Add" />
    <input name="diffuse_roughness" type="float" value="0" />
    <input name="metalness" type="float" value="0.8" />
    <input name="specular" type="float" value="1" />
    <input name="specular_color" type="color3" value="1, 1, 1" />
    <input name="specular_roughness" type="float" value="0.1" />
    <input name="specular_IOR" type="float" value="1.5" />
    <input name="specular_anisotropy" type="float" value="0" />
    <input name="specular_rotation" type="float" value="0" />
    <input name="transmission" type="float" value="0" />
    <input name="transmission_color" type="color3" value="1, 1, 1" />
    <input name="transmission_depth" type="float" value="0" />
    <input name="transmission_scatter" type="color3" value="0, 0, 0" />
    <input name="transmission_scatter_anisotropy" type="float" value="0" />
    <input name="transmission_dispersion" type="float" value="0" />
    <input name="transmission_extra_roughness" type="float" value="0" />
    <input name="subsurface" type="float" value="0" />
    <input name="subsurface_color" type="color3" value="1, 1, 1" />
    <input name="subsurface_radius" type="color3" value="1, 1, 1" />
    <input name="subsurface_scale" type="float" value="1" />
    <input name="subsurface_anisotropy" type="float" value="0" />
    <input name="sheen" type="float" value="0" />
    <input name="sheen_color" type="color3" value="1, 1, 1" />
    <input name="sheen_roughness" type="float" value="0.3" />
    <input name="coat" type="float" value="1" />
    <input name="coat_color" type="color3" value="0.6, 0.45, 1" />
    <input name="coat_roughness" type="float" value="0.1" />
    <input name="coat_anisotropy" type="float" value="0" />
    <input name="coat_rotation" type="float" value="0" />
    <input name="coat_IOR" type="float" value="2.5" />
    <input name="coat_affect_color" type="float" value="0" />
    <input name="coat_affect_roughness" type="float" value="0" />
    <input name="thin_film_thickness" type="float" value="0" />
    <input name="thin_film_IOR" type="float" value="1.5" />
    <input name="emission" type="float" value="0" />
    <input name="emission_color" type="color3" value="1, 1, 1" />
    <input name="opacity" type="color3" value="1, 1, 1" />
    <input name="thin_walled" type="boolean" value="false" />
    <output name="out" type="surfaceshader" />
    </standard_surface>
    <nodegraph name="Nodegraph" xpos="0.43441000436718924" ypos="2.8679899354385903">
    <add name="Add" type="color3" xpos="3.5103239549683254" ypos="2.7896954322821355">
      <input name="in1" type="color3" value="0, 0, 0" />
      <input name="in2" type="color3" value="0, 0, 0" />
      <output name="out" type="color3" />
    </add>
    <output name="out_Add" type="color3" nodename="Add" />
    </nodegraph>
    </materialx>

Here you can see that the inputs are missing from the document but appear in the UI.

Thus it appears that the nodegraph UI has the inputs added but the connections are never made to the node UI ?

kwokcb commented 3 weeks ago

@manuelkoester , @RichardFrangenberg

I have tried adding this code inside of connect_qx_inputs_from_mx_node(). It adds a connection but doesn't work properly. For example the nodegraph has no UI in the properly panel.

for mx_input in mx_node.getActiveInputs():
    if mx_input.hasInterfaceName():   
                    intf_name = mx_input.getInterfaceName()
                    logger.info("-------------- Add connect interface name: %s" % intf_name)   
                    port_node = qx_node.graph.get_input_port_nodes()[0]
                    out_port = port_node.get_output(intf_name)
                    qx_input_port = qx_node.get_input(mx_input.getName())
                    out_port.connect_to(qx_input_port)
kwokcb commented 3 weeks ago

This is the current WIP code.

https://github.com/PrismPipeline/QuiltiX/compare/main...kwokcb:interface_input_load?expand=1

The connections are there but when unexpanded there are no inputs on the nodegraph node. Tried forcing an update but no luck: https://github.com/PrismPipeline/QuiltiX/compare/main...kwokcb:interface_input_load?expand=1#diff-98b0f2ce3bf2a207a8c4be6ee4c9a654250018d567f18b55dff0d6fc686ef145R889-R897

There are no value attributes on for the interface inputs when examining the XML.