Blender V5.3
node_texture_valToNor.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
11namespace blender {
12
14 {SOCK_FLOAT, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
15 {SOCK_FLOAT, N_("Nabla"), 0.025f, 0.0f, 0.0f, 0.0f, 0.001f, 0.1f, PROP_UNSIGNED},
16 {-1, ""},
17};
18
20 {SOCK_VECTOR, N_("Normal")},
21 {-1, ""},
22};
23
24static void normalfn(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
25{
26 float new_co[3];
27 const float *co = p->co;
28
29 float nabla = tex_input_value(in[1], p, thread);
30 float val;
31 float nor[3];
32
33 TexParams np = *p;
34 np.co = new_co;
35
36 val = tex_input_value(in[0], p, thread);
37
38 new_co[0] = co[0] + nabla;
39 new_co[1] = co[1];
40 new_co[2] = co[2];
41 nor[0] = tex_input_value(in[0], &np, thread);
42
43 new_co[0] = co[0];
44 new_co[1] = co[1] + nabla;
45 nor[1] = tex_input_value(in[0], &np, thread);
46
47 new_co[1] = co[1];
48 new_co[2] = co[2] + nabla;
49 nor[2] = tex_input_value(in[0], &np, thread);
50
51 out[0] = val - nor[0];
52 out[1] = val - nor[1];
53 out[2] = val - nor[2];
54}
55static void exec(void *data,
56 int /*thread*/,
57 bNode *node,
58 bNodeExecData *execdata,
59 bNodeStack **in,
61{
62 tex_output(node, execdata, in, out[0], &normalfn, static_cast<TexCallData *>(data));
63}
64
66{
67 static bke::bNodeType ntype;
68
69 tex_node_type_base(&ntype, "TextureNodeValToNor"_ustr, TEX_NODE_VALTONOR);
70 ntype.ui_name = "Value to Normal";
71 ntype.enum_name_legacy = "VALTONOR";
74 ntype.exec_fn = exec;
75
77}
78
79} // namespace blender
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define TEX_NODE_VALTONOR
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 register_node_type_tex_valtonor()
static void normalfn(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
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[]
@ PROP_UNSIGNED
Definition RNA_types.hh:306
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
const char * enum_name_legacy
Definition BKE_node.hh:274
#define N_(msgid)