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

MaterialX: HdMtlx shader fails to compile when MaterialX nodedef has filename input #1786

Closed
ashwinbhat opened this issue Feb 25, 2022 · 1 comment

Comments

@ashwinbhat
Copy link
Contributor

Description of Issue

If a MaterialX nodedef has a filename type input that is routed to an image node, HdMtlx ShaderGen ignores this input.
I'm looking for some hints on where/how I could fix this.

Here is a nodedef with filename input

  <nodedef name="ND_diagimage" node="diagimage" version="1.0.0" isdefaultversion="true">
    <input name="extra_color" type="color3" value="0.6, 0, 0.6"/>
    <input name="diag_file" type="filename" value="diagnostic.png"/>
    <output name="out" type="surfaceshader" />
  </nodedef>

Here is the corresponding nodegraph.
The nodegraph maps the input filename to the image node.

<nodegraph name="IMPL_diagimage" nodedef="ND_diagimage">
    <texcoord name="texcoord" type="vector2" nodedef="ND_texcoord_vector2"/>
    <image name="image0" type="color3" nodedef="ND_image_color3">
      <input name="file" type="filename" interfacename="diag_file" />
      <input name="texcoord" type="vector2" nodename="texcoord" />
    </image>
    
    <add name="add1" type="color3" >
      <input name="in1" type="color3" interfacename="extra_color"  />
      <input name="in2" type="color3" nodename="image0"  />
    </add>
    <uniform_edf name="uniform_edf" type="EDF" >
      <input name="color" type="color3" nodename="add1" />
    </uniform_edf>
    <surface name="diag_shader" type="surfaceshader" >
      <input name="bsdf" type="BSDF" value="" />
      <input name="edf" type="EDF" nodename="uniform_edf" />
      <input name="opacity" type="float" value="1" />
    </surface>
    <output name="out" type="surfaceshader" nodename="diag_shader" />
</nodegraph>

Generates the following error:

Warning: in _ValidateCompilation at line 213 of pxr\imaging\hdSt\glslProgram.cpp -- Failed to compile shader (FRAGMENT_SHADER): 0(2436) : error C1503: undefined variable "diag_file"
ERROR: Usdview encountered an error while rendering.

Expected result from the referenced mtlx file loads in MaterialXVIew
mtlxview

Steps to Reproduce

  1. Extract the files in the zip mtlx_image_nodedef.zip
  2. Copy diagtest_def.mtlx from libraries\bxdf to usd\install\debug|release\libraries\bxdf (note this can be also be setup by using env variable)
  3. open simplediag.usda
  4. Usdview reports error in console
    Warning: in _ValidateCompilation at line 213 of \pxr\imaging\hdSt\glslProgram.cpp -- Failed to compile shader (FRAGMENT_SHADER): 0(2436) : error C1503: undefined variable "diag_file"

System Information (OS, Hardware)

Windows 10

Package Versions

v22.03-rc2

Build Flags

build_scripts\build_usd.py --build-variant debug --materialx

@jilliene
Copy link

Filed as internal issue #USD-7244

pixar-oss pushed a commit that referenced this issue Sep 20, 2022
Fixes #1786

(Internal change: 2248466)
pixar-oss pushed a commit that referenced this issue Sep 20, 2022
…e textures or texture coordinates

This change inspects a nodes implementation nodegraph
which means we no longer require custom nodes to use the
'textureuser' or 'texcoorduser' nodegroup names. Custom
texture nodes do still need a specific nodegroup name but
can now use the standard 'texture2d' name instead, and
they should also have a file input of type 'filename'.

Fixes #1786

(Internal change: 2248469)
pixar-oss pushed a commit that referenced this issue Sep 20, 2022
Fixes #1786

(Internal change: 2248713)
pixar-oss pushed a commit that referenced this issue Sep 20, 2022
… use textures.

Note that when using textures custom material nodes need to
expose the texture, meaning the 'filename' must be an input
on the material. Also, they need to be defined in a shared
library so the corresponding sdrNodes are created.

Adding surfaceshader entry to table in UsdMtlxUtils to fix a
warning when using custom material nodes.

Fixes #1786

(Internal change: 2248719)
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