Skip to content

Commit

Permalink
ARNOLD-14286 Add back support for using BSDF as shader graph outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienHerubel committed Dec 21, 2023
1 parent 45a1d72 commit 2b8bbb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions source/MaterialXGenOsl/OslShaderGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ ShaderPtr OslShaderGenerator::generate(const string& name, ElementPtr element, G
emitLine("output closure color " + singleOutput->getVariable() + " = 0", stage, false);
}
#ifdef MATERIALX_OSL_LEGACY_CLOSURES
else if (isBsdfOutput)
else if (isBsdfOutput && context.getOptions().wrapBSDFAsClosureGraphOutput)
{
// Special case for having 'BSDF' as final output type.
// For legacy closures this type is a struct internally (response, throughput, thickness, ior)
Expand Down Expand Up @@ -330,7 +330,7 @@ ShaderPtr OslShaderGenerator::generate(const string& name, ElementPtr element, G
emitScopeEnd(stage);
}
#ifdef MATERIALX_OSL_LEGACY_CLOSURES
else if (isBsdfOutput)
else if (isBsdfOutput && context.getOptions().wrapBSDFAsClosureGraphOutput)
{
// Special case for having 'BSDF' as final output type.
// For legacy closures this type is a struct internally (response, throughput, thickness, ior)
Expand Down
6 changes: 5 additions & 1 deletion source/MaterialXGenShader/GenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class MX_GENSHADER_API GenOptions
hwWriteAlbedoTable(false),
hwImplicitBitangents(true),
emitColorTransforms(true),
elideConnectedConstants(true)
elideConnectedConstants(true),
wrapBSDFAsClosureGraphOutput(true)
{
}
virtual ~GenOptions() { }
Expand Down Expand Up @@ -186,6 +187,9 @@ class MX_GENSHADER_API GenOptions
/// Enable eliding connected constants, setting this option to true
/// breaks shader generation for arnold-usd. Defaults to true.
bool elideConnectedConstants;

// Enable exporting OSL BSDFs as closures in graph outputs
bool wrapBSDFAsClosureGraphOutput;
};

MATERIALX_NAMESPACE_END
Expand Down

0 comments on commit 2b8bbb6

Please sign in to comment.