Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connections between nodes with multiple outputs ("multioutput") are not correctly handled #34

Closed
kwokcb opened this issue Nov 16, 2023 · 4 comments · Fixed by #66
Closed
Labels
bug Something isn't working

Comments

@kwokcb
Copy link
Contributor

kwokcb commented Nov 16, 2023

Issue

Separate and combine types and connections are improperly set / created

Environment

Tested with 0.4.1.

Test

If you create a separate node and then a combine node and connect the combine to a color3, the

  1. Separate node remains the incorrect type of "float" - which has no definition
  2. The input connections on the combine node do not specify which output to route to the combine.
    Perhaps this is a general "multioutput" issue?

Errors when the document get's validated.

Node interface doesn't support this output type: <separate3 name="Separate3" type="float" xpos="-7.002825605060728" ypos="2.48722845391956">
Mismatched types in port connection: <input name="base" type="float" value="1" nodegraph="NG_main" output="output_Combine3_out">

Could not find a nodedef for node 'Separate3'
Could not find a nodedef for node 'Separate3'

This is the resulting MaterialX file:

<?xml version="1.0"?>
<materialx version="1.38">
  <nodegraph name="NG_main">
    <separate3 name="Separate3" type="float" xpos="-7.002825605060728" ypos="2.48722845391956">
      <input name="in" type="color3" value="0, 0.894118, 0.14902" />
    </separate3>
    <combine3 name="Combine3" type="color3" xpos="-4.030665817358112" ypos="2.0648689051407674">
      <input name="in1" type="float" value="0" nodename="Separate3" />
      <input name="in2" type="float" value="0" nodename="Separate3" />
      <input name="in3" type="float" value="0" nodename="Separate3" />
    </combine3>
    <output name="output_Combine3_out" type="color3" nodename="Combine3" />
  </nodegraph>
  <surfacematerial name="USD_Default" type="material" xpos="3.6367873479362176" ypos="0.9333624596469625">
    <input name="surfaceshader" type="surfaceshader" nodename="Standard_surface" />
  </surfacematerial>
  <standard_surface name="Standard_surface" type="surfaceshader" xpos="-1.3527374062034248" ypos="1.0335230787321623">
    <input name="base" type="float" value="1" nodegraph="NG_main" output="output_Combine3_out" />
    <input name="base_color" type="color3" value="0.8, 0.8, 0.8" />
    <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_normal" type="vector3" value="0, 0, 0" />
    <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" />
    <input name="normal" type="vector3" value="0, 0, 0" />
    <input name="tangent" type="vector3" value="0, 0, 0" />
  </standard_surface>
</materialx>
@RichardFrangenberg
Copy link
Member

RichardFrangenberg commented Nov 22, 2023

Thanks for reporting this.
I created a branch with a fix for this: https://github.com/PrismPipeline/QuiltiX/tree/fix_multi_output_nodes
Feel free to test that change.

The separate node has now the type "multioutput" and it works fine with Storm:
image

However the generated MaterialX file has a validation error:
No output found for port connection: <input name="in2" type="float" value="0" output="outg" nodename="Separate3"

Do you know what this means and how to fix it @kwokcb ?
The generated xml data looks correct to me and USD can load the file without problem. Could it be that there is a problem in the validator?
This is the generated xml data:

<?xml version="1.0"?>
<materialx version="1.38">
  <nodegraph name="NG_main">
    <separate3 name="Separate3" type="multioutput" xpos="-6.323393349156183" ypos="0.4079608612358828">
      <input name="in" type="color3" value="1, 1, 1" />
      <output name="outr" type="float" />
      <output name="outg" type="float" />
      <output name="outb" type="float" />
    </separate3>
    <combine3 name="Combine3" type="color3" xpos="-3.9209571663226512" ypos="0.5439478149811771">
      <input name="in1" type="float" value="0" />
      <input name="in2" type="float" value="0" output="outg" nodename="Separate3" />
      <input name="in3" type="float" value="0" />
      <output name="out" type="color3" />
    </combine3>
    <output name="output_Combine3_out" type="color3" nodename="Combine3" />
  </nodegraph>
  <surfacematerial name="USD_Default" type="material" xpos="2.1875" ypos="0.0">
    <input name="surfaceshader" type="surfaceshader" nodename="Standard_surface" />
    <output name="out" type="material" />
  </surfacematerial>
  <standard_surface name="Standard_surface" type="surfaceshader" xpos="-1.5775000000000001" ypos="0.0">
    <input name="base" type="float" value="1" />
    <input name="base_color" type="color3" value="0.8, 0.8, 0.8" nodegraph="NG_main" output="output_Combine3_out" />
    <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_normal" type="vector3" value="0, 0, 0" />
    <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" />
    <input name="normal" type="vector3" value="0, 0, 0" />
    <input name="tangent" type="vector3" value="0, 0, 0" />
    <output name="out" type="surfaceshader" />
  </standard_surface>
</materialx>

@kwokcb
Copy link
Contributor Author

kwokcb commented Nov 23, 2023

  • I tried the branch but the graph shows up unconnected on load (first version):
    image

  • The error you're encountering appears to be when trying to make connection between the upstream output and input. By default the node will not create it's outputs (outr, outg, outb) so when you try to connect there is no output port on the upstream node.

It seems the MaterialX save is adding in the outputs for every node (outr, outg, outb) after which the output can be found. I assume USD conversion is adding outputs as needed when converting to UsdShade.

I think a more robust mechanism is to add the output if it's not there when loading.

@kwokcb kwokcb changed the title Separate / Combine connections and types incorrect Connections between nodes with multiple outputs ("multioutput") are not correctly handled Nov 23, 2023
@manuelkoester manuelkoester added the bug Something isn't working label Dec 27, 2023
@RichardFrangenberg
Copy link
Member

Hey @kwokcb , I added a new commit, which fixes the problems when loading the mtlx file. Could you give it a try?
The validation warning is still there. It still looks like a problem in the validator to me.
However the material updates fine for me in Storm.

@kwokcb
Copy link
Contributor Author

kwokcb commented Feb 17, 2024

Thanks @RichardFrangenberg
I'll take a look at it as soon as I can. If there is a validation error, I can take this up in core MaterialX :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants