Blender V5.0
node_texture_separate_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
8
9#include "BLI_math_color.h"
10#include "node_texture_util.hh"
11#include "node_util.hh"
12
14 {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
15 {-1, ""},
16};
18 {SOCK_FLOAT, N_("Red")},
19 {SOCK_FLOAT, N_("Green")},
20 {SOCK_FLOAT, N_("Blue")},
21 {SOCK_FLOAT, N_("Alpha")},
22 {-1, ""},
23};
24
26{
27 switch (type) {
29 /* Pass */
30 break;
31 }
34 break;
35 }
38 break;
39 }
40 default: {
42 break;
43 }
44 }
45}
46
47static void valuefn_r(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
48{
49 tex_input_rgba(out, in[0], p, thread);
51 *out = out[0];
52}
53
54static void valuefn_g(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
55{
56 tex_input_rgba(out, in[0], p, thread);
58 *out = out[1];
59}
60
61static void valuefn_b(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
62{
63 tex_input_rgba(out, in[0], p, thread);
65 *out = out[2];
66}
67
68static void valuefn_a(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
69{
70 tex_input_rgba(out, in[0], p, thread);
71 *out = out[3];
72}
73
74static void update(bNodeTree * /*ntree*/, bNode *node)
75{
77}
78
79static void exec(void *data,
80 int /*thread*/,
81 bNode *node,
82 bNodeExecData *execdata,
83 bNodeStack **in,
85{
86 TexCallData *tex_call_data = static_cast<TexCallData *>(data);
87 tex_output(node, execdata, in, out[0], &valuefn_r, tex_call_data);
88 tex_output(node, execdata, in, out[1], &valuefn_g, tex_call_data);
89 tex_output(node, execdata, in, out[2], &valuefn_b, tex_call_data);
90 tex_output(node, execdata, in, out[3], &valuefn_a, tex_call_data);
91}
92
94{
95 static blender::bke::bNodeType ntype;
96
97 tex_node_type_base(&ntype, "TextureNodeSeparateColor", TEX_NODE_SEPARATE_COLOR);
98 ntype.ui_name = "Separate Color";
99 ntype.enum_name_legacy = "SEPARATE_COLOR";
102 ntype.exec_fn = exec;
103 ntype.updatefunc = update;
104
106}
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:449
#define TEX_NODE_SEPARATE_COLOR
#define BLI_assert_unreachable()
Definition BLI_assert.h:93
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
void rgb_to_hsl_v(const float rgb[3], float r_hsl[3])
@ SOCK_FLOAT
@ SOCK_RGBA
NodeCombSepColorMode
@ NODE_COMBSEP_COLOR_RGB
@ NODE_COMBSEP_COLOR_HSV
@ NODE_COMBSEP_COLOR_HSL
BMesh const char void * data
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:5352
static void update(bNodeTree *ntree)
static blender::bke::bNodeSocketTemplate outputs[]
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static blender::bke::bNodeSocketTemplate inputs[]
static void update(bNodeTree *, bNode *node)
static void apply_color_space(float *out, NodeCombSepColorMode type)
static void valuefn_b(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
void register_node_type_tex_separate_color()
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static void valuefn_r(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
static void valuefn_a(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
static void valuefn_g(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
void tex_output(bNode *node, bNodeExecData *, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_combsep_color_label(const ListBase *sockets, NodeCombSepColorMode mode)
Definition node_util.cc:227
int16_t custom1
ListBase outputs
Compact definition of a node socket.
Definition BKE_node.hh:99
Defines a node type.
Definition BKE_node.hh:238
NodeExecFunction exec_fn
Definition BKE_node.hh:340
const char * enum_name_legacy
Definition BKE_node.hh:247
void(* updatefunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:281
#define N_(msgid)