Blender  V3.3
node_texture_separate_color.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2022 Blender Foundation. All rights reserved. */
3 
8 #include "BLI_listbase.h"
9 #include "NOD_texture.h"
10 #include "node_texture_util.h"
11 #include <math.h>
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 
47 static 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 
54 static 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 
61 static 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 
68 static void valuefn_a(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
69 {
70  tex_input_rgba(out, in[0], p, thread);
71  *out = out[3];
72 }
73 
75 {
77 }
78 
79 static void exec(void *data,
80  int UNUSED(thread),
81  bNode *node,
82  bNodeExecData *execdata,
83  bNodeStack **in,
84  bNodeStack **out)
85 {
86  tex_output(node, execdata, in, out[0], &valuefn_r, data);
87  tex_output(node, execdata, in, out[1], &valuefn_g, data);
88  tex_output(node, execdata, in, out[2], &valuefn_b, data);
89  tex_output(node, execdata, in, out[3], &valuefn_a, data);
90 }
91 
93 {
94  static bNodeType ntype;
95 
98  node_type_exec(&ntype, NULL, NULL, exec);
99  node_type_update(&ntype, update);
100 
101  nodeRegisterType(&ntype);
102 }
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4358
void node_type_update(struct bNodeType *ntype, void(*updatefunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4443
#define TEX_NODE_SEPARATE_COLOR
Definition: BKE_node.h:1371
#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 BLI_assert_unreachable()
Definition: BLI_assert.h:93
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
Definition: math_color.c:232
void rgb_to_hsl_v(const float rgb[3], float r_hsl[3])
Definition: math_color.c:292
#define UNUSED(x)
@ SOCK_FLOAT
@ SOCK_RGBA
NodeCombSepColorMode
@ NODE_COMBSEP_COLOR_RGB
@ NODE_COMBSEP_COLOR_HSV
@ NODE_COMBSEP_COLOR_HSL
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Definition: thread.h:34
OperationNode * node
bNodeTree * ntree
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static bNodeSocketTemplate outputs[]
static void apply_color_space(float *out, NodeCombSepColorMode type)
static void update(bNodeTree *UNUSED(ntree), bNode *node)
static void valuefn_b(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
static bNodeSocketTemplate inputs[]
static void exec(void *data, int UNUSED(thread), 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 *UNUSED(node), bNodeStack **in, short thread)
static void valuefn_g(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
void register_node_type_tex_separate_color(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)
void node_combsep_color_label(const ListBase *sockets, NodeCombSepColorMode mode)
Definition: node_util.c:229
Compact definition of a node socket.
Definition: BKE_node.h:84
Defines a node type.
Definition: BKE_node.h:226
#define N_(msgid)