Skip to content
New issue

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

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

Already on GitHub? # to your account

usdMtlx fails to read a mtlx file with more than one bind input #950

Closed
juliencb2018 opened this issue Aug 28, 2019 · 4 comments
Closed

Comments

@juliencb2018
Copy link
Contributor

juliencb2018 commented Aug 28, 2019

Description of Issue

usdMtlx is failing to properly read a materialX file that has more than one bind input.

Steps to Reproduce

  1. Input mtlx file with more than one bind input:

MultiBindInputs.mtlx

<?xml version="1.0"?>
<materialx version="1.36">                                                                                                                                                                                    
  <nodedef name="ND_layerShader" type="surfaceshader" node="layerShader">                                                                                                                                     
        <input name="weight_1" type="color3"/>                                                                                                                                                                
        <input name="weight_2" type="color3"/>                                                                                                                                                                
        <input name="weight_3" type="color3"/>                                                                                                                                                                
    </nodedef>                                                                                                                                                                                                
  <Gradient name="layered_layer1_gradient" type="color3">                                                                                                                                                     
  </Gradient>                                                                                                                                                                                                 
  <Gradient name="layered_layer2_gradient" type="color3">                                                                                                                                                     
  </Gradient>                                                                                                                                                                                                 
  <Gradient name="layered_layer3_gradient" type="color3">                                                                                                                                                     
  </Gradient>                                                                                                                                                                                                 
  <material name="layered">                                                                                                                                                                                   
    <shaderref name="layered_sr" node="layerShader">                                                                                                                                                          
      <bindinput name="weight_1" type="color3" output="o_layered_layer1_gradient" />                                                                                                                          
      <bindinput name="weight_2" type="color3" output="o_layered_layer2_gradient" />                                                                                                                          
      <bindinput name="weight_3" type="color3" output="o_layered_layer3_gradient" />                                                                                                                          
    </shaderref>                                                                                                                                                                                              
  </material>                                                                                                                                                                                                 
  <output name="o_layered_layer1_gradient" type="color3" nodename="layered_layer1_gradient" />                                                                                                                
  <output name="o_layered_layer2_gradient" type="color3" nodename="layered_layer2_gradient" />                                                                                                                
  <output name="o_layered_layer3_gradient" type="color3" nodename="layered_layer3_gradient" />                                                                                                                
</materialx>
  1. python calls to read and parse this file:
from pxr import Usd, UsdShade, Sdf
stage = Usd.Stage.CreateInMemory()
stage = stage.Open('MultiBindInputs.mtlx')
nodeGraph = UsdShade.NodeGraph.Get(stage, Sdf.Path('/MaterialX/Materials/layered/ND_layerShader'))
inputs = nodeGraph.GetInputs()
for i in inputs:
     print i.GetFullName(), i.HasConnectedSource(), i.GetConnectedSource()[0].GetPath()
  1. The previous snippet does produce this warning:
Warning: in AddReference at line 1070 of px//lib/vendor/pixar/usdMtlx/pxr/usd/usdMtlx/reader.cpp -- Can't create node graph at </MaterialX/Materials/layered/NodeGraphs>; a '' already exists
Warning: in AddReference at line 1070 of pxr//lib/vendor/pixar/usdMtlx/pxr/usd/usdMtlx/reader.cpp -- Can't create node graph at </MaterialX/Materials/layered/NodeGraphs>; a '' already exists

And the prints are:

inputs:weight_1 True /MaterialX/Materials/layered/NodeGraphs/layered_layer1_gradient
inputs:weight_2 True /MaterialX/Materials/layered
inputs:weight_3 True /MaterialX/Materials/layered

which are incorrect.

The correct prints are:

inputs:weight_1 True /MaterialX/Materials/layered/NodeGraphs/layered_layer1_gradient
inputs:weight_2 True /MaterialX/Materials/layered/NodeGraphs/layered_layer2_gradient
inputs:weight_3 True /MaterialX/Materials/layered/NodeGraphs/layered_layer3_gradient

System Information (OS, Hardware)

Linux RHEL7

Package Versions

Build Flags

@jilliene
Copy link

Filed as internal issue #USD-5517

@spiffmon
Copy link
Member

Thanks, @juliencb2018 - we'll have a look!

@juliencb2018
Copy link
Contributor Author

juliencb2018 commented Aug 30, 2019 via email

juliencb2018 added a commit to juliencb2018/USD that referenced this issue Sep 4, 2019
usdMtlx fails to read a mtlx file with more than one bind input PixarAnimationStudios#950
@sunyab
Copy link
Contributor

sunyab commented Oct 31, 2019

PR #956 was released with 19.11 -- closing, thanks!

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

No branches or pull requests

4 participants