Blender V5.0
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
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 layout->prop(ptr, "aov_name", UI_ITEM_R_SPLIT_EMPTY_NAME, std::nullopt, ICON_NONE);
24}
25
26static void node_shader_init_output_aov(bNodeTree * /*ntree*/, bNode *node)
27{
28 NodeShaderOutputAOV *aov = MEM_callocN<NodeShaderOutputAOV>("NodeShaderOutputAOV");
29 node->storage = aov;
30}
31
33 bNode *node,
34 bNodeExecData * /*execdata*/,
37{
38 GPUNodeLink *outlink;
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
62 sh_node_type_base(&ntype, "ShaderNodeOutputAOV", SH_NODE_OUTPUT_AOV);
63 ntype.ui_name = "AOV Output";
64 ntype.ui_description =
65 "Arbitrary Output Variables.\nProvide custom render passes for arbitrary shader node "
66 "outputs";
67 ntype.enum_name_legacy = "OUTPUT_AOV";
69 ntype.declare = file_ns::node_declare;
70 ntype.draw_buttons = file_ns::node_shader_buts_output_aov;
71 ntype.initfunc = file_ns::node_shader_init_output_aov;
73 ntype, "NodeShaderOutputAOV", node_free_standard_storage, node_copy_standard_storage);
74 ntype.gpu_fn = file_ns::node_shader_gpu_output_aov;
75
76 ntype.no_muting = true;
77
79}
#define NODE_CLASS_OUTPUT
Definition BKE_node.hh:448
#define SH_NODE_OUTPUT_AOV
#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:67
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)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
#define in
#define out
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:5414
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, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
Definition node_util.cc:42
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:54
#define hash
Definition noise_c.cc:154
void * storage
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:289
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:342
const char * enum_name_legacy
Definition BKE_node.hh:247
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:259
NodeDeclareFunction declare
Definition BKE_node.hh:362
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
PointerRNA * ptr
Definition wm_files.cc:4238