-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,8 +230,8 @@ HdStMaterialXShaderGen::_EmitMxFunctions( | |
mx::ShaderStage& mxStage) const | ||
{ | ||
// Add global constants and type definitions | ||
emitInclude("pbrlib/" + mx::GlslShaderGenerator::TARGET | ||
+ "/lib/mx_defines.glsl", mxContext, mxStage); | ||
emitInclude("stdlib/" + mx::GlslShaderGenerator::TARGET | ||
+ "/lib/mx_math.glsl", mxContext, mxStage); | ||
emitLine("#if NUM_LIGHTS > 0", mxStage, false); | ||
emitLine("#define MAX_LIGHT_SOURCES NUM_LIGHTS", mxStage, false); | ||
emitLine("#else", mxStage, false); | ||
|
@@ -343,11 +343,6 @@ HdStMaterialXShaderGen::_EmitMxFunctions( | |
_EmitMxInitFunction(vertexData, mxStage); | ||
} | ||
|
||
// Emit common math functions | ||
emitInclude("pbrlib/" + mx::GlslShaderGenerator::TARGET | ||
+ "/lib/mx_math.glsl", mxContext, mxStage); | ||
emitLineBreak(mxStage); | ||
|
||
// Emit lighting and shadowing code | ||
if (lighting) { | ||
emitSpecularEnvironment(mxContext, mxStage); | ||
|
@@ -384,6 +379,9 @@ HdStMaterialXShaderGen::_EmitMxFunctions( | |
emitInclude(ShaderGenerator::T_FILE_TRANSFORM_UV, mxContext, mxStage); | ||
} | ||
|
||
// Add light sampling functions | ||
emitLightFunctionDefinitions(mxGraph, mxContext, mxStage); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
// Add all functions for node implementations | ||
emitFunctionDefinitions(mxGraph, mxContext, mxStage); | ||
} | ||
|
@@ -405,7 +403,8 @@ HdStMaterialXShaderGen::_EmitMxSurfaceShader( | |
emitLine("mxInit(Peye, Neye)", mxStage); | ||
|
||
const mx::ShaderGraphOutputSocket* outputSocket = mxGraph.getOutputSocket(); | ||
if (mxGraph.hasClassification(mx::ShaderNode::Classification::CLOSURE)) { | ||
if (mxGraph.hasClassification(mx::ShaderNode::Classification::CLOSURE) && | ||
!mxGraph.hasClassification(mx::ShaderNode::Classification::SHADER)) { | ||
// Handle the case where the mxGraph is a direct closure. | ||
// We don't support rendering closures without attaching | ||
// to a surface shader, so just output black. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,8 @@ pxr_plugin(usdMtlx | |
usdShade | ||
usdUI | ||
usdUtils | ||
${MATERIALX_LIBRARIES} | ||
|
||
INCLUDE_DIRS | ||
${MATERIALX_INCLUDE_DIRS} | ||
MaterialXCore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
MaterialXFormat | ||
|
||
CPPFILES | ||
debugCodes.cpp | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,7 @@ _FindMatchingNodeDef( | |
const mx::ConstDocumentPtr& mtlxDocument, | ||
const mx::ConstInterfaceElementPtr& mtlxInterface, | ||
const std::string& family, | ||
const std::string& type, | ||
const NdrVersion& version, | ||
const std::string& target) | ||
{ | ||
|
@@ -289,7 +290,11 @@ _FindMatchingNodeDef( | |
} | ||
|
||
// Filter by types. | ||
if (mtlxInterface && !mtlxInterface->isTypeCompatible(mtlxNodeDef)) { | ||
if (mtlxInterface && !mtlxInterface->hasExactInputMatch(mtlxNodeDef)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
continue; | ||
} | ||
|
||
if (mtlxNodeDef->getType() != type) { | ||
continue; | ||
} | ||
|
||
|
@@ -336,6 +341,7 @@ _FindMatchingNodeDef( | |
auto nodeDef = _FindMatchingNodeDef(mtlxShaderNode->getDocument(), | ||
mtlxInterface, | ||
mtlxShaderNode->getCategory(), | ||
mtlxShaderNode->getType(), | ||
UsdMtlxGetVersion(mtlxShaderNode), | ||
mtlxShaderNode->getTarget()); | ||
if (nodeDef) { | ||
|
@@ -344,9 +350,18 @@ _FindMatchingNodeDef( | |
|
||
// Get the standard library document and check that. | ||
static auto standardLibraryDocument = UsdMtlxGetDocument(""); | ||
|
||
if (mtlxShaderNode->hasNodeDefString()) { | ||
nodeDef = standardLibraryDocument->getNodeDef(mtlxShaderNode->getNodeDefString()); | ||
if (nodeDef) { | ||
return nodeDef; | ||
} | ||
} | ||
|
||
return _FindMatchingNodeDef(standardLibraryDocument, | ||
mtlxInterface, | ||
mtlxShaderNode->getCategory(), | ||
mtlxShaderNode->getType(), | ||
UsdMtlxGetVersion(mtlxShaderNode), | ||
mtlxShaderNode->getTarget()); | ||
} | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 . There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
// The shaderNode specified a node instead of a nodeDef. Find | ||
// the best matching nodedef since the MaterialX API doesn't. | ||
mtlxNodeDef = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,7 +297,7 @@ _ReadFromAsset(mx::DocumentPtr doc, const ArResolvedPath& resolvedPath, | |
newReadOptions); | ||
}; | ||
|
||
mx::readFromXmlString(doc, s, &readOptions); | ||
mx::readFromXmlString(doc, s, searchPath, &readOptions); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just updating to the latest API. No behavior change. |
||
} | ||
#endif | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,14 @@ endif() | |
set(optionalIncludeDirs "") | ||
set(optionalPublicClasses "") | ||
if (${PXR_ENABLE_MATERIALX_SUPPORT}) | ||
list(APPEND optionalLibs ${MATERIALX_LIBRARIES} hdMtlx) | ||
list(APPEND optionalIncludeDirs ${MATERIALX_INCLUDE_DIRS}) | ||
list(APPEND optionalLibs | ||
MaterialXCore | ||
MaterialXFormat | ||
MaterialXGenShader | ||
MaterialXGenOsl | ||
MaterialXRender | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious as to why there is a dependence on MaterialXRender ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I grepped for |
||
hdMtlx | ||
) | ||
list(APPEND optionalPublicClasses matfiltMaterialX) | ||
|
||
if (${PXR_ENABLE_OSL_SUPPORT}) | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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