Blender V5.0
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
5#include "node_shader_util.hh"
6
8#include "UI_resources.hh"
9
11
13{
14 b.add_input<decl::Float>("Radius").default_value(0.05f).min(0.0f).max(1000.0f);
15 b.add_input<decl::Vector>("Normal").hide_value();
16 b.add_output<decl::Vector>("Normal");
17}
18
19static void node_shader_buts_bevel(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
20{
21 layout->prop(ptr, "samples", UI_ITEM_R_SPLIT_EMPTY_NAME, std::nullopt, ICON_NONE);
22}
23
24static void node_shader_init_bevel(bNodeTree * /*ntree*/, bNode *node)
25{
26 node->custom1 = 4; /* samples */
27}
28
30 bNode *node,
31 bNodeExecData * /*execdata*/,
34{
35 if (!in[1].link) {
36 GPU_link(mat, "world_normals_get", &in[1].link);
37 }
38
39 return GPU_stack_link(mat, node, "node_bevel", in, out);
40}
41
43#ifdef WITH_MATERIALX
44{
45 /* NOTE: This node isn't supported by MaterialX. */
46 return get_input_link("Normal", NodeItem::Type::Vector3);
47}
48#endif
50
51} // namespace blender::nodes::node_shader_bevel_cc
52
53/* node type definition */
55{
56 namespace file_ns = blender::nodes::node_shader_bevel_cc;
57
58 static blender::bke::bNodeType ntype;
59
60 sh_node_type_base(&ntype, "ShaderNodeBevel", SH_NODE_BEVEL);
61 ntype.ui_name = "Bevel";
62 ntype.ui_description =
63 "Generates normals with round corners.\nNote: only supported in Cycles, and may slow down "
64 "renders";
65 ntype.enum_name_legacy = "BEVEL";
67 ntype.declare = file_ns::node_declare;
68 ntype.draw_buttons = file_ns::node_shader_buts_bevel;
69 ntype.initfunc = file_ns::node_shader_init_bevel;
70 ntype.gpu_fn = file_ns::gpu_shader_bevel;
71 ntype.materialx_fn = file_ns::node_shader_materialx;
72
74}
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define SH_NODE_BEVEL
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
bool GPU_link(GPUMaterial *mat, const char *name,...)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static int gpu_shader_bevel(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_buts_bevel(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_shader_init_bevel(bNodeTree *, bNode *node)
static void node_declare(NodeDeclarationBuilder &b)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_bevel()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
int16_t custom1
Defines a node type.
Definition BKE_node.hh:238
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:344
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