Blender V4.3
node_composite_antialiasing.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2017 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "UI_interface.hh"
10#include "UI_resources.hh"
11
12#include "COM_algorithm_smaa.hh"
13#include "COM_node_operation.hh"
14
16
17/* **************** Anti-Aliasing (SMAA 1x) ******************** */
18
20
22
24{
25 b.add_input<decl::Color>("Image")
26 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
27 .compositor_domain_priority(0);
28 b.add_output<decl::Color>("Image");
29}
30
31static void node_composit_init_antialiasing(bNodeTree * /*ntree*/, bNode *node)
32{
33 NodeAntiAliasingData *data = MEM_cnew<NodeAntiAliasingData>(__func__);
34
35 data->threshold = CMP_DEFAULT_SMAA_THRESHOLD;
36 data->contrast_limit = CMP_DEFAULT_SMAA_CONTRAST_LIMIT;
37 data->corner_rounding = CMP_DEFAULT_SMAA_CORNER_ROUNDING;
38
39 node->storage = data;
40}
41
43{
45
46 col = uiLayoutColumn(layout, false);
47
48 uiItemR(col, ptr, "threshold", UI_ITEM_NONE, nullptr, ICON_NONE);
49 uiItemR(col, ptr, "contrast_limit", UI_ITEM_NONE, nullptr, ICON_NONE);
50 uiItemR(col, ptr, "corner_rounding", UI_ITEM_NONE, nullptr, ICON_NONE);
51}
52
53using namespace blender::realtime_compositor;
54
56 public:
58
59 void execute() override
60 {
61 smaa(context(),
62 get_input("Image"),
63 get_result("Image"),
67 }
68
69 /* Blender encodes the threshold in the [0, 1] range, while the SMAA algorithm expects it in
70 * the [0, 0.5] range. */
72 {
73 return node_storage(bnode()).threshold / 2.0f;
74 }
75
76 /* Blender encodes the local contrast adaptation factor in the [0, 1] range, while the SMAA
77 * algorithm expects it in the [0, 10] range. */
79 {
80 return node_storage(bnode()).contrast_limit * 10.0f;
81 }
82
83 /* Blender encodes the corner rounding factor in the float [0, 1] range, while the SMAA algorithm
84 * expects it in the integer [0, 100] range. */
86 {
87 return int(node_storage(bnode()).corner_rounding * 100.0f);
88 }
89};
90
92{
93 return new AntiAliasingOperation(context, node);
94}
95
96} // namespace blender::nodes::node_composite_antialiasing_cc
97
99{
101
102 static blender::bke::bNodeType ntype;
103
104 cmp_node_type_base(&ntype, CMP_NODE_ANTIALIASING, "Anti-Aliasing", NODE_CLASS_OP_FILTER);
105 ntype.declare = file_ns::cmp_node_antialiasing_declare;
106 ntype.draw_buttons = file_ns::node_composit_buts_antialiasing;
107 ntype.flag |= NODE_PREVIEW;
108 blender::bke::node_type_size(&ntype, 170, 140, 200);
109 ntype.initfunc = file_ns::node_composit_init_antialiasing;
111 &ntype, "NodeAntiAliasingData", node_free_standard_storage, node_copy_standard_storage);
112 ntype.get_compositor_operation = file_ns::get_compositor_operation;
113
115}
#define CMP_DEFAULT_SMAA_CORNER_ROUNDING
Definition BKE_node.hh:1127
#define NODE_STORAGE_FUNCS(StorageT)
Definition BKE_node.hh:1799
#define CMP_DEFAULT_SMAA_CONTRAST_LIMIT
Definition BKE_node.hh:1126
#define CMP_DEFAULT_SMAA_THRESHOLD
Definition BKE_node.hh:1125
#define NODE_CLASS_OP_FILTER
Definition BKE_node.hh:408
@ NODE_PREVIEW
#define UI_ITEM_NONE
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
NodeOperation(Context &context, DNode node)
Result & get_input(StringRef identifier) const
Definition operation.cc:144
Result & get_result(StringRef identifier)
Definition operation.cc:46
local_group_size(16, 16) .push_constant(Type b
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
uint col
void node_type_size(bNodeType *ntype, int width, int minwidth, int maxwidth)
Definition node.cc:4602
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 NodeOperation * get_compositor_operation(Context &context, DNode node)
static void node_composit_buts_antialiasing(uiLayout *layout, bContext *, PointerRNA *ptr)
static void cmp_node_antialiasing_declare(NodeDeclarationBuilder &b)
static void node_composit_init_antialiasing(bNodeTree *, bNode *node)
void smaa(Context &context, Result &input, Result &output, float threshold=0.1f, float local_contrast_adaptation_factor=2.0f, int corner_rounding=25)
Definition smaa.cc:160
void register_node_type_cmp_antialiasing()
void cmp_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
Defines a node type.
Definition BKE_node.hh:218
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:324
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:267
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