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

Update to MaterialX v1.38.3 #1738

Conversation

kxl-adsk
Copy link
Contributor

  • Use CMake config directly from MaterialX install
  • Update for API and library changes in v1.38.3
  • Strengthen NodeDef discovery

This is the last update that is not version tagged in the C++ code.
Future updates will be bracketed using MATERIALX_MINOR_VERSION defines
introduced in v1.38.3.

- Use CMake config directly from MaterialX install
- Update for API and library changes in v1.38.3
- Strenghten NodeDef discovery

This is the last update that is not version tagged in the C++ code.
Future updates will be bracketed using MATERIALX_MINOR_VERSION defines
introduced in v1.38.3.
@@ -384,6 +379,9 @@ HdStMaterialXShaderGen::_EmitMxFunctions(
emitInclude(ShaderGenerator::T_FILE_TRANSFORM_UV, mxContext, mxStage);
}

// Add light sampling functions
emitLightFunctionDefinitions(mxGraph, mxContext, mxStage);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a check here to see if needed: The albedo table initiation was affected by light refactoring and this fixes it. be0d3d65727ad343eaf469e9c179f772d31a9be2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storm has its own dome light functions (see line 531) and does not use the MaterialX albedo table. Adding this was necessary to get access to scene light functions. So no check required.


INCLUDE_DIRS
${MATERIALX_INCLUDE_DIRS}
MaterialXCore

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why explicit library names are now used vs ${MATEIALX_LIBRARIES}. Will this affect users which use more than the
explicitly specified library currently ?
(This appears to be done in a few build configurations).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It allows linking only the libraries that are in use instead of all libraries.
Also, with this modern CMake implementation, the required include dirs (and also the required compiler definitions) gets added on a per-library basis.

@@ -1284,7 +1299,7 @@ _Context::AddShaderNode(const mx::ConstNodePtr& mtlxShaderNode)

// Get the nodeDef for this shaderNode.
mx::ConstNodeDefPtr mtlxNodeDef = mtlxShaderNode->getNodeDef();
if (mtlxShaderNode->getNodeDefString().empty()) {
if (!mtlxNodeDef) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to double check here that this handles finding the / associations found on .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context: at this exact point in the code, the MaterialX library has not been loaded. This means that a node that has a NodeDef string will fail to resolve, and previously would not be tried again. Changing the test to retry when the NodeDef was not found allows trying a second time to find the NodeDef using the string, but this time with libraries loaded.

MaterialXFormat
MaterialXGenShader
MaterialXGenOsl
MaterialXRender

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious as to why there is a dependence on MaterialXRender ?
Generally I would assume this is not required.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I grepped for #include <MaterialX in the code and added what was found. In this case, I saw one MaterialXRender include being accessed.

@@ -289,7 +290,11 @@ _FindMatchingNodeDef(
}

// Filter by types.
if (mtlxInterface && !mtlxInterface->isTypeCompatible(mtlxNodeDef)) {
if (mtlxInterface && !mtlxInterface->hasExactInputMatch(mtlxNodeDef)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a query: This assumes the latest API. I'm curious if code which handles multiple versions is not desirable e.g. if version preprocessor statements ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires knowing which version of MaterialX is in use and that can only be done starting with MaterialX v1.38.3.
I fully expect that submitting code that handles multiple versions will be the default for all future PRs.


cmakeOptions += buildArgs;

if "v1.38.3.zip" in MATERIALX_URL:
# This will be fixed in v1.38.4:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps comment that this is for when Python is not required.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default in USD is to build MaterialX without Python. This is how I found the fix was required.
I could possibly add a comment pointing to the fix if requested: autodesk-forks/MaterialX#1344
And the fix for CMake relocability: autodesk-forks/MaterialX#1350
That were both merged in ILM repo via: AcademySoftwareFoundation/MaterialX#805

@@ -297,7 +297,7 @@ _ReadFromAsset(mx::DocumentPtr doc, const ArResolvedPath& resolvedPath,
newReadOptions);
};

mx::readFromXmlString(doc, s, &readOptions);
mx::readFromXmlString(doc, s, searchPath, &readOptions);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this purely to update the API, or will there be any behaviour change here.
If syntatical then should this instead be an empty search path ? Seems passing
searchPath is correct though. Just wondering.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just updating to the latest API. No behavior change.

@JGamache-autodesk
Copy link
Contributor

Github decided to fail all builds done in Windows 2016 VMs: actions/runner-images#4312
Fixing this will require upgrading the azure-pipelines.yaml and azure-pypi-pipelines.yaml files to use the windows-2019 VM which implies VS2019 instead of VS2017.

@jilliene
Copy link

Filed as internal issue #USD-7129

@spiffmon
Copy link
Member

spiffmon commented Mar 4, 2022

Closing, per @seando-adsk , in favor of PR #1792

@spiffmon spiffmon closed this Mar 4, 2022
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

Successfully merging this pull request may close these issues.

5 participants