AcademySoftwareFoundation / MaterialX

MaterialX is an open standard for the exchange of rich material and look-development content across applications and renderers.
http://www.materialx.org/
Apache License 2.0
1.87k stars 352 forks source link

Input node resolution failure when same-named nodes exist inside and outside a nodegraph #1976

Open zicher3d opened 2 months ago

zicher3d commented 2 months ago

This s a bit tricky to reproduce, as it might depend on some evaluation order. But the attached document consistently reproduces it on 1.38.10 and 1.39.0. Smaller test documents tend to work, so I'm posting the larger doc.

maya_ldx_export_gradient_test_debug2.zip

Load the document in Viewer and you will see this error: image In the Graph Editor the error will appear on the console output.

The input for the nodegraph is a node "multiply1". There is another "multiply1" inside the graph that should not be a concern, but the check finds it and throw the error.

This document was created in Maya/LookdevX. Inside Maya it works fine.

zicher3d commented 2 months ago

I'm adding another test case, a reduced version of the original doc, that ends up in a different error. The cause seem to be the same, as the error is fixed by renaming the "multiply1" outside the nodegraph, but in this case the generated code is broken and you get a glsl compile error and a bunch of issues on the console.

maya_ldx_export_gradient_test_debug1.zip

image

This works in Maya/LookdevX as well.

kwokcb commented 2 months ago

Visually, I get this.

graph LR
    surfacematerial1([surfacematerial1])
    style surfacematerial1   fill:#090, color:#FFF
    texcoord1[texcoord1]
    multiply1[multiply1]
    subgraph gradient_test
    gradient_test_texcoord([texcoord])
    style gradient_test_texcoord  fill:#09D, color:#FFF
    gradient_test_type([type:4])
    style gradient_test_type  fill:#09D, color:#FFF
    gradient_test_color1([color1:0.9069, 0.5283, 0])
    style gradient_test_color1  fill:#09D, color:#FFF
    gradient_test_color2([color2:0.049, 0.0041, 0.5988])
    style gradient_test_color2  fill:#09D, color:#FFF
    gradient_test_out([out])
    style gradient_test_out  fill:#09D, color:#FFF
    gradient_test_modulo1[modulo1]
    gradient_test_standard_surface1[standard_surface1]
    gradient_test_switch1{switch1}
    style gradient_test_switch1   fill:#C72, color:#FFF
    gradient_test_separate2_1[separate2_1]
    gradient_test_multiply1[multiply1]
    gradient_test_multiply2[multiply2]
    gradient_test_divide1[divide1]
    gradient_test_subtract3[subtract3]
    gradient_test_absval3[absval3]
    gradient_test_multiply3[multiply3]
    gradient_test_separate2_2[separate2_2]
    gradient_test_max1[max1]
    gradient_test_min1[min1]
    gradient_test_magnitude1[magnitude1]
    gradient_test_combine2_1[combine2_1]
    gradient_test_mix1[mix1]
    gradient_test_subtract1[subtract1]
    gradient_test_subtract2[subtract2]
    end
    gradient_test_out --"surfaceshader"--> surfacematerial1
    texcoord1 --"in1"--> multiply1
    multiply1 --> gradient_test_texcoord
    gradient_test_standard_surface1 --> gradient_test_out
    gradient_test_texcoord --"in1"--> gradient_test_modulo1
    gradient_test_mix1 --"base_color"--> gradient_test_standard_surface1
    gradient_test_divide1 --"in3"--> gradient_test_switch1
    gradient_test_separate2_1 --"outx-->in1"--> gradient_test_switch1
    gradient_test_separate2_1 --"outy-->in2"--> gradient_test_switch1
    gradient_test_min1 --"in4"--> gradient_test_switch1
    gradient_test_type --"which"--> gradient_test_switch1
    gradient_test_magnitude1 --"in5"--> gradient_test_switch1
    gradient_test_modulo1 --"in"--> gradient_test_separate2_1
    gradient_test_separate2_1 --"outy-->in1"--> gradient_test_multiply1
    gradient_test_separate2_1 --"outy-->in2"--> gradient_test_multiply1
    gradient_test_separate2_1 --"outx-->in1"--> gradient_test_multiply2
    gradient_test_separate2_1 --"outx-->in2"--> gradient_test_multiply2
    gradient_test_multiply1 --"in1"--> gradient_test_divide1
    gradient_test_multiply2 --"in2"--> gradient_test_divide1
    gradient_test_modulo1 --"in1"--> gradient_test_subtract3
    gradient_test_subtract3 --"in"--> gradient_test_absval3
    gradient_test_absval3 --"in1"--> gradient_test_multiply3
    gradient_test_multiply3 --"in"--> gradient_test_separate2_2
    gradient_test_separate2_2 --"outx-->in1"--> gradient_test_max1
    gradient_test_separate2_2 --"outy-->in2"--> gradient_test_max1
    gradient_test_max1 --"in1"--> gradient_test_min1
    gradient_test_combine2_1 --"in"--> gradient_test_magnitude1
    gradient_test_subtract1 --"in1"--> gradient_test_combine2_1
    gradient_test_subtract2 --"in2"--> gradient_test_combine2_1
    gradient_test_color1 --"fg"--> gradient_test_mix1
    gradient_test_color2 --"bg"--> gradient_test_mix1
    gradient_test_switch1 --"mix"--> gradient_test_mix1
    gradient_test_separate2_1 --"outy-->in1"--> gradient_test_subtract1
    gradient_test_separate2_1 --"outx-->in2"--> gradient_test_subtract1
    gradient_test_separate2_1 --"outx-->in1"--> gradient_test_subtract2
    gradient_test_separate2_1 --"outy-->in2"--> gradient_test_subtract2
kwokcb commented 2 months ago

From what I see this is coming from code generation and is a known and logged issue of name scope. Sorry I don't recall which one it is.