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

Swizzle node inside nodegraph ignored edits to 'channels' #1598

Closed
leekerley opened this issue Nov 9, 2023 · 1 comment
Closed

Swizzle node inside nodegraph ignored edits to 'channels' #1598

leekerley opened this issue Nov 9, 2023 · 1 comment

Comments

@leekerley
Copy link

When using a swizzle node inside a nodegraph it appears that editing the channels input via the interfacename attribute convention doesn't work.

I've only tested this in the Metal shader generator, but if I'm understanding the code I think it would affect all shader generators. It appears that the Swizzle shader generator node is directly querying the channels input parameter value at shader code generation time (source code), and only querying this directly from the node that's being generated, ignoring any upstream edits that might affect the node.

The file below demonstrates the problem

<?xml version="1.0"?>
<materialx version="1.38">

<nodedef name="ND_mySwizzle" node="mySwizzle" nodegroup="channel">
    <input name="in" type="float" value="0.0" />
    <input name="channels" type="string" value="rrr" uniform="true"  />
    <output name="out" type="color3" default="0.0, 0.0, 0.0" />
</nodedef>

<nodegraph name="IM_mySwizzle" nodedef="ND_mySwizzle">
    <swizzle name="my_swizzle" type="color3">
        <input name="in" type="float" interfacename="in"/>
        <input name="channels" type="string" interfacename="channels"/>
    </swizzle>
    <output name="out" type="color3" nodename="my_swizzle"/>
</nodegraph>

<mySwizzle name="test_node" type="color3">
    <input name="in" type="float"  value="0.85"/>
    <input name="channels" type="string"  value="00r"/>
</mySwizzle>

<oren_nayar_diffuse_bsdf name="diffuse_bsdf" type="BSDF">
    <input name="color" type="color3" nodename="test_node" />
</oren_nayar_diffuse_bsdf>
<surface name="surface_constructor" type="surfaceshader">
    <input name="bsdf" type="BSDF" nodename="diffuse_bsdf" />
</surface>
<surfacematerial name="test_material" type="material">
    <input name="surfaceshader" type="surfaceshader" nodename="surface_constructor" />
</surfacematerial>
</materialx>

broken_swizzle_nodegraph

Notice here we get the image we would expect if channels is rrr which is the default specified inside the node definition, that should be being over written by the input specified on the test_nodegraph node.

I would expect it to generate the same image as this file

<?xml version="1.0"?>
<materialx version="1.38">

<swizzle name="test_node" type="color3">
    <input name="in" type="float"  value="0.85"/>
    <input name="channels" type="string"  value="00r"/>
</swizzle>

<oren_nayar_diffuse_bsdf name="diffuse_bsdf" type="BSDF">
    <input name="color" type="color3" nodename="test_node" />
</oren_nayar_diffuse_bsdf>
<surface name="surface_constructor" type="surfaceshader">
    <input name="bsdf" type="BSDF" nodename="diffuse_bsdf" />
</surface>
<surfacematerial name="test_material" type="material">
    <input name="surfaceshader" type="surfaceshader" nodename="surface_constructor" />
</surfacematerial>
</materialx>

working_swizzle_node

@jstone-lucasfilm
Copy link
Member

Thanks for this original report, @ld-kerley, and I believe we can close this issue as swizzle nodes have been removed from MaterialX 1.39 in #1793.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants