Blender V4.3
node_shader_output_aov.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
5#include "node_shader_util.hh"
6#include "node_util.hh"
7
8#include "BLI_hash.h"
9
10#include "UI_interface.hh"
11#include "UI_resources.hh"
12
14
16{
17 b.add_input<decl::Color>("Color").default_value({0.0f, 0.0f, 0.0f, 1.0f});
18 b.add_input<decl::Float>("Value").default_value(0.0f).min(0.0f).max(1.0f);
19}
20
22{
23 uiItemR(layout, ptr, "aov_name", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
24}
25
26static void node_shader_init_output_aov(bNodeTree * /*ntree*/, bNode *node)
27{
28 NodeShaderOutputAOV *aov = MEM_cnew<NodeShaderOutputAOV>("NodeShaderOutputAOV");
29 node->storage = aov;
30}
31
33 bNode *node,
34 bNodeExecData * /*execdata*/,
35 GPUNodeStack *in,
36 GPUNodeStack *out)
37{
38 GPUNodeLink *outlink;
39 NodeShaderOutputAOV *aov = (NodeShaderOutputAOV *)node->storage;
41 /* WORKAROUND: We don't support int/uint constants for now. So make sure the aliasing works.
42 * We cast back to uint in GLSL. */
43 BLI_STATIC_ASSERT(sizeof(float) == sizeof(uint),
44 "GPUCodegen: AOV hash needs float and uint to be the same size.");
45 GPUNodeLink *hash_link = GPU_constant((float *)&hash);
46
48 GPU_stack_link(mat, node, "node_output_aov", in, out, hash_link, &outlink);
50 return true;
51}
52
53} // namespace blender::nodes::node_shader_output_aov_cc
54
55/* node type definition */
57{
59
60 static blender::bke::bNodeType ntype;
61
63 ntype.declare = file_ns::node_declare;
64 ntype.draw_buttons = file_ns::node_shader_buts_output_aov;
65 ntype.initfunc = file_ns::node_shader_init_output_aov;
67 &ntype, "NodeShaderOutputAOV", node_free_standard_storage, node_copy_standard_storage);
68 ntype.gpu_fn = file_ns::node_shader_gpu_output_aov;
69
70 ntype.no_muting = true;
71
73}
#define NODE_CLASS_OUTPUT
Definition BKE_node.hh:405
#define SH_NODE_OUTPUT_AOV
Definition BKE_node.hh:990
#define BLI_STATIC_ASSERT(a, msg)
Definition BLI_assert.h:87
BLI_INLINE unsigned int BLI_hash_string(const char *str)
Definition BLI_hash.h:71
unsigned int uint
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
void GPU_material_add_output_link_aov(GPUMaterial *material, GPUNodeLink *link, int hash)
@ GPU_MATFLAG_AOV
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
local_group_size(16, 16) .push_constant(Type b
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:4632
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void node_shader_buts_output_aov(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_shader_init_output_aov(bNodeTree *, bNode *node)
static int node_shader_gpu_output_aov(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
void register_node_type_sh_output_aov()
void sh_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_free_standard_storage(bNode *node)
Definition node_util.cc:46
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:58
#define hash
Definition noise.c:154
Defines a node type.
Definition BKE_node.hh:218
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:267
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:238
NodeDeclareFunction declare
Definition BKE_node.hh:347
PointerRNA * ptr
Definition wm_files.cc:4126