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 search paths are unstable not relocatable and code gen breaks when relocating libraries #1586

Closed
dlarsson-adobe opened this issue Aug 6, 2021 · 1 comment

Comments

@dlarsson-adobe
Copy link

Description of Issue

When building with materialx the full path to the materialx libraries directory is burned into the build making it hard to relocate a build to a different location.
There seems to be a number of environment variables to allow user defined materialx search paths (PXR_USDMTLX_STDLIB_SEARCH_PATHS, PXR_USDMTLX_PLUGIN_SEARCH_PATHS and MATERIALX_SEARCH_PATH are my candidates) but non of them seem to work fully regardless how I set them.
When properly setting PXR_USDMTLX_STDLIB_SEARCH_PATHS to the library the translation mtlx graphs to USD seems to work but when trying to render the results in hydra storm I get a number of issues along this line:

ERROR: Usdview encountered an error while rendering.Could not find a nodedef for shader node 'SR_M_BrickPattern
Warning: in _GetMxNodeType at line 52 of D:\work\code\current\USD\pxr\imaging\hdMtlx\hdMtlx.cpp -- Unsupported node type 'ND_standard_surface_surfaceshader' cannot find the associated NodeDef.
Warning: in _AddMaterialXNode at line 218 of D:\work\code\current\USD\pxr\imaging\hdMtlx\hdMtlx.cpp -- NodeDef not found for Node 'ND_normalmap'
Warning: in HdMtlxCreateMtlxDocumentFromHdNetwork at line 421 of D:\work\code\current\USD\pxr\imaging\hdMtlx\hdMtlx.cpp -- Validation warnings for generated MaterialX file.
Node element is missing a category: < name="SR_M_BrickPattern" type="surfaceshader">

My ideal solution to this problem is looking up the libraries directory relative to something that is stable when relocating the build rather than relying on environment variables for the default case, I'm not sure what the right solution would be but it would make sense to put it among the resources for the materialx plugin rather than in the global libraries directory for the build and avoid burning in this path in the executable but looking it up relative to the plugin loaded.

With that said, it would also be great if I could get these search paths to work so I can work around the issue for now.

Steps to Reproduce

  1. Build Usd with MaterialX
  2. Rename the libraries directory in your Usd installation location (to simulate a relocated build). In my example I will call it libraries2
  3. Set PXR_USDMTLX_STDLIB_SEARCH_PATHS environment variable to the new libraries location
  4. Run usdview with cone.usda in the attached file and see the error messages

I have tried to point PXR_USDMTLX_STDLIB_SEARCH_PATHS and PXR_USDMTLX_PLUGIN_SEARCH_PATHS to a number of different locations without success but it might still be a user error on my side.

search_path_issue.zip

System Information (OS, Hardware)

Windows 10 x64

Package Versions

USD 21.08

Build Flags

--MaterialX

@jilliene
Copy link

jilliene commented Aug 6, 2021

Filed as internal issue #USD-6824

pixar-oss pushed a commit that referenced this issue Nov 16, 2021
UsdMtlx uses the two environment variables PXR_USDMTLX_STDLIB_SEARCH_PATHS and
PXR_USDMTLX_PUGIN_SEARCH_PATHS for the user to specify where to find the necessary
MaterialX files. The imaging side does not do this. This change adds that behavior to HdMtlx.
So now, if the location of the MaterialX provided libraries folder changes from the location
originally found at runtime (stored in PXR_MATERIALX_STDLIB_DIR) the new location(s)
can be indicated with PXR_MTLX_STDLIB_SEARCH_PATHS. The location(s) to any custom
MaterialX files can be indicated with PXR_MTLX_PLUGIN_SEARCH_PATHS.

(Based on GitHub PR #1628 by @vlasovi)

Fixes #1586

(Internal change: 2197997)
lkerley pushed a commit to imageworks/USD that referenced this issue Jan 7, 2022
UsdMtlx uses the two environment variables PXR_USDMTLX_STDLIB_SEARCH_PATHS and
PXR_USDMTLX_PUGIN_SEARCH_PATHS for the user to specify where to find the necessary
MaterialX files. The imaging side does not do this. This change adds that behavior to HdMtlx.
So now, if the location of the MaterialX provided libraries folder changes from the location
originally found at runtime (stored in PXR_MATERIALX_STDLIB_DIR) the new location(s)
can be indicated with PXR_MTLX_STDLIB_SEARCH_PATHS. The location(s) to any custom
MaterialX files can be indicated with PXR_MTLX_PLUGIN_SEARCH_PATHS.

(Based on GitHub PR PixarAnimationStudios#1628 by @vlasovi)

Fixes PixarAnimationStudios#1586

(Internal change: 2197997)
seando-adsk pushed a commit to autodesk-forks/USD that referenced this issue Mar 1, 2024
UsdMtlx uses the two environment variables PXR_USDMTLX_STDLIB_SEARCH_PATHS and
PXR_USDMTLX_PUGIN_SEARCH_PATHS for the user to specify where to find the necessary
MaterialX files. The imaging side does not do this. This change adds that behavior to HdMtlx.
So now, if the location of the MaterialX provided libraries folder changes from the location
originally found at runtime (stored in PXR_MATERIALX_STDLIB_DIR) the new location(s)
can be indicated with PXR_MTLX_STDLIB_SEARCH_PATHS. The location(s) to any custom
MaterialX files can be indicated with PXR_MTLX_PLUGIN_SEARCH_PATHS.

(Based on GitHub PR PixarAnimationStudios#1628 by @vlasovi)

Fixes PixarAnimationStudios#1586

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