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

Simple MaterialX examples not displaying correctly in usdview #1636

Closed
pmolodo opened this issue Oct 1, 2021 · 4 comments
Closed

Simple MaterialX examples not displaying correctly in usdview #1636

pmolodo opened this issue Oct 1, 2021 · 4 comments

Comments

@pmolodo
Copy link
Contributor

pmolodo commented Oct 1, 2021

Description of Issue

I've been trying to get some basic MaterialX examples to display in usdview, and haven't had much luck.

I'm not sure which of these are expected failures - ideally, ALL of these .usda files should work, somehow. (Though obviously some of the combinatons of env vars won't work - I was just flailing a bit, trying to find some way to set env vars to make usdMtlx read my library files correctly...)

Steps to Reproduce

  1. Unzip the attached zip files somewhere
  2. (Optional) If you also want to run MaterialXView, to confirm that the .mtlx files are valid, download materialx somewhere, and put MaterialXView on your path
  3. Run these commands, adapting for your os, or the location of the unzipped test files:

Results - Basic Parameter Override

One mtlx file, just setting inputs to a standard shader

WORKS

MaterialXView --material "C:\matx_tests\red_onefile_onenode.mtlx"

WORKS

usdview "C:\matx_tests\red_onefile_onenode.usda"

Results - Image File

One mtlx file, with image node hooked up to a standard shader

WORKS

MaterialXView --material "C:\matx_tests\wood_onefile_twonodes.mtlx"

FAILS

usdview "C:\matx_tests\wood_onefile_twonodes.usda"
    (No error message - texture node simply not created)

One mtlx file, with the image node in a nodegraph

WORKS

MaterialXView --material "C:\matx_tests\wood_onefile_nodegraph.mtlx"

WORKS

usdview "C:\matx_tests\wood_onefile_nodegraph.usda"

One mtlx file, with a custom nodedef wrapping an image node

WORKS

MaterialXView --material "C:\matx_tests\wood_onefile_nodedef.mtlx"

FAILS

usdview "C:\matx_tests\wood_onefile_nodedef.usda"
    Warning: in _AddMaterialXNode at line 218 of C:\USD_src\pxr\imaging\hdMtlx\hdMtlx.cpp -- NodeDef not found for Node 'sillyimage_nodedef'

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests
usdview "C:\matx_tests\wood_onefile_nodedef.usda"
    ERROR: Usdview encountered an error while rendering.Child name is not unique: surface_material_node

FAILS

set PXR_USDMTLX_PLUGIN_SEARCH_PATHS=C:\matx_tests
usdview "C:\matx_tests\wood_onefile_nodedef.usda"
    Warning: in _AddMaterialXNode at line 218 of C:\USD_src\pxr\imaging\hdMtlx\hdMtlx.cpp -- NodeDef not found for Node 'sillyimage_nodedef'

Separate material + nodedef files, using an xml include statement

WORKS

MaterialXView --material "C:\matx_tests\wood_twofiles_nodedef_subfolder_include\wood_twofiles_nodedef_subfolder_include-material.mtlx"

FAILS

usdview "C:\matx_tests\wood_twofiles_nodedef_subfolder_include\wood_twofiles_nodedef_subfolder_include.usda"
    Warning: in _AddMaterialXNode at line 218 of C:\USD_src\pxr\imaging\hdMtlx\hdMtlx.cpp -- NodeDef not found for Node 'sillyimage_nodedef'

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\wood_twofiles_nodedef_subfolder_include
usdview "C:\matx_tests\wood_twofiles_nodedef_subfolder_include\wood_twofiles_nodedef_subfolder_include.usda"
    ERROR: Usdview encountered an error while rendering.Child name is not unique: surface_material_node

Separate material + nodedef files (using search-path env vars)

WORKS

set MATERIALX_SEARCH_PATH=C:\matx_tests\wood_twofiles_nodedef_subfolder
MaterialXView --library nodedefs --material "C:\matx_tests\wood_twofiles_nodedef_subfolder\wood_twofiles_nodedef_subfolder-material.mtlx"

(Note that you do need to specify an extra arg, "--library nodedefs", to identify the subfolder on the MATERIALX_SEARCH_PATH.)

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\wood_twofiles_nodedef_subfolder
usdview "C:\matx_tests\wood_twofiles_nodedef_subfolder\wood_twofiles_nodedef_subfolder.usda"
    Warning (secondary thread): in _ConnectPorts at line 881 of C:\USD_src\pxr\usd\plugin\usdMtlx\reader.cpp -- Output for </MaterialX/NodeGraphs/simple_nodegraph.outputs:diffuse_output> missing
    ERROR: Usdview encountered an error while rendering.Child name is not unique: surface_material_node

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\wood_twofiles_nodedef_subfolder\nodedefs
usdview "C:\matx_tests\wood_twofiles_nodedef_subfolder\wood_twofiles_nodedef_subfolder.usda"
    Warning (secondary thread): in _ConnectPorts at line 881 of C:\USD_src\pxr\usd\plugin\usdMtlx\reader.cpp -- Output for </MaterialX/NodeGraphs/simple_nodegraph.outputs:diffuse_output> missing

FAILS

set PXR_USDMTLX_PLUGIN_SEARCH_PATHS=C:\matx_tests\wood_twofiles_nodedef_subfolder
usdview "C:\matx_tests\wood_twofiles_nodedef_subfolder\wood_twofiles_nodedef_subfolder.usda"
    Warning (secondary thread): in _ConnectPorts at line 881 of C:\USD_src\pxr\usd\plugin\usdMtlx\reader.cpp -- Output for </MaterialX/NodeGraphs/simple_nodegraph.outputs:diffuse_output> missing

FAILS

set PXR_USDMTLX_PLUGIN_SEARCH_PATHS=C:\matx_tests\wood_twofiles_nodedef_subfolder\nodedefs
usdview "C:\matx_tests\wood_twofiles_nodedef_subfolder\wood_twofiles_nodedef_subfolder.usda"
    Warning (secondary thread): in _ConnectPorts at line 881 of C:\USD_src\pxr\usd\plugin\usdMtlx\reader.cpp -- Output for </MaterialX/NodeGraphs/simple_nodegraph.outputs:diffuse_output> missing

Separate material + nodedef files (using search-path env vars, with extra folder level for libraries)

WORKS

set MATERIALX_SEARCH_PATH=C:\matx_tests\wood_twofiles_nodedef_subsubfolder\libraries
MaterialXView --library sillylib --material "C:\matx_tests\wood_twofiles_nodedef_subsubfolder\wood_twofiles_nodedef_subsubfolder-material.mtlx"

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\wood_twofiles_nodedef_subsubfolder\libraries
usdview "C:\matx_tests\wood_twofiles_nodedef_subsubfolder\wood_twofiles_nodedef_subsubfolder.usda"
    Warning (secondary thread): in _ConnectPorts at line 881 of C:\USD_src\pxr\usd\plugin\usdMtlx\reader.cpp -- Output for </MaterialX/NodeGraphs/simple_nodegraph.outputs:diffuse_output> missing

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\wood_twofiles_nodedef_subsubfolder\libraries\sillylib
usdview "C:\matx_tests\wood_twofiles_nodedef_subsubfolder\wood_twofiles_nodedef_subsubfolder.usda"
    Warning (secondary thread): in _ConnectPorts at line 881 of C:\USD_src\pxr\usd\plugin\usdMtlx\reader.cpp -- Output for </MaterialX/NodeGraphs/simple_nodegraph.outputs:diffuse_output> missing

Results - Checkerboard Shader Graph

One mtlx file, with one big shader graph

FAILS

usdview "C:\matx_tests\checker_onefile_nodegraph.usda"
    material loads, but just shiny black with no checker (no errors)

WORKS

MaterialXView --material "C:\matx_tests\checker_onefile_nodegraph.mtlx"

One mtlx file, with a custom checkerboard nodedef in it

FAILS

usdview "C:\matx_tests\checker_onefile_nodedef.usda"
    material loads, but just shiny black with no checker (no errors)

WORKS

MaterialXView --material "C:\matx_tests\checker_onefile_nodedef.mtlx"

One mtlx file, with one big shader graph (and declared input)

FAILS

usdview "C:\matx_tests\checker_onefile_nodegraphWithInput.usda"
    material loads, but just shiny black with no checker
    Warning (secondary thread): in _AddInputCommon at line 801 of C:\src\USD\usd_build\USD\src\pxr\usd\plugin\usdMtlx\reader.cpp -- No interface name 'scale' for node 'in2'

WORKS

MaterialXView --material "C:\matx_tests\checker_onefile_nodegraphWithInput.mtlx"

Separate material + nodedef files (using search-path env vars)

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\checker_twofiles_nodedef_subfolder\nodedefs
usdview "C:\matx_tests\checker_twofiles_nodedef_subfolder\checker_twofiles_nodedef_subfolder.usda"
    default material:
        Warning: in _ConnectPorts at line 881 of C:\src\NVIDIA\usd-build\USD\pxr\usd\plugin\usdMtlx\reader.cpp -- Output for </MaterialX/NodeGraphs/wrapper_nodegraph.outputs:diffuse_output> missing

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\checker_twofiles_nodedef_subfolder

WORKS

MaterialXView --library nodedefs --material "C:\matx_tests\checker_twofiles_nodedef_subfolder\checker_twofiles_nodedef_subfolder-material.mtlx"

Separate material + nodedef files (using search-path env vars, with extra folder level for libraries)

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\checker_twofiles_nodedef_subsubfolder
usdview "C:\matx_tests\checker_twofiles_nodedef_subsubfolder\checker_twofiles_nodedef_subsubfolder.usda"
    screen black:
        RuntimeError: Child name is not unique: surface_material_node

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\checker_twofiles_nodedef_subsubfolder\libraries
usdview "C:\matx_tests\checker_twofiles_nodedef_subsubfolder\checker_twofiles_nodedef_subsubfolder.usda"
    default material:
        Warning: in _ConnectPorts at line 881 of C:\src\NVIDIA\usd-build\USD\pxr\usd\plugin\usdMtlx\reader.cpp -- Output for </MaterialX/NodeGraphs/wrapper_nodegraph.outputs:diffuse_output> missing

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\checker_twofiles_nodedef_subsubfolder\libraries\sillylib
usdview "C:\matx_tests\checker_twofiles_nodedef_subsubfolder\checker_twofiles_nodedef_subsubfolder.usda"
    default material:
        Warning: in _ConnectPorts at line 881 of C:\src\NVIDIA\usd-build\USD\pxr\usd\plugin\usdMtlx\reader.cpp -- Output for </MaterialX/NodeGraphs/wrapper_nodegraph.outputs:diffuse_output> missing

FAILS

set MATERIALX_SEARCH_PATH=C:\matx_tests\checker_twofiles_nodedef_subsubfolder\libraries
set PXR_USDMTLX_PLUGIN_SEARCH_PATHS=sillylib
usdview "C:\matx_tests\checker_twofiles_nodedef_subsubfolder\checker_twofiles_nodedef_subsubfolder.usda"
    default material:
        Warning: in _ConnectPorts at line 881 of C:\src\NVIDIA\usd-build\USD\pxr\usd\plugin\usdMtlx\reader.cpp -- Output for </MaterialX/NodeGraphs/wrapper_nodegraph.outputs:diffuse_output> missing

WORKS

set MATERIALX_SEARCH_PATH=C:\matx_tests\checker_twofiles_nodedef_subsubfolder\libraries
MaterialXView --library sillylib --material "C:\matx_tests\checker_twofiles_nodedef_subsubfolder\checker_twofiles_nodedef_subsubfolder-material.mtlx"

Flattening .mtlx into one big .usda (ie, using UsdShade only)

FAILS

:: Generated via:
::   usdcat -f -o "C:\matx_tests\checker_onefile_nodegraph_flat.usda" "C:\matx_tests\checker_onefile_nodegraph.usda"
usdview "C:\matx_tests\checker_onefile_nodegraph_flat.usda"
    material loads, but just shiny black with no checker (no errors)

System Information (OS, Hardware)

Windows

Package Versions

I was using the latest dev branch tip at the time (c1efe0b). (There's been a dev update since then, but nothing that would obviously affect this.)

Build Flags

--materialx

matx_tests.v2.zip

@jilliene
Copy link

jilliene commented Oct 4, 2021

Filed as internal issue #USD-6941

@FlorianZ
Copy link
Contributor

@pmolodo there has been some recent work done to the MaterialX integration. Would you mind confirming that this is still failing for you in the latest release candidate? Thank you!

@pmolodo
Copy link
Contributor Author

pmolodo commented Mar 3, 2022

@FlorianZ - I just retested using the latest dev, ff1e6fd

After changing to try PXR_MTLX_PLUGIN_SEARCH_PATHS and PXR_MTLX_STDLIB_SEARCH_PATHS as environment variables to try altering, results were mostly the same.

In some cases the failure mode was slightly different - ie, in some cases for the checker-material tests, I would get what I described as material loads, but just shiny black with no checker (no errors), whereas before I got some explicit error. So it's possible that something was fixed, but we're hitting a different issue.

Anyway, my full test results are in the attached file...

matx_tests_results_2022-03-02_ff1e6fd7.txt

@klucknav
Copy link
Contributor

klucknav commented Mar 7, 2022

Thank you for all the test cases, and for re-testing them. Unfortunately you are coming across some of the current limitations. Having nodes outside the nodegraph are not supported (Image File - test 1), Interfaces are not supported (Checkerboard - test 3), and support for texcoord nodes while not currently supported will be added shortly (Checkerboard test 1).

The rest of your test cases are playing with custom nodedefs which are unfortunately also not fully supported. Currently, the two mtlx file approach is needed, placing the nodedef.mtlx file where it is not a sibling of the material.mtlx file. If they are siblings HdMtlx will end up including both nodedef.mtlx and material.mtlx in the document it is recreating for the material, and cause the error you saw about the material name not being unique. The nodedef.mtlx file needs to be included in the material.mtlx file, and its path should be indicated with the PXR_MTLX_PLUGIN_SEARCH_PATHS environment variable.

Again custom nodedefs are not fully supported so using textures, or primvars (such as the texcoord node or geomprop nodes) in that custom nodedef will not work in Storm (recent git Issue for this). However, using primvars dose work in HdPrman. In my recent testing it seems like there are some issues maintaining correct connections downstream of a custom node. So it should work if your node/nodedef is directly providing the nodegraph output, and do all the above.

One last thing to mention about your last test case. When you reference a mtlx file in a usda file, that mtlx file will be processed into UsdShade, which is also what happens when you run that same mtlx referencing usda file through usdcat. So I would expect usdview checker_onefile_nodegraph.usda and usdview checker_onefile_nodegraph_flat.usda to have the same result.

Thanks again!

pixar-oss pushed a commit that referenced this issue Mar 13, 2022
pixar-oss pushed a commit that referenced this issue Mar 13, 2022
pixar-oss pushed a commit that referenced this issue Mar 13, 2022
…xture coordinates

See #1636

(Internal change: 2220101)
pixar-oss pushed a commit that referenced this issue Jul 29, 2022
…s defined in libraries

Custom nodes defined in a separate library indicated with the
PXR_MTLX_PLUGIN_SEARCH_PATHS envar that use textures need
to have the 'textureuser' group so that UsdMtlx and hdMtlx know
they use textures and can properly initialize texture coordinates.
Similarly custom nodes that use texcoords need the
'texcoorduser' group. These custom nodes now work in both
Storm and HdPrman.
Changes in hdSt are since custom nodes can name the input for
the file anything instead of 'file' which the stdlib texture nodes use.

Note:
- users need to add 'textureuser' or 'texcoorduser' as the custom node's nodegroup
- need to use the fallback texture coordinates
- cannot use mutliple textures inside one custom node

Fixes #1636
Fixes #1786

(Internal change: 2242208)
pixar-oss pushed a commit that referenced this issue Jul 29, 2022
If material inputs are coming from a node output, we create
a nodegraph around that node as well as any upstream nodes
or other nodes providing connections to different material
inputs. Essentially doing what we previously required the
user to do; contain all nodes that ultimately feed into the
material/surfaceshader nodes, inside a nodegraph.

Fixes #1636

(Internal change: 2242218)
(Internal change: 2242222)
pixar-oss pushed a commit that referenced this issue Jul 29, 2022
…odes that use textures or texcoords.

Fixes #1636

(Internal change: 2242575)
pixar-oss pushed a commit that referenced this issue Jul 29, 2022
pixar-oss pushed a commit that referenced this issue Jul 29, 2022
…oving use of deprecated GetConnectedSource() from FileFormat test

Fixes #1636

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

4 participants