Blender V4.3
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
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,
38 bNodeStack **out)
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
62
63/* **************** RGBTOBW ******************** */
65 {SOCK_RGBA, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f},
66 {-1, ""},
67};
69 {SOCK_FLOAT, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
70 {-1, ""},
71};
72
73static void rgbtobw_valuefn(
74 float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
75{
76 float cin[4];
77 tex_input_rgba(cin, in[0], p, thread);
79}
80
81static void rgbtobw_exec(void *data,
82 int /*thread*/,
83 bNode *node,
84 bNodeExecData *execdata,
85 bNodeStack **in,
86 bNodeStack **out)
87{
88 tex_output(node, execdata, in, out[0], &rgbtobw_valuefn, static_cast<TexCallData *>(data));
89}
90
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:410
@ SOCK_FLOAT
@ SOCK_RGBA
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
@ PROP_FACTOR
Definition RNA_types.hh:154
void node_type_size_preset(bNodeType *ntype, eNodeSizePreset size)
Definition node.cc:4614
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:4570
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:4632
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
void tex_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
float tex_input_value(bNodeStack *in, TexParams *params, short thread)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
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:46
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:58
Compact definition of a node socket.
Definition BKE_node.hh:103
Defines a node type.
Definition BKE_node.hh:218
NodeExecFunction exec_fn
Definition BKE_node.hh:316
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:267
#define N_(msgid)