Blender V4.3
node_texture_decompose.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10#include <cmath>
11
13 {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
14 {-1, ""},
15};
17 {SOCK_FLOAT, N_("Red")},
18 {SOCK_FLOAT, N_("Green")},
19 {SOCK_FLOAT, N_("Blue")},
20 {SOCK_FLOAT, N_("Alpha")},
21 {-1, ""},
22};
23
24static void valuefn_r(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
25{
26 tex_input_rgba(out, in[0], p, thread);
27 *out = out[0];
28}
29
30static void valuefn_g(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
31{
32 tex_input_rgba(out, in[0], p, thread);
33 *out = out[1];
34}
35
36static void valuefn_b(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
37{
38 tex_input_rgba(out, in[0], p, thread);
39 *out = out[2];
40}
41
42static void valuefn_a(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
43{
44 tex_input_rgba(out, in[0], p, thread);
45 *out = out[3];
46}
47
48static void exec(void *data,
49 int /*thread*/,
50 bNode *node,
51 bNodeExecData *execdata,
52 bNodeStack **in,
53 bNodeStack **out)
54{
55 TexCallData *tex_call_data = static_cast<TexCallData *>(data);
56 tex_output(node, execdata, in, out[0], &valuefn_r, tex_call_data);
57 tex_output(node, execdata, in, out[1], &valuefn_g, tex_call_data);
58 tex_output(node, execdata, in, out[2], &valuefn_b, tex_call_data);
59 tex_output(node, execdata, in, out[3], &valuefn_a, tex_call_data);
60}
61
63{
64 static blender::bke::bNodeType ntype;
65
66 tex_node_type_base(&ntype, TEX_NODE_DECOMPOSE_LEGACY, "Separate RGBA", NODE_CLASS_OP_COLOR);
67 blender::bke::node_type_socket_templates(&ntype, inputs, outputs);
68 ntype.exec_fn = exec;
69
71}
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:406
@ SOCK_FLOAT
@ SOCK_RGBA
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
void register_node_type_tex_decompose()
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static void valuefn_a(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
static void valuefn_g(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
static void valuefn_b(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
static void valuefn_r(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
void tex_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
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
#define N_(msgid)