Blender V4.3
node_texture_texture.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
11#include "BKE_material.h"
12#include "BKE_node_runtime.hh"
13
14#include "BLI_math_vector.h"
15
16#include "DNA_material_types.h"
17
18#include "RE_texture.h"
19
21 {SOCK_RGBA, N_("Color1"), 1.0f, 1.0f, 1.0f, 1.0f},
22 {SOCK_RGBA, N_("Color2"), 0.0f, 0.0f, 0.0f, 1.0f},
23 {-1, ""},
24};
25
27 {SOCK_RGBA, N_("Color")},
28 {-1, ""},
29};
30
31static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
32{
33 Tex *nodetex = (Tex *)node->id;
34 static float red[] = {1, 0, 0, 1};
35 static float white[] = {1, 1, 1, 1};
36 float co[3], dxt[3], dyt[3];
37
38 copy_v3_v3(co, p->co);
39 if (p->osatex) {
40 copy_v3_v3(dxt, p->dxt);
41 copy_v3_v3(dyt, p->dyt);
42 }
43 else {
44 zero_v3(dxt);
45 zero_v3(dyt);
46 }
47
48 if (node->custom2 || node->runtime->need_exec == 0) {
49 /* this node refers to its own texture tree! */
50 copy_v4_v4(out, (fabsf(co[0] - co[1]) < 0.01f) ? white : red);
51 }
52 else if (nodetex) {
53 TexResult texres;
54 int textype;
55 float col1[4], col2[4];
56
57 tex_input_rgba(col1, in[0], p, thread);
58 tex_input_rgba(col2, in[1], p, thread);
59
60 textype = multitex_nodes(
61 nodetex, co, dxt, dyt, p->osatex, &texres, thread, 0, p->mtex, nullptr);
62
63 if (textype & TEX_RGB) {
64 copy_v4_v4(out, texres.trgba);
65 }
66 else {
67 copy_v4_v4(out, col1);
68 ramp_blend(MA_RAMP_BLEND, out, texres.tin, col2);
69 }
70 }
71}
72
73static void exec(void *data,
74 int /*thread*/,
75 bNode *node,
76 bNodeExecData *execdata,
77 bNodeStack **in,
78 bNodeStack **out)
79{
80 tex_output(node, execdata, in, out[0], &colorfn, static_cast<TexCallData *>(data));
81}
82
84{
85 static blender::bke::bNodeType ntype;
86
87 tex_node_type_base(&ntype, TEX_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT);
88 blender::bke::node_type_socket_templates(&ntype, inputs, outputs);
89 ntype.exec_fn = exec;
90 ntype.flag |= NODE_PREVIEW;
91
93}
General operations, lookup, etc. for materials.
void ramp_blend(int type, float r_col[3], float fac, const float col[3])
#define NODE_CLASS_INPUT
Definition BKE_node.hh:404
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
@ MA_RAMP_BLEND
@ NODE_PREVIEW
@ SOCK_RGBA
@ TEX_RGB
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 Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a producing a negative Combine Generate a color from its red
#define fabsf(x)
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
void register_node_type_tex_texture()
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
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)
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)
const MTex * mtex
const float * co
float tin
Definition RE_texture.h:87
float trgba[4]
Definition RE_texture.h:88
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
int multitex_nodes(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, short which_output, const MTex *mtex, ImagePool *pool)
#define N_(msgid)