2022-02-10 23:07:11 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
* Copyright 2017 Blender Foundation. */
|
2021-03-29 07:44:27 +02:00
|
|
|
|
|
|
|
#include "COM_AntiAliasingNode.h"
|
|
|
|
#include "COM_SMAAOperation.h"
|
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
namespace blender::compositor {
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void AntiAliasingNode::convert_to_operations(NodeConverter &converter,
|
|
|
|
const CompositorContext & /*context*/) const
|
2021-03-29 07:44:27 +02:00
|
|
|
{
|
2022-08-31 18:49:35 +02:00
|
|
|
const bNode *node = this->get_bnode();
|
|
|
|
const NodeAntiAliasingData *data = (const NodeAntiAliasingData *)node->storage;
|
2021-03-29 07:44:27 +02:00
|
|
|
|
|
|
|
/* Edge Detection (First Pass) */
|
|
|
|
SMAAEdgeDetectionOperation *operation1 = nullptr;
|
|
|
|
|
|
|
|
operation1 = new SMAAEdgeDetectionOperation();
|
2021-10-13 23:01:15 +02:00
|
|
|
operation1->set_threshold(data->threshold);
|
|
|
|
operation1->set_local_contrast_adaptation_factor(data->contrast_limit);
|
|
|
|
converter.add_operation(operation1);
|
2021-03-29 07:44:27 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
converter.map_input_socket(get_input_socket(0), operation1->get_input_socket(0));
|
2021-03-29 07:44:27 +02:00
|
|
|
|
|
|
|
/* Blending Weight Calculation Pixel Shader (Second Pass) */
|
|
|
|
SMAABlendingWeightCalculationOperation *operation2 =
|
|
|
|
new SMAABlendingWeightCalculationOperation();
|
2021-10-13 23:01:15 +02:00
|
|
|
operation2->set_corner_rounding(data->corner_rounding);
|
|
|
|
converter.add_operation(operation2);
|
2021-03-29 07:44:27 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
converter.add_link(operation1->get_output_socket(), operation2->get_input_socket(0));
|
2021-03-29 07:44:27 +02:00
|
|
|
|
|
|
|
/* Neighborhood Blending Pixel Shader (Third Pass) */
|
|
|
|
SMAANeighborhoodBlendingOperation *operation3 = new SMAANeighborhoodBlendingOperation();
|
2021-10-13 23:01:15 +02:00
|
|
|
converter.add_operation(operation3);
|
2021-03-29 07:44:27 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
converter.map_input_socket(get_input_socket(0), operation3->get_input_socket(0));
|
|
|
|
converter.add_link(operation2->get_output_socket(), operation3->get_input_socket(1));
|
|
|
|
converter.map_output_socket(get_output_socket(0), operation3->get_output_socket());
|
2021-03-29 07:44:27 +02:00
|
|
|
}
|
2021-03-23 17:12:27 +01:00
|
|
|
|
|
|
|
} // namespace blender::compositor
|