Blender V5.3
node_shader_bevel.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
8
9#include "node_shader_util.hh"
10
12#include "UI_resources.hh"
13
14namespace blender {
15
17
19{
20 b.add_input<decl::Float>("Radius"_ustr).default_value(0.05f).min(0.0f).max(1000.0f);
21 b.add_input<decl::Vector>("Normal"_ustr).hide_value();
22 b.add_output<decl::Vector>("Normal"_ustr);
23}
24
25static void node_shader_buts_bevel(ui::Layout &layout, bContext * /*C*/, PointerRNA *ptr)
26{
27 layout.prop(ptr, "samples", ui::ITEM_R_SPLIT_EMPTY_NAME, std::nullopt, ICON_NONE);
28}
29
30static void node_shader_init_bevel(bNodeTree * /*ntree*/, bNode *node)
31{
32 node->custom1 = 4; /* samples */
33}
34
36 bNode *node,
37 bNodeExecData * /*execdata*/,
40{
41 if (!in[1].link) {
42 GPU_link(mat, "world_normals_get", GPU_shading_data(), &in[1].link);
43 }
44
45 return GPU_stack_link(mat, node, "node_bevel", in, out);
46}
47
49#ifdef WITH_MATERIALX
50{
51 /* NOTE: This node isn't supported by MaterialX. */
52 return get_input_link("Normal", NodeItem::Type::Vector3);
53}
54#endif
56
57} // namespace nodes::node_shader_bevel_cc
58
59/* node type definition */
61{
62 namespace file_ns = nodes::node_shader_bevel_cc;
63
64 static bke::bNodeType ntype;
65
66 sh_node_type_base(&ntype, "ShaderNodeBevel"_ustr, SH_NODE_BEVEL);
67 ntype.ui_name = "Bevel";
68 ntype.ui_description =
69 "Generates normals with round corners.\nNote: only supported in Cycles, and may slow down "
70 "renders";
71 ntype.enum_name_legacy = "BEVEL";
73 ntype.declare = file_ns::node_declare;
74 ntype.draw_buttons = file_ns::node_shader_buts_bevel;
75 ntype.initfunc = file_ns::node_shader_init_bevel;
76 ntype.gpu_fn = file_ns::gpu_shader_bevel;
77 ntype.materialx_fn = file_ns::node_shader_materialx;
78
80}
81
82} // namespace blender
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define SH_NODE_BEVEL
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static int gpu_shader_bevel(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_init_bevel(bNodeTree *, bNode *node)
static void node_shader_buts_bevel(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
BMesh Iterators.
void register_node_type_sh_bevel()
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
bool GPU_link(GPUMaterial *mat, const char *name,...)
GPUNodeLink * GPU_shading_data()
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
Defines a node type.
Definition BKE_node.hh:265
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:375
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:290
std::string ui_description
Definition BKE_node.hh:271
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:373
void(*) initfunc(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:320
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)