Blender  V3.3
node_texture_combine_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 
13  {SOCK_FLOAT, N_("Red"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
14  {SOCK_FLOAT, N_("Green"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
15  {SOCK_FLOAT, N_("Blue"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
16  {SOCK_FLOAT, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
17  {-1, ""},
18 };
20  {SOCK_RGBA, N_("Color")},
21  {-1, ""},
22 };
23 
24 static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
25 {
26  int i;
27  for (i = 0; i < 4; i++) {
28  out[i] = tex_input_value(in[i], p, thread);
29  }
30  /* Apply color space if required. */
31  switch (node->custom1) {
33  /* Pass */
34  break;
35  }
38  break;
39  }
42  break;
43  }
44  default: {
46  break;
47  }
48  }
49 }
50 
52 {
54 }
55 
56 static void exec(void *data,
57  int UNUSED(thread),
58  bNode *node,
59  bNodeExecData *execdata,
60  bNodeStack **in,
61  bNodeStack **out)
62 {
63  tex_output(node, execdata, in, out[0], &colorfn, data);
64 }
65 
67 {
68  static bNodeType ntype;
69 
72  node_type_exec(&ntype, NULL, NULL, exec);
73  node_type_update(&ntype, update);
74 
75  nodeRegisterType(&ntype);
76 }
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_COMBINE_COLOR
Definition: BKE_node.h:1370
#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 hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
Definition: math_color.c:49
void hsl_to_rgb_v(const float hsl[3], float r_rgb[3])
Definition: math_color.c:54
#define UNUSED(x)
@ SOCK_FLOAT
@ SOCK_RGBA
NodeCombSepColorMode
@ NODE_COMBSEP_COLOR_RGB
@ NODE_COMBSEP_COLOR_HSV
@ NODE_COMBSEP_COLOR_HSL
@ PROP_FACTOR
Definition: RNA_types.h:144
Definition: thread.h:34
OperationNode * node
bNodeTree * ntree
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
void register_node_type_tex_combine_color(void)
static bNodeSocketTemplate outputs[]
static void update(bNodeTree *UNUSED(ntree), bNode *node)
static bNodeSocketTemplate inputs[]
static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
float tex_input_value(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)