diff --git a/ndr/parser.cpp b/ndr/parser.cpp index 7d72e23d3a..d38f1ddcef 100644 --- a/ndr/parser.cpp +++ b/ndr/parser.cpp @@ -55,6 +55,7 @@ NDR_REGISTER_PARSER_PLUGIN(NdrArnoldParserPlugin); TF_DEFINE_PRIVATE_TOKENS(_tokens, (arnold) ((arnoldPrefix, "arnold:")) + ((outputsPrefix, "outputs:")) (binary)); // clang-format on @@ -119,8 +120,12 @@ NdrNodeUniquePtr NdrArnoldParserPlugin::Parse(const NdrNodeDiscoveryResult& disc properties.reserve(props.size()); for (const auto& property : props) { const auto& propertyName = property.GetName(); + + // check if this attribute is an output #1121 + bool isOutput = TfStringStartsWith(propertyName, _tokens->outputsPrefix); + // In case `info:id` is set on the nodes. - if (TfStringContains(propertyName.GetString(), ":")) { + if (!isOutput && TfStringContains(propertyName.GetString(), ":")) { continue; } const auto propertyStack = property.GetPropertyStack(); @@ -138,13 +143,14 @@ NdrNodeUniquePtr NdrArnoldParserPlugin::Parse(const NdrNodeDiscoveryResult& disc propertyName, // name attr.GetTypeName(), // typeName v, // defaultValue - false, // isOutput + isOutput, // isOutput 0, // arraySize - NdrTokenMap(), // metadata - NdrTokenMap(), // hints - NdrOptionVec() // options + NdrTokenMap(), // metadata + NdrTokenMap(), // hints + NdrOptionVec() // options })); } + return NdrNodeUniquePtr(new SdrShaderNode( discoveryResult.identifier, // identifier discoveryResult.version, // version diff --git a/ndr/utils.cpp b/ndr/utils.cpp index 78e3a6c3c0..44d9f99d16 100644 --- a/ndr/utils.cpp +++ b/ndr/utils.cpp @@ -50,6 +50,8 @@ PXR_NAMESPACE_OPEN_SCOPE // clang-format off TF_DEFINE_PRIVATE_TOKENS(_tokens, ((filename, "arnold:filename")) + ((output, "outputs:out")) + ); // clang-format on @@ -339,6 +341,16 @@ void _ReadArnoldShaderDef(UsdPrim& prim, const AtNodeEntry* nodeEntry) const auto filename = AiNodeEntryGetFilename(nodeEntry); prim.SetMetadata(_tokens->filename, VtValue(TfToken(filename == nullptr ? "" : filename))); + + // For shaders, we want to add an attribute for the output type + // FIXME : add support for multiple outputs + if (AiNodeEntryGetType(nodeEntry) == AI_NODE_SHADER) { + const auto* conversion = _GetDefaultValueConversion(AiNodeEntryGetOutputType(nodeEntry)); + if (conversion != nullptr) { + prim.CreateAttribute(_tokens->output, conversion->type, false); + } + } + auto paramIter = AiNodeEntryGetParamIterator(nodeEntry); while (!AiParamIteratorFinished(paramIter)) {