Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions source/MaterialXGenMdl/Nodes/CustomNodeMdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ void CustomCodeNodeMdl::initializeForInlineSourceCode(const InterfaceElement& el

NodeDefPtr nodeDef = impl.getNodeDef();
_inlineFunctionName = nodeDef->getName();
_hash = std::hash<string>{}(_inlineFunctionName); // make sure we emit the function definition only once

const ShaderGenerator& shadergen = context.getShaderGenerator();
const MdlSyntax& syntax = static_cast<const MdlSyntax&>(shadergen.getSyntax());
syntax.makeValidName(_inlineFunctionName);
_hash = std::hash<string>{}(_inlineFunctionName); // make sure we emit the function definition only once
// Construct the function call template string
initializeFunctionCallTemplateString(syntax, *nodeDef);
// Collect information about output names and defaults
Expand Down Expand Up @@ -248,7 +249,14 @@ void CustomCodeNodeMdl::emitFunctionDefinition(const ShaderNode& node, GenContex

// User defined code
shadergen.emitComment("inlined shader source code:", stage);
shadergen.emitLine(_inlineSourceCode, stage, false);
if (numOutputs == 1)
{
shadergen.emitLine(outputs.back().name + " = " + _inlineSourceCode, stage);
}
else
{
shadergen.emitLine(_inlineSourceCode, stage, false);
}

// Output packing
shadergen.emitComment("pack (in case of multiple outputs) and return outputs:", stage);
Expand Down
3 changes: 3 additions & 0 deletions source/MaterialXTest/MaterialXGenMdl/GenMdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ void MdlShaderGeneratorTester::compileSource(const std::vector<mx::FilePath>& so
// avoid warning "C350: unused let temporary '...'"
mdlcCommand += " -W \"350=off\"";

// avoid warning "C181: unused variable '...'"
mdlcCommand += " -W \"181=off\"";

// but treat all other warnings as errors
mdlcCommand += " -W err";

Expand Down
Loading