Blender  V3.3
node_shader_output_aov.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 
4 #include "node_shader_util.hh"
5 
6 #include "BLI_hash.h"
7 
8 #include "UI_interface.h"
9 #include "UI_resources.h"
10 
12 
14 {
15  b.add_input<decl::Color>(N_("Color")).default_value({0.0f, 0.0f, 0.0f, 1.0f});
16  b.add_input<decl::Float>(N_("Value")).default_value(0.0f).min(0.0f).max(1.0f);
17 }
18 
20 {
21  uiItemR(layout, ptr, "name", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
22 }
23 
25 {
26  NodeShaderOutputAOV *aov = MEM_cnew<NodeShaderOutputAOV>("NodeShaderOutputAOV");
27  node->storage = aov;
28 }
29 
31  bNode *node,
32  bNodeExecData *UNUSED(execdata),
33  GPUNodeStack *in,
35 {
36  GPUNodeLink *outlink;
37  NodeShaderOutputAOV *aov = (NodeShaderOutputAOV *)node->storage;
38  uint hash = BLI_hash_string(aov->name);
39  /* WORKAROUND: We don't support int/uint constants for now. So make sure the aliasing works.
40  * We cast back to uint in GLSL. */
41  BLI_STATIC_ASSERT(sizeof(float) == sizeof(uint),
42  "GPUCodegen: AOV hash needs float and uint to be the same size.");
43  GPUNodeLink *hash_link = GPU_constant((float *)&hash);
44 
46  GPU_stack_link(mat, node, "node_output_aov", in, out, hash_link, &outlink);
48  return true;
49 }
50 
51 } // namespace blender::nodes::node_shader_output_aov_cc
52 
53 /* node type definition */
55 {
57 
58  static bNodeType ntype;
59 
65  &ntype, "NodeShaderOutputAOV", node_free_standard_storage, node_copy_standard_storage);
67 
68  ntype.no_muting = true;
69 
70  nodeRegisterType(&ntype);
71 }
void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn)
Definition: node.cc:4465
#define NODE_CLASS_OUTPUT
Definition: BKE_node.h:346
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4390
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
Definition: node.cc:4426
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define SH_NODE_OUTPUT_AOV
Definition: BKE_node.h:1178
#define BLI_STATIC_ASSERT(a, msg)
Definition: BLI_assert.h:83
BLI_INLINE unsigned int BLI_hash_string(const char *str)
Definition: BLI_hash.h:69
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNUSED(x)
void GPU_material_add_output_link_aov(GPUMaterial *material, GPUNodeLink *link, int hash)
Definition: gpu_material.c:533
GPUNodeLink * GPU_constant(const float *num)
@ GPU_MATFLAG_AOV
Definition: GPU_material.h:83
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
Definition: gpu_material.c:596
bool GPU_stack_link(GPUMaterial *mat, struct bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ 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 int node_shader_gpu_output_aov(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_init_output_aov(bNodeTree *UNUSED(ntree), bNode *node)
static void node_shader_buts_output_aov(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
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_output_aov()
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
Definition: node_util.c:55
void node_free_standard_storage(bNode *node)
Definition: node_util.c:43
#define hash
Definition: noise.c:153
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
bool no_muting
Definition: BKE_node.h:338
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480