Blender  V2.93
node_shader_mapping.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2005 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "node_shader_util.h"
25 
26 /* **************** MAPPING ******************** */
28  {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_NONE},
29  {SOCK_VECTOR, N_("Location"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
30  {SOCK_VECTOR, N_("Rotation"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_EULER},
31  {SOCK_VECTOR, N_("Scale"), 1.0f, 1.0f, 1.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_XYZ},
32  {-1, ""},
33 };
34 
36  {SOCK_VECTOR, N_("Vector")},
37  {-1, ""},
38 };
39 
41  bNode *node,
42  bNodeExecData *UNUSED(execdata),
43  GPUNodeStack *in,
44  GPUNodeStack *out)
45 {
46  static const char *names[] = {
47  [NODE_MAPPING_TYPE_POINT] = "mapping_point",
48  [NODE_MAPPING_TYPE_TEXTURE] = "mapping_texture",
49  [NODE_MAPPING_TYPE_VECTOR] = "mapping_vector",
50  [NODE_MAPPING_TYPE_NORMAL] = "mapping_normal",
51  };
52 
53  if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
54  return GPU_stack_link(mat, node, names[node->custom1], in, out);
55  }
56 
57  return 0;
58 }
59 
61 {
62  bNodeSocket *sock = nodeFindSocket(node, SOCK_IN, "Location");
65 }
66 
68 {
69  static bNodeType ntype;
70 
75 
76  nodeRegisterType(&ntype);
77 }
void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn)
Definition: node.cc:4645
void nodeSetSocketAvailability(struct bNodeSocket *sock, bool is_available)
Definition: node.cc:3726
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4527
void node_type_update(struct bNodeType *ntype, void(*updatefunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4623
struct bNodeSocket * nodeFindSocket(const struct bNode *node, eNodeSocketInOut in_out, const char *identifier)
#define NODE_CLASS_OP_VECTOR
Definition: BKE_node.h:337
#define SH_NODE_MAPPING
Definition: BKE_node.h:981
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1298
#define ARRAY_SIZE(arr)
#define UNUSED(x)
#define ELEM(...)
#define N_(msgid)
@ NODE_MAPPING_TYPE_POINT
@ NODE_MAPPING_TYPE_VECTOR
@ NODE_MAPPING_TYPE_TEXTURE
@ NODE_MAPPING_TYPE_NORMAL
@ SOCK_IN
@ SOCK_VECTOR
bool GPU_stack_link(GPUMaterial *mat, struct bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ PROP_XYZ
Definition: RNA_types.h:148
@ PROP_EULER
Definition: RNA_types.h:145
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_TRANSLATION
Definition: RNA_types.h:140
OperationNode * node
bNodeTree * ntree
static char ** names
Definition: makesdna.c:162
static bNodeSocketTemplate sh_node_mapping_in[]
static void node_shader_update_mapping(bNodeTree *UNUSED(ntree), bNode *node)
static bNodeSocketTemplate sh_node_mapping_out[]
static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
void register_node_type_sh_mapping(void)
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag)
Compact definition of a node socket.
Definition: BKE_node.h:95
Defines a node type.
Definition: BKE_node.h:221