forked from blender/blender
MaterialX: add convert nodes #15
@ -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
|
||||
|
23
source/blender/nodes/shader/materialx/nodes/clamp.cc
Normal file
23
source/blender/nodes/shader/materialx/nodes/clamp.cc
Normal 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
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user