Blender V5.3
node_texture_mixRgb.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
10#include "node_util.hh"
11
12#include "BKE_material.hh"
13
14#include "BLI_math_vector_c.hh"
15
16namespace blender {
17
18/* **************** MIX RGB ******************** */
20 {SOCK_FLOAT, N_("Factor"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
21 {SOCK_RGBA, N_("Color1"), 0.5f, 0.5f, 0.5f, 1.0f},
22 {SOCK_RGBA, N_("Color2"), 0.5f, 0.5f, 0.5f, 1.0f},
23 {-1, ""},
24};
26 {SOCK_RGBA, N_("Color")},
27 {-1, ""},
28};
29
30static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
31{
32 float fac = tex_input_value(in[0], p, thread);
33 float col1[4], col2[4];
34
35 tex_input_rgba(col1, in[1], p, thread);
36 tex_input_rgba(col2, in[2], p, thread);
37
38 /* use alpha */
39 if (node->custom2 & 1) {
40 fac *= col2[3];
41 }
42
43 CLAMP(fac, 0.0f, 1.0f);
44
45 copy_v4_v4(out, col1);
46 ramp_blend(node->custom1, out, fac, col2);
47}
48
49static void exec(void *data,
50 int /*thread*/,
51 bNode *node,
52 bNodeExecData *execdata,
53 bNodeStack **in,
55{
56 tex_output(node, execdata, in, out[0], &colorfn, static_cast<TexCallData *>(data));
57}
58
60{
61 static bke::bNodeType ntype;
62
63 tex_node_type_base(&ntype, "TextureNodeMixRGB"_ustr, TEX_NODE_MIX_RGB);
64 ntype.ui_name = "Mix";
65 ntype.enum_name_legacy = "MIX_RGB";
69 ntype.exec_fn = exec;
70
72}
73
74} // namespace blender
General operations, lookup, etc. for materials.
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:480
#define TEX_NODE_MIX_RGB
#define CLAMP(a, b, c)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:6134
BMesh Iterators.
void ramp_blend(int type, float r_col[4], float fac, const float col[4])
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
static void colorfn(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
void node_blend_label(const bNodeTree *, const bNode *node, char *label, int label_maxncpy)
Definition node_util.cc:133
void register_node_type_tex_mix_rgb()
BMesh const char void * data
void tex_output(bNode *node, bNodeExecData *, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
static bke::bNodeSocketTemplate inputs[]
void tex_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
float tex_input_value(bNodeStack *in, TexParams *params, short thread)
static bke::bNodeSocketTemplate outputs[]
MINLINE void copy_v4_v4(float r[4], const float a[4])
Compact definition of a node socket.
Definition BKE_node.hh:102
Defines a node type.
Definition BKE_node.hh:265
NodeExecFunction exec_fn
Definition BKE_node.hh:371
void(*) labelfunc(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
Definition BKE_node.hh:301
const char * enum_name_legacy
Definition BKE_node.hh:274
#define N_(msgid)