Blender V4.3
COM_AntiAliasingNode.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
6#include "COM_SMAAOperation.h"
7
8namespace blender::compositor {
9
10/* Blender encodes the threshold in the [0, 1] range, while the SMAA algorithm expects it in
11 * the [0, 0.5] range. */
12static float get_threshold(const NodeAntiAliasingData *data)
13{
14 return data->threshold / 2.0f;
15}
16
17/* Blender encodes the local contrast adaptation factor in the [0, 1] range, while the SMAA
18 * algorithm expects it in the [0, 10] range. */
20{
21 return data->contrast_limit * 10.0f;
22}
23
24/* Blender encodes the corner rounding factor in the float [0, 1] range, while the SMAA algorithm
25 * expects it in the integer [0, 100] range. */
27{
28 return int(data->corner_rounding * 100.0f);
29}
30
32 const CompositorContext & /*context*/) const
33{
34 const bNode *node = this->get_bnode();
35 const NodeAntiAliasingData *data = (const NodeAntiAliasingData *)node->storage;
36
37 SMAAOperation *operation = new SMAAOperation();
38 operation->set_threshold(get_threshold(data));
41 converter.add_operation(operation);
42
43 converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
44 converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
45}
46
47} // namespace blender::compositor
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
Overall context of the compositor.
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void add_operation(NodeOperation *operation)
void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket)
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOperationInput * get_input_socket(unsigned int index)
NodeOutput * get_output_socket(unsigned int index=0) const
Definition COM_Node.cc:85
NodeInput * get_input_socket(unsigned int index) const
Definition COM_Node.cc:90
const bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition COM_Node.h:65
void set_local_contrast_adaptation_factor(float factor)
void set_corner_rounding(int corner_rounding)
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
static float get_threshold(const NodeAntiAliasingData *data)
static float get_local_contrast_adaptation_factor(const NodeAntiAliasingData *data)
static int get_corner_rounding(const NodeAntiAliasingData *data)