forked from blender/blender
MaterialX: add support for nodes #11
@ -158,6 +158,7 @@ if(WITH_MATERIALX)
|
||||
materialx/nodes/tex_environment.cc
|
||||
materialx/nodes/tex_noise.cc
|
||||
materialx/nodes/tex_checker.cc
|
||||
materialx/nodes/hueSatVal.cc
|
||||
|
||||
materialx/material.h
|
||||
materialx/nodes/node_item.h
|
||||
|
32
source/blender/nodes/shader/materialx/nodes/hueSatVal.cc
Normal file
32
source/blender/nodes/shader/materialx/nodes/hueSatVal.cc
Normal file
@ -0,0 +1,32 @@
|
||||
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "node_parser.h"
|
||||
|
||||
namespace blender::nodes::materialx {
|
||||
|
||||
NodeItem HueSatValNodeParser::compute()
|
||||
{
|
||||
/* TODO: implement fac, see do_hue_sat_fac in source\blender\nodes\texture\nodes\node_texture_hueSatVal.cc */
|
||||
NodeItem hue = get_input_value("Hue");
|
||||
NodeItem saturation = get_input_value("Saturation");
|
||||
NodeItem val = get_input_value("Value");
|
||||
NodeItem fac = get_input_value("Fac");
|
||||
NodeItem color = get_input_value("Color");
|
||||
|
||||
/* Modifier to follow Cycles result */
|
||||
hue = hue - value(0.5f);
|
||||
|
||||
NodeItem combine = create_node("combine3", "vector3");
|
||||
combine.set_input("in1", hue);
|
||||
combine.set_input("in2", saturation);
|
||||
combine.set_input("in3", val);
|
||||
|
||||
NodeItem res = create_node("hsvadjust", "color3", false);
|
||||
res.set_input("in", color.to_color3());
|
||||
res.set_input("amount", combine);
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace blender::nodes::materialx
|
@ -136,6 +136,9 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket)
|
||||
case SH_NODE_TEX_CHECKER:
|
||||
parser = std::make_unique<TexCheckerNodeParser>(graph, depsgraph, material, in_node);
|
||||
break;
|
||||
case SH_NODE_HUE_SAT:
|
||||
parser = std::make_unique<HueSatValNodeParser>(graph, depsgraph, material, in_node);
|
||||
break;
|
||||
default:
|
||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported node: %s (%d)", in_node->name, in_node->type);
|
||||
return res;
|
||||
|
@ -68,5 +68,6 @@ DECLARE_PARSER(TexCheckerNodeParser)
|
||||
DECLARE_PARSER(TexEnvironmentNodeParser)
|
||||
DECLARE_PARSER(TexImageNodeParser)
|
||||
DECLARE_PARSER(TexNoiseNodeParser)
|
||||
DECLARE_PARSER(HueSatValNodeParser)
|
||||
|
||||
} // namespace blender::nodes::materialx
|
||||
|
Loading…
Reference in New Issue
Block a user