Blender V4.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
10#include "node_util.hh"
11
12#include "BKE_material.h"
13
14#include "BLI_math_vector.h"
15
16/* **************** MIX RGB ******************** */
18 {SOCK_FLOAT, N_("Factor"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
19 {SOCK_RGBA, N_("Color1"), 0.5f, 0.5f, 0.5f, 1.0f},
20 {SOCK_RGBA, N_("Color2"), 0.5f, 0.5f, 0.5f, 1.0f},
21 {-1, ""},
22};
24 {SOCK_RGBA, N_("Color")},
25 {-1, ""},
26};
27
28static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
29{
30 float fac = tex_input_value(in[0], p, thread);
31 float col1[4], col2[4];
32
33 tex_input_rgba(col1, in[1], p, thread);
34 tex_input_rgba(col2, in[2], p, thread);
35
36 /* use alpha */
37 if (node->custom2 & 1) {
38 fac *= col2[3];
39 }
40
41 CLAMP(fac, 0.0f, 1.0f);
42
43 copy_v4_v4(out, col1);
44 ramp_blend(node->custom1, out, fac, col2);
45}
46
47static void exec(void *data,
48 int /*thread*/,
49 bNode *node,
50 bNodeExecData *execdata,
51 bNodeStack **in,
52 bNodeStack **out)
53{
54 tex_output(node, execdata, in, out[0], &colorfn, static_cast<TexCallData *>(data));
55}
56
58{
59 static blender::bke::bNodeType ntype;
60
61 tex_node_type_base(&ntype, TEX_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR);
62 blender::bke::node_type_socket_templates(&ntype, inputs, outputs);
64 ntype.exec_fn = exec;
65
67}
General operations, lookup, etc. for materials.
void ramp_blend(int type, float r_col[3], float fac, const float col[3])
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:406
MINLINE void copy_v4_v4(float r[4], const float a[4])
#define CLAMP(a, b, c)
@ SOCK_FLOAT
@ SOCK_RGBA
@ PROP_NONE
Definition RNA_types.hh:136
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:4570
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void register_node_type_tex_mix_rgb()
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
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)
void node_blend_label(const bNodeTree *, const bNode *node, char *label, int label_maxncpy)
Definition node_util.cc:180
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(* labelfunc)(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
Definition BKE_node.hh:249
#define N_(msgid)