Realtime Compositor: Anti-alias morphological threshold

This patch anti-aliases the output of the morphological threshold
operation in the Dilate/Erode node. This is done to match the CPU
implementation.
This commit is contained in:
Omar Emara
2024-01-29 20:13:04 +02:00
parent fb7f29c98e
commit 6fe2bbd51c

View File

@@ -21,6 +21,7 @@
#include "COM_algorithm_morphological_distance.hh"
#include "COM_algorithm_morphological_distance_feather.hh"
#include "COM_algorithm_smaa.hh"
#include "COM_node_operation.hh"
#include "COM_utilities.hh"
@@ -195,7 +196,7 @@ class DilateErodeOperation : public NodeOperation {
input_mask.bind_as_texture(shader, "input_tx");
const Domain domain = compute_domain();
Result &output_mask = get_result("Mask");
Result output_mask = context().create_temporary_result(ResultType::Float);
output_mask.allocate_texture(domain);
output_mask.bind_as_image(shader, "output_img");
@@ -204,6 +205,17 @@ class DilateErodeOperation : public NodeOperation {
GPU_shader_unbind();
output_mask.unbind_as_image();
input_mask.unbind_as_texture();
/* For configurations where there is little user-specified inset, anti-alias the result for
* smoother edges. */
Result &output = get_result("Mask");
if (get_inset() < 2.0f) {
smaa(context(), output_mask, output);
output_mask.release();
}
else {
output.steal_data(output_mask);
}
}
/* See the discussion in the implementation for more information. */