Blender V5.0
node_texture_valToRgb.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
8
9#include "BKE_colorband.hh"
11#include "node_texture_util.hh"
12#include "node_util.hh"
13
14/* **************** VALTORGB ******************** */
16 {SOCK_FLOAT, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
17 {-1, ""},
18};
20 {SOCK_RGBA, N_("Color")},
21 {-1, ""},
22};
23
24static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
25{
26 if (node->storage) {
27 float fac = tex_input_value(in[0], p, thread);
28
29 BKE_colorband_evaluate(static_cast<const ColorBand *>(node->storage), fac, out);
30 }
31}
32
33static void valtorgb_exec(void *data,
34 int /*thread*/,
35 bNode *node,
36 bNodeExecData *execdata,
37 bNodeStack **in,
39{
40 tex_output(node, execdata, in, out[0], &valtorgb_colorfn, static_cast<TexCallData *>(data));
41}
42
43static void valtorgb_init(bNodeTree * /*ntree*/, bNode *node)
44{
45 node->storage = BKE_colorband_add(true);
46}
47
65
66/* **************** RGBTOBW ******************** */
68 {SOCK_RGBA, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f},
69 {-1, ""},
70};
72 {SOCK_FLOAT, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
73 {-1, ""},
74};
75
76static void rgbtobw_valuefn(
77 float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
78{
79 float cin[4];
80 tex_input_rgba(cin, in[0], p, thread);
82}
83
84static void rgbtobw_exec(void *data,
85 int /*thread*/,
86 bNode *node,
87 bNodeExecData *execdata,
88 bNodeStack **in,
90{
91 tex_output(node, execdata, in, out[0], &rgbtobw_valuefn, static_cast<TexCallData *>(data));
92}
93
95{
96 static blender::bke::bNodeType ntype;
97
98 tex_node_type_base(&ntype, "TextureNodeRGBToBW", TEX_NODE_RGBTOBW);
99 ntype.ui_name = "RGB to BW";
100 ntype.enum_name_legacy = "RGBTOBW";
103 ntype.exec_fn = rgbtobw_exec;
104
106}
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
Definition colorband.cc:396
ColorBand * BKE_colorband_add(bool rangetype)
Definition colorband.cc:298
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:453
#define TEX_NODE_RGBTOBW
#define TEX_NODE_VALTORGB
@ SOCK_FLOAT
@ SOCK_RGBA
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
@ PROP_FACTOR
Definition RNA_types.hh:251
BMesh const char void * data
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:5352
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:5414
void node_type_size_preset(bNodeType &ntype, eNodeSizePreset size)
Definition node.cc:5396
void tex_output(bNode *node, bNodeExecData *, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
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(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
static void valtorgb_exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static blender::bke::bNodeSocketTemplate valtorgb_in[]
static blender::bke::bNodeSocketTemplate valtorgb_out[]
static blender::bke::bNodeSocketTemplate rgbtobw_out[]
static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
static void rgbtobw_valuefn(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
static blender::bke::bNodeSocketTemplate rgbtobw_in[]
static void valtorgb_init(bNodeTree *, bNode *node)
void register_node_type_tex_rgbtobw()
static void rgbtobw_exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void register_node_type_tex_valtorgb()
void node_free_standard_storage(bNode *node)
Definition node_util.cc:42
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:54
void * storage
Compact definition of a node socket.
Definition BKE_node.hh:99
Defines a node type.
Definition BKE_node.hh:238
NodeExecFunction exec_fn
Definition BKE_node.hh:340
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:289
const char * enum_name_legacy
Definition BKE_node.hh:247
#define N_(msgid)