MaterialX: add convert nodes #15

Merged
Bogdan Nagirniak merged 8 commits from matx-add-convert-nodes into matx-export-material 2023-09-08 16:55:00 +02:00
4 changed files with 26 additions and 0 deletions
Showing only changes of commit 5a5dd1201f - Show all commits

View File

@ -150,6 +150,7 @@ if(WITH_MATERIALX)
materialx/nodes/blackbody.cc
materialx/nodes/brightness.cc
materialx/nodes/bsdf_principled.cc
materialx/nodes/clamp.cc
materialx/nodes/huesatval.cc
materialx/nodes/invert.cc
materialx/nodes/math.cc

View File

@ -0,0 +1,23 @@
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "node_parser.h"
namespace blender::nodes::materialx {
NodeItem ClampNodeParser::compute()
{
auto type = node_->custom1;
NodeItem value = get_input_value("Value", NodeItem::Type::Float);
NodeItem min = get_input_value("Min", NodeItem::Type::Float);
NodeItem max = get_input_value("Max", NodeItem::Type::Float);
if (type == NODE_CLAMP_MINMAX) {
min = min.if_else(NodeItem::CompareOp::Greater, max, max, min);
}
return value.clamp(min, max);
}
} // namespace blender::nodes::materialx

View File

@ -135,6 +135,7 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket)
CASE_NODE_TYPE(SH_NODE_BLACKBODY, BlackbodyNodeParser)
CASE_NODE_TYPE(SH_NODE_BRIGHTCONTRAST, BrightContrastNodeParser)
CASE_NODE_TYPE(SH_NODE_BSDF_PRINCIPLED, BSDFPrincipledNodeParser)
CASE_NODE_TYPE(SH_NODE_CLAMP, ClampNodeParser)
CASE_NODE_TYPE(SH_NODE_COMBINE_COLOR, CombineColorNodeParser)
CASE_NODE_TYPE(SH_NODE_COMBXYZ, CombineXYZNodeParser)
CASE_NODE_TYPE(SH_NODE_HUE_SAT, HueSatValNodeParser)

View File

@ -66,6 +66,7 @@ template<class T> NodeItem NodeParser::value(const T &data) const
DECLARE_PARSER(BlackbodyNodeParser)
DECLARE_PARSER(BrightContrastNodeParser)
DECLARE_PARSER(BSDFPrincipledNodeParser)
DECLARE_PARSER(ClampNodeParser)
DECLARE_PARSER(CombineColorNodeParser)
DECLARE_PARSER(CombineXYZNodeParser)
DECLARE_PARSER(HueSatValNodeParser)