Blender  V3.3
node_shader_mapping.cc
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 "node_shader_util.hh"
9 
10 #include "UI_interface.h"
11 #include "UI_resources.h"
12 
14 
16 {
17  b.add_input<decl::Vector>(N_("Vector"))
18  .default_value({0.0f, 0.0f, 0.0f})
19  .min(-FLT_MAX)
20  .max(FLT_MAX);
21  b.add_input<decl::Vector>(N_("Location"))
22  .default_value({0.0f, 0.0f, 0.0f})
23  .min(-FLT_MAX)
24  .max(FLT_MAX)
25  .subtype(PROP_TRANSLATION);
26  b.add_input<decl::Vector>(N_("Rotation"))
27  .default_value({0.0f, 0.0f, 0.0f})
28  .min(-FLT_MAX)
29  .max(FLT_MAX)
30  .subtype(PROP_EULER);
31  b.add_input<decl::Vector>(N_("Scale"))
32  .default_value({1.0f, 1.0f, 1.0f})
33  .min(-FLT_MAX)
34  .max(FLT_MAX)
35  .subtype(PROP_XYZ);
36  b.add_output<decl::Vector>(N_("Vector"));
37 }
38 
40 {
41  uiItemR(layout, ptr, "vector_type", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
42 }
43 
44 static const char *gpu_shader_get_name(int mode)
45 {
46  switch (mode) {
48  return "mapping_point";
50  return "mapping_texture";
52  return "mapping_vector";
54  return "mapping_normal";
55  }
56  return nullptr;
57 }
58 
60  bNode *node,
61  bNodeExecData *UNUSED(execdata),
62  GPUNodeStack *in,
64 {
65  if (gpu_shader_get_name(node->custom1)) {
66  return GPU_stack_link(mat, node, gpu_shader_get_name(node->custom1), in, out);
67  }
68 
69  return 0;
70 }
71 
73 {
74  bNodeSocket *sock = nodeFindSocket(node, SOCK_IN, "Location");
77 }
78 
79 } // namespace blender::nodes::node_shader_mapping_cc
80 
82 {
83  namespace file_ns = blender::nodes::node_shader_mapping_cc;
84 
85  static bNodeType ntype;
86 
92 
93  nodeRegisterType(&ntype);
94 }
void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn)
Definition: node.cc:4465
void node_type_update(struct bNodeType *ntype, void(*updatefunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4443
void nodeSetSocketAvailability(struct bNodeTree *ntree, struct bNodeSocket *sock, bool is_available)
Definition: node.cc:3664
struct bNodeSocket * nodeFindSocket(const struct bNode *node, eNodeSocketInOut in_out, const char *identifier)
#define NODE_CLASS_OP_VECTOR
Definition: BKE_node.h:348
#define SH_NODE_MAPPING
Definition: BKE_node.h:1088
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define UNUSED(x)
#define ELEM(...)
@ NODE_MAPPING_TYPE_POINT
@ NODE_MAPPING_TYPE_VECTOR
@ NODE_MAPPING_TYPE_TEXTURE
@ NODE_MAPPING_TYPE_NORMAL
@ SOCK_IN
bool GPU_stack_link(GPUMaterial *mat, struct bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ PROP_XYZ
Definition: RNA_types.h:162
@ PROP_EULER
Definition: RNA_types.h:159
@ PROP_TRANSLATION
Definition: RNA_types.h:154
@ UI_ITEM_R_SPLIT_EMPTY_NAME
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
OperationNode * node
bNodeTree * ntree
static const char * gpu_shader_get_name(int mode)
static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void node_shader_update_mapping(bNodeTree *ntree, bNode *node)
static void node_declare(NodeDeclarationBuilder &b)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_sh_mapping()
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass)
#define min(a, b)
Definition: sort.c:35
Defines a node type.
Definition: BKE_node.h:226
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
Definition: BKE_node.h:244
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480