From cdfd6040fbe7e6f6a4decb1cd5887a7d0523a2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Delgado=20Kr=C3=A4mer?= Date: Thu, 30 May 2024 11:31:25 +0200 Subject: [PATCH] Fix wrong assumption that vector3 type is converted trivially --- source/MaterialXCore/Version.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/MaterialXCore/Version.cpp b/source/MaterialXCore/Version.cpp index 203d7b13d7..26ea1edef6 100644 --- a/source/MaterialXCore/Version.cpp +++ b/source/MaterialXCore/Version.cpp @@ -1311,21 +1311,23 @@ void Document::upgradeVersion() } else if (nodeCategory == "subsurface_bsdf") { - InputPtr radiusInput = node->getInput("radius"); + InputPtr radiusInput = node->getActiveInput("radius"); if (radiusInput) { - NodePtr connectedNode = radiusInput->getConnectedNode(); - if (connectedNode) + if (NodePtr connectedNode = radiusInput->getConnectedNode(); connectedNode) { GraphElementPtr graph = node->getAncestorOfType(); + NodePtr convertNode = graph->addNode("convert", graph->createValidChildName("convert"), "color3"); InputPtr inInput = convertNode->addInput("in", "vector3"); + inInput->setConnectedNode(connectedNode); radiusInput->setConnectedNode(convertNode); } - else + else if (ValuePtr value = radiusInput->getValue(); value && value->isA()) { - // vector3 value is trivially convertible + Vector3 v = value->asA(); + radiusInput->setValue(Color3(v[0], v[1], v[2])); } radiusInput->setType("color3");