Blender V4.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
10
12 {SOCK_FLOAT, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
13 {SOCK_FLOAT, N_("Nabla"), 0.025f, 0.0f, 0.0f, 0.0f, 0.001f, 0.1f, PROP_UNSIGNED},
14 {-1, ""},
15};
16
18 {SOCK_VECTOR, N_("Normal")},
19 {-1, ""},
20};
21
22static void normalfn(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
23{
24 float new_co[3];
25 const float *co = p->co;
26
27 float nabla = tex_input_value(in[1], p, thread);
28 float val;
29 float nor[3];
30
31 TexParams np = *p;
32 np.co = new_co;
33
34 val = tex_input_value(in[0], p, thread);
35
36 new_co[0] = co[0] + nabla;
37 new_co[1] = co[1];
38 new_co[2] = co[2];
39 nor[0] = tex_input_value(in[0], &np, thread);
40
41 new_co[0] = co[0];
42 new_co[1] = co[1] + nabla;
43 nor[1] = tex_input_value(in[0], &np, thread);
44
45 new_co[1] = co[1];
46 new_co[2] = co[2] + nabla;
47 nor[2] = tex_input_value(in[0], &np, thread);
48
49 out[0] = val - nor[0];
50 out[1] = val - nor[1];
51 out[2] = val - nor[2];
52}
53static void exec(void *data,
54 int /*thread*/,
55 bNode *node,
56 bNodeExecData *execdata,
57 bNodeStack **in,
58 bNodeStack **out)
59{
60 tex_output(node, execdata, in, out[0], &normalfn, static_cast<TexCallData *>(data));
61}
62
64{
65 static blender::bke::bNodeType ntype;
66
67 tex_node_type_base(&ntype, TEX_NODE_VALTONOR, "Value to Normal", NODE_CLASS_CONVERTER);
68 blender::bke::node_type_socket_templates(&ntype, inputs, outputs);
69 ntype.exec_fn = exec;
70
72}
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:410
@ SOCK_VECTOR
@ SOCK_FLOAT
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_UNSIGNED
Definition RNA_types.hh:152
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 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_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
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)
void register_node_type_tex_valtonor()
Frequency::GEOMETRY nor[]
const float * co
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
#define N_(msgid)