Blender  V3.3
node_texture_valToRgb.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 "IMB_colormanagement.h"
9 #include "NOD_texture.h"
10 #include "node_texture_util.h"
11 
12 /* **************** VALTORGB ******************** */
14  {SOCK_FLOAT, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
15  {-1, ""},
16 };
18  {SOCK_RGBA, N_("Color")},
19  {-1, ""},
20 };
21 
22 static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
23 {
24  if (node->storage) {
25  float fac = tex_input_value(in[0], p, thread);
26 
27  BKE_colorband_evaluate(node->storage, fac, out);
28  }
29 }
30 
31 static void valtorgb_exec(void *data,
32  int UNUSED(thread),
33  bNode *node,
34  bNodeExecData *execdata,
35  bNodeStack **in,
36  bNodeStack **out)
37 {
38  tex_output(node, execdata, in, out[0], &valtorgb_colorfn, data);
39 }
40 
42 {
43  node->storage = BKE_colorband_add(true);
44 }
45 
47 {
48  static bNodeType ntype;
49 
56 
57  nodeRegisterType(&ntype);
58 }
59 
60 /* **************** RGBTOBW ******************** */
62  {SOCK_RGBA, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f},
63  {-1, ""},
64 };
66  {SOCK_FLOAT, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
67  {-1, ""},
68 };
69 
70 static void rgbtobw_valuefn(
71  float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
72 {
73  float cin[4];
74  tex_input_rgba(cin, in[0], p, thread);
76 }
77 
78 static void rgbtobw_exec(void *data,
79  int UNUSED(thread),
80  bNode *node,
81  bNodeExecData *execdata,
82  bNodeStack **in,
83  bNodeStack **out)
84 {
85  tex_output(node, execdata, in, out[0], &rgbtobw_valuefn, data);
86 }
87 
89 {
90  static bNodeType ntype;
91 
95 
96  nodeRegisterType(&ntype);
97 }
struct ColorBand * BKE_colorband_add(bool rangetype)
Definition: colorband.c:296
bool BKE_colorband_evaluate(const struct ColorBand *coba, float in, float out[4])
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4358
#define NODE_CLASS_CONVERTER
Definition: BKE_node.h:351
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4390
void node_type_size_preset(struct bNodeType *ntype, eNodeSizePreset size)
Definition: node.cc:4408
#define TEX_NODE_RGBTOBW
Definition: BKE_node.h:1353
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
Definition: node.cc:4426
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 TEX_NODE_VALTORGB
Definition: BKE_node.h:1354
@ NODE_SIZE_LARGE
Definition: BKE_node.h:367
#define UNUSED(x)
@ SOCK_FLOAT
@ SOCK_RGBA
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
@ PROP_FACTOR
Definition: RNA_types.h:144
Definition: thread.h:34
OperationNode * node
bNodeTree * ntree
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
float tex_input_value(bNodeStack *in, TexParams *params, short thread)
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)
static bNodeSocketTemplate valtorgb_in[]
static void rgbtobw_valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
static bNodeSocketTemplate rgbtobw_out[]
static void valtorgb_init(bNodeTree *UNUSED(ntree), bNode *node)
static bNodeSocketTemplate valtorgb_out[]
void register_node_type_tex_rgbtobw(void)
static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
void register_node_type_tex_valtorgb(void)
static void rgbtobw_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static bNodeSocketTemplate rgbtobw_in[]
static void valtorgb_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
Definition: node_util.c:55
void node_free_standard_storage(bNode *node)
Definition: node_util.c:43
Compact definition of a node socket.
Definition: BKE_node.h:84
Defines a node type.
Definition: BKE_node.h:226
#define N_(msgid)