Blender V5.3
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_c.hh"
10#include "node_texture_util.hh"
11#include "node_util.hh"
12
13namespace blender {
14
16 {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
17 {-1, ""},
18};
20 {SOCK_FLOAT, N_("Red")},
21 {SOCK_FLOAT, N_("Green")},
22 {SOCK_FLOAT, N_("Blue")},
23 {SOCK_FLOAT, N_("Alpha")},
24 {-1, ""},
25};
26
28{
29 switch (type) {
31 /* Pass */
32 break;
33 }
36 break;
37 }
40 break;
41 }
42 default: {
44 break;
45 }
46 }
47}
48
49static void valuefn_r(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
50{
51 tex_input_rgba(out, in[0], p, thread);
53 *out = out[0];
54}
55
56static void valuefn_g(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
57{
58 tex_input_rgba(out, in[0], p, thread);
60 *out = out[1];
61}
62
63static void valuefn_b(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
64{
65 tex_input_rgba(out, in[0], p, thread);
67 *out = out[2];
68}
69
70static void valuefn_a(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
71{
72 tex_input_rgba(out, in[0], p, thread);
73 *out = out[3];
74}
75
76static void update(bNodeTree * /*ntree*/, bNode *node)
77{
79}
80
81static void exec(void *data,
82 int /*thread*/,
83 bNode *node,
84 bNodeExecData *execdata,
85 bNodeStack **in,
87{
88 TexCallData *tex_call_data = static_cast<TexCallData *>(data);
89 tex_output(node, execdata, in, out[0], &valuefn_r, tex_call_data);
90 tex_output(node, execdata, in, out[1], &valuefn_g, tex_call_data);
91 tex_output(node, execdata, in, out[2], &valuefn_b, tex_call_data);
92 tex_output(node, execdata, in, out[3], &valuefn_a, tex_call_data);
93}
94
96{
97 static bke::bNodeType ntype;
98
99 tex_node_type_base(&ntype, "TextureNodeSeparateColor"_ustr, TEX_NODE_SEPARATE_COLOR);
100 ntype.ui_name = "Separate Color";
101 ntype.enum_name_legacy = "SEPARATE_COLOR";
104 ntype.exec_fn = exec;
105 ntype.updatefunc = update;
106
108}
109
110} // namespace blender
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:480
#define TEX_NODE_SEPARATE_COLOR
#define BLI_assert_unreachable()
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:6134
BMesh Iterators.
static void update(bNodeTree *, bNode *node)
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)
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void rgb_to_hsl_v(const float rgb[3], float r_hsl[3])
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
@ NODE_COMBSEP_COLOR_HSL
@ NODE_COMBSEP_COLOR_HSV
@ NODE_COMBSEP_COLOR_RGB
static void apply_color_space(float *out, NodeCombSepColorMode type)
void node_combsep_color_label(const ListBaseT< bNodeSocket > *sockets, NodeCombSepColorMode mode)
Definition node_util.cc:184
BMesh const char void * data
void tex_output(bNode *node, bNodeExecData *, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
static void valuefn_r(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
static bke::bNodeSocketTemplate inputs[]
void register_node_type_tex_separate_color()
void tex_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
static void valuefn_b(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
static bke::bNodeSocketTemplate outputs[]
Compact definition of a node socket.
Definition BKE_node.hh:102
Defines a node type.
Definition BKE_node.hh:265
NodeExecFunction exec_fn
Definition BKE_node.hh:371
void(*) updatefunc(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:312
const char * enum_name_legacy
Definition BKE_node.hh:274
#define N_(msgid)