Blender V4.3
node_texture_combine_color.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BLI_listbase.h"
10#include "BLI_math_color.h"
11#include "NOD_texture.h"
12#include "node_texture_util.hh"
13#include "node_util.hh"
14
16 {SOCK_FLOAT, N_("Red"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
17 {SOCK_FLOAT, N_("Green"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
18 {SOCK_FLOAT, N_("Blue"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
19 {SOCK_FLOAT, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
20 {-1, ""},
21};
23 {SOCK_RGBA, N_("Color")},
24 {-1, ""},
25};
26
27static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
28{
29 int i;
30 for (i = 0; i < 4; i++) {
31 out[i] = tex_input_value(in[i], p, thread);
32 }
33 /* Apply color space if required. */
34 switch (node->custom1) {
36 /* Pass */
37 break;
38 }
40 hsv_to_rgb_v(out, out);
41 break;
42 }
44 hsl_to_rgb_v(out, out);
45 break;
46 }
47 default: {
49 break;
50 }
51 }
52}
53
54static void update(bNodeTree * /*ntree*/, bNode *node)
55{
56 node_combsep_color_label(&node->inputs, (NodeCombSepColorMode)node->custom1);
57}
58
59static void exec(void *data,
60 int /*thread*/,
61 bNode *node,
62 bNodeExecData *execdata,
63 bNodeStack **in,
64 bNodeStack **out)
65{
66 tex_output(node, execdata, in, out[0], &colorfn, static_cast<TexCallData *>(data));
67}
68
70{
71 static blender::bke::bNodeType ntype;
72
73 tex_node_type_base(&ntype, TEX_NODE_COMBINE_COLOR, "Combine Color", NODE_CLASS_OP_COLOR);
74 blender::bke::node_type_socket_templates(&ntype, inputs, outputs);
75 ntype.exec_fn = exec;
76 ntype.updatefunc = update;
77
79}
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:406
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
Definition math_color.cc:57
void hsl_to_rgb_v(const float hsl[3], float r_rgb[3])
Definition math_color.cc:62
@ SOCK_FLOAT
@ SOCK_RGBA
NodeCombSepColorMode
@ NODE_COMBSEP_COLOR_RGB
@ NODE_COMBSEP_COLOR_HSV
@ NODE_COMBSEP_COLOR_HSL
@ PROP_FACTOR
Definition RNA_types.hh:154
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:4570
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void update(bNodeTree *, bNode *node)
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void register_node_type_tex_combine_color()
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
void tex_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
float tex_input_value(bNodeStack *in, TexParams *params, short thread)
void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
void node_combsep_color_label(const ListBase *sockets, NodeCombSepColorMode mode)
Definition node_util.cc:242
Compact definition of a node socket.
Definition BKE_node.hh:103
Defines a node type.
Definition BKE_node.hh:218
NodeExecFunction exec_fn
Definition BKE_node.hh:316
void(* updatefunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:257
#define N_(msgid)