Blender V5.3
node_shader_hueSatVal.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2006 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "node_shader_util.hh"
10
11namespace blender {
12
14
16{
17 b.add_input<decl::Float>("Hue"_ustr)
18 .default_value(0.5f)
19 .min(0.0f)
20 .max(1.0f)
22 "Hue rotation offset, from 0 (-180°) to 1 (+180°). Note that 0 and 1 have the same "
23 "result");
24 b.add_input<decl::Float>("Saturation"_ustr)
25 .default_value(1.0f)
26 .min(0.0f)
27 .max(2.0f)
29 "Value of 0 removes color from the image, making it black-and-white. "
30 "A value greater than 1.0 increases saturation");
31 b.add_input<decl::Float>("Value"_ustr)
32 .default_value(1.0f)
33 .min(0.0f)
34 .max(2.0f)
36 .description(
37 "Value shift. 0 makes the color black, 1 keeps it the same, and higher values make it "
38 "brighter");
39 b.add_input<decl::Float>("Factor"_ustr, "Fac"_ustr)
40 .default_value(1.0f)
41 .min(0.0f)
42 .max(1.0f)
44 .description("Amount of influence the node exerts on the image");
45 b.add_input<decl::Color>("Color"_ustr)
46 .default_value({0.8f, 0.8f, 0.8f, 1.0f})
47 .description("Color input on which HSV color transformation will be applied");
48 b.add_output<decl::Color>("Color"_ustr);
49}
50
52 bNode *node,
53 bNodeExecData * /*execdata*/,
56{
57 return GPU_stack_link(mat, node, "hue_sat", in, out);
58}
59
61#ifdef WITH_MATERIALX
62{
63 NodeItem hue = get_input_value("Hue", NodeItem::Type::Float);
64 NodeItem saturation = get_input_value("Saturation", NodeItem::Type::Float);
65 NodeItem value = get_input_value("Value", NodeItem::Type::Float);
66 NodeItem fac = get_input_value("Fac", NodeItem::Type::Float);
67 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
68
69 /* Modifier to follow Cycles result */
70 hue = hue - val(0.5f);
71
72 NodeItem combine = create_node(
73 "combine3", NodeItem::Type::Vector3, {{"in1", hue}, {"in2", saturation}, {"in3", value}});
74
75 NodeItem hsv = create_node(
76 "hsvadjust", NodeItem::Type::Color3, {{"in", color}, {"amount", combine}});
77
78 return fac.mix(color, hsv);
79}
80#endif
82
83} // namespace nodes::node_shader_hueSatVal_cc
84
86{
87 namespace file_ns = nodes::node_shader_hueSatVal_cc;
88
89 static bke::bNodeType ntype;
90
91 sh_node_type_base(&ntype, "ShaderNodeHueSaturation"_ustr, SH_NODE_HUE_SAT);
92 ntype.ui_name = "Hue/Saturation/Value";
93 ntype.ui_description = "Apply a color transformation in the HSV color model";
94 ntype.enum_name_legacy = "HUE_SAT";
96 ntype.declare = file_ns::node_declare;
98 ntype.gpu_fn = file_ns::gpu_shader_hue_sat;
99 ntype.materialx_fn = file_ns::node_shader_materialx;
100
102}
103
104} // namespace blender
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:480
#define SH_NODE_HUE_SAT
#define BLT_I18NCONTEXT_COLOR
std::optional< std::string > translation_context
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static int gpu_shader_hue_sat(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
BMesh Iterators.
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void register_node_type_sh_hue_sat()
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
@ PROP_FACTOR
Definition RNA_types.hh:308
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
static constexpr int _160
Definition BKE_node.hh:246
Defines a node type.
Definition BKE_node.hh:265
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:375
std::string ui_description
Definition BKE_node.hh:271
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:373
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393