Blender V4.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
9#include "node_shader_util.hh"
10
12
14{
15 b.add_input<decl::Float>("Hue").default_value(0.5f).min(0.0f).max(1.0f).description(
16 "Hue rotation offset, from 0 (-180°) to 1 (+180°). Note that 0 and 1 have the same result");
17 b.add_input<decl::Float>("Saturation")
18 .default_value(1.0f)
19 .min(0.0f)
20 .max(2.0f)
22 "Value of 0 removes color from the image, making it black-and-white. "
23 "A value greater than 1.0 increases saturation");
24 b.add_input<decl::Float>("Value")
25 .default_value(1.0f)
26 .min(0.0f)
27 .max(2.0f)
29 .description(
30 "Value shift. 0 makes the color black, 1 keeps it the same, and higher values make it "
31 "brighter");
32 b.add_input<decl::Float>("Fac")
33 .default_value(1.0f)
34 .min(0.0f)
35 .max(1.0f)
37 .description("Amount of influence the node exerts on the image");
38 b.add_input<decl::Color>("Color")
39 .default_value({0.8f, 0.8f, 0.8f, 1.0f})
40 .description("Color input on which HSV color transformation will be applied");
41 b.add_output<decl::Color>("Color");
42}
43
45 bNode *node,
46 bNodeExecData * /*execdata*/,
47 GPUNodeStack *in,
48 GPUNodeStack *out)
49{
50 return GPU_stack_link(mat, node, "hue_sat", in, out);
51}
52
54#ifdef WITH_MATERIALX
55{
56 NodeItem hue = get_input_value("Hue", NodeItem::Type::Float);
57 NodeItem saturation = get_input_value("Saturation", NodeItem::Type::Float);
58 NodeItem value = get_input_value("Value", NodeItem::Type::Float);
59 NodeItem fac = get_input_value("Fac", NodeItem::Type::Float);
60 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
61
62 /* Modifier to follow Cycles result */
63 hue = hue - val(0.5f);
64
65 NodeItem combine = create_node(
66 "combine3", NodeItem::Type::Vector3, {{"in1", hue}, {"in2", saturation}, {"in3", value}});
67
68 NodeItem hsv = create_node(
69 "hsvadjust", NodeItem::Type::Color3, {{"in", color}, {"amount", combine}});
70
71 return fac.mix(color, hsv);
72}
73#endif
75
76} // namespace blender::nodes::node_shader_hueSatVal_cc
77
79{
81
82 static blender::bke::bNodeType ntype;
83
84 sh_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue/Saturation/Value", NODE_CLASS_OP_COLOR);
85 ntype.declare = file_ns::node_declare;
87 ntype.gpu_fn = file_ns::gpu_shader_hue_sat;
88 ntype.materialx_fn = file_ns::node_shader_materialx;
89
91}
#define SH_NODE_HUE_SAT
Definition BKE_node.hh:911
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:406
#define BLT_I18NCONTEXT_COLOR
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ PROP_FACTOR
Definition RNA_types.hh:154
local_group_size(16, 16) .push_constant(Type b
void node_type_size_preset(bNodeType *ntype, eNodeSizePreset size)
Definition node.cc:4614
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static int gpu_shader_hue_sat(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_hue_sat()
void sh_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
Defines a node type.
Definition BKE_node.hh:218
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:320
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
NodeDeclareFunction declare
Definition BKE_node.hh:347