Blender  V3.3
node_texture_decompose.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2005 Blender Foundation. All rights reserved. */
3 
8 #include "NOD_texture.h"
9 #include "node_texture_util.h"
10 #include <math.h>
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 
24 static void valuefn_r(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
25 {
26  tex_input_rgba(out, in[0], p, thread);
27  *out = out[0];
28 }
29 
30 static void valuefn_g(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
31 {
32  tex_input_rgba(out, in[0], p, thread);
33  *out = out[1];
34 }
35 
36 static void valuefn_b(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
37 {
38  tex_input_rgba(out, in[0], p, thread);
39  *out = out[2];
40 }
41 
42 static void valuefn_a(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
43 {
44  tex_input_rgba(out, in[0], p, thread);
45  *out = out[3];
46 }
47 
48 static void exec(void *data,
49  int UNUSED(thread),
50  bNode *node,
51  bNodeExecData *execdata,
52  bNodeStack **in,
53  bNodeStack **out)
54 {
55  tex_output(node, execdata, in, out[0], &valuefn_r, data);
56  tex_output(node, execdata, in, out[1], &valuefn_g, data);
57  tex_output(node, execdata, in, out[2], &valuefn_b, data);
58  tex_output(node, execdata, in, out[3], &valuefn_a, data);
59 }
60 
62 {
63  static bNodeType ntype;
64 
67  node_type_exec(&ntype, NULL, NULL, exec);
68 
69  nodeRegisterType(&ntype);
70 }
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4358
#define TEX_NODE_DECOMPOSE_LEGACY
Definition: BKE_node.h:1366
#define NODE_CLASS_OP_COLOR
Definition: BKE_node.h:347
void node_type_exec(struct bNodeType *ntype, NodeInitExecFunction init_exec_fn, NodeFreeExecFunction free_exec_fn, NodeExecFunction exec_fn)
Definition: node.cc:4455
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define UNUSED(x)
@ SOCK_FLOAT
@ SOCK_RGBA
Definition: thread.h:34
OperationNode * node
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static void valuefn_b(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
static bNodeSocketTemplate outputs[]
static bNodeSocketTemplate inputs[]
static void valuefn_g(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static void valuefn_a(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
static void valuefn_r(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
void register_node_type_tex_decompose(void)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass)
void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
Compact definition of a node socket.
Definition: BKE_node.h:84
Defines a node type.
Definition: BKE_node.h:226
#define N_(msgid)