Blender  V3.3
node_texture_translate.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 #include <math.h>
11 
13  {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
14  {SOCK_VECTOR, N_("Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_TRANSLATION},
15  {-1, ""},
16 };
17 
19  {SOCK_RGBA, N_("Color")},
20  {-1, ""},
21 };
22 
23 static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
24 {
25  float offset[3], new_co[3];
26  TexParams np = *p;
27  np.co = new_co;
28 
29  tex_input_vec(offset, in[1], p, thread);
30 
31  new_co[0] = p->co[0] + offset[0];
32  new_co[1] = p->co[1] + offset[1];
33  new_co[2] = p->co[2] + offset[2];
34 
35  tex_input_rgba(out, in[0], &np, thread);
36 }
37 static void exec(void *data,
38  int UNUSED(thread),
39  bNode *node,
40  bNodeExecData *execdata,
41  bNodeStack **in,
42  bNodeStack **out)
43 {
44  tex_output(node, execdata, in, out[0], &colorfn, data);
45 }
46 
48 {
49  static bNodeType ntype;
50 
53  node_type_exec(&ntype, NULL, NULL, exec);
54 
55  nodeRegisterType(&ntype);
56 }
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4358
#define TEX_NODE_TRANSLATE
Definition: BKE_node.h:1362
#define NODE_CLASS_DISTORT
Definition: BKE_node.h:353
void node_type_exec(struct bNodeType *ntype, NodeInitExecFunction init_exec_fn, NodeFreeExecFunction free_exec_fn, NodeExecFunction exec_fn)
Definition: node.cc:4455
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define UNUSED(x)
@ SOCK_VECTOR
@ SOCK_RGBA
@ PROP_TRANSLATION
Definition: RNA_types.h:154
Definition: thread.h:34
OperationNode * node
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static bNodeSocketTemplate outputs[]
void register_node_type_tex_translate(void)
static bNodeSocketTemplate inputs[]
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void tex_input_vec(float *out, 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)
const float * co
Compact definition of a node socket.
Definition: BKE_node.h:84
Defines a node type.
Definition: BKE_node.h:226
#define N_(msgid)