Blender  V3.3
node_texture_mixRgb.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 "NOD_texture.h"
9 #include "node_texture_util.h"
10 
11 /* **************** MIX RGB ******************** */
13  {SOCK_FLOAT, N_("Factor"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
14  {SOCK_RGBA, N_("Color1"), 0.5f, 0.5f, 0.5f, 1.0f},
15  {SOCK_RGBA, N_("Color2"), 0.5f, 0.5f, 0.5f, 1.0f},
16  {-1, ""},
17 };
19  {SOCK_RGBA, N_("Color")},
20  {-1, ""},
21 };
22 
23 static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
24 {
25  float fac = tex_input_value(in[0], p, thread);
26  float col1[4], col2[4];
27 
28  tex_input_rgba(col1, in[1], p, thread);
29  tex_input_rgba(col2, in[2], p, thread);
30 
31  /* use alpha */
32  if (node->custom2 & 1) {
33  fac *= col2[3];
34  }
35 
36  CLAMP(fac, 0.0f, 1.0f);
37 
38  copy_v4_v4(out, col1);
39  ramp_blend(node->custom1, out, fac, col2);
40 }
41 
42 static void exec(void *data,
43  int UNUSED(thread),
44  bNode *node,
45  bNodeExecData *execdata,
46  bNodeStack **in,
47  bNodeStack **out)
48 {
49  tex_output(node, execdata, in, out[0], &colorfn, data);
50 }
51 
53 {
54  static bNodeType ntype;
55 
59  node_type_exec(&ntype, NULL, NULL, exec);
60 
61  nodeRegisterType(&ntype);
62 }
void ramp_blend(int type, float r_col[3], float fac, const float col[3])
Definition: material.c:1611
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4358
#define NODE_CLASS_OP_COLOR
Definition: BKE_node.h:347
void node_type_exec(struct bNodeType *ntype, NodeInitExecFunction init_exec_fn, NodeFreeExecFunction free_exec_fn, NodeExecFunction exec_fn)
Definition: node.cc:4455
#define TEX_NODE_MIX_RGB
Definition: BKE_node.h:1352
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
MINLINE void copy_v4_v4(float r[4], const float a[4])
#define UNUSED(x)
@ SOCK_FLOAT
@ SOCK_RGBA
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
@ PROP_NONE
Definition: RNA_types.h:126
Definition: thread.h:34
OperationNode * node
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static bNodeSocketTemplate outputs[]
void register_node_type_tex_mix_rgb(void)
static bNodeSocketTemplate inputs[]
static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
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)
void node_blend_label(const bNodeTree *UNUSED(ntree), const bNode *node, char *label, int maxlen)
Definition: node_util.c:179
Compact definition of a node socket.
Definition: BKE_node.h:84
Defines a node type.
Definition: BKE_node.h:226
void(* labelfunc)(const struct bNodeTree *ntree, const struct bNode *node, char *label, int maxlen)
Definition: BKE_node.h:256
#define N_(msgid)