From cef1cf7587cf199608e096466b17747835095859 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sat, 29 Apr 2023 23:35:30 +0200 Subject: [PATCH] Hide edge aliasing of hard brushes with a blur (#1189) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [𝘀𝗽𝗿] initial version Created using spr 1.3.4 * Formatting Created using spr 1.3.4 * Rename aa to blur + add comment Created using spr 1.3.4 --- node-graph/gstd/src/brush.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/node-graph/gstd/src/brush.rs b/node-graph/gstd/src/brush.rs index 9984ad59..2e4a5a33 100644 --- a/node-graph/gstd/src/brush.rs +++ b/node-graph/gstd/src/brush.rs @@ -99,12 +99,17 @@ impl Sample for BrushStampGenerator

{ fn sample(&self, position: DVec2, area: DVec2) -> Option

{ let position = self.transform.inverse().transform_point2(position); let area = self.transform.inverse().transform_vector2(area); + let aa_blur_radius = area.length() as f32 * 2.; let center = DVec2::splat(0.5); let distance = (position + area / 2. - center).length() as f32 * 2.; - let result = if distance < 1. { + let edge_opacity = 1. - (1. - aa_blur_radius).powf(self.feather_exponent); + let result = if distance < 1. - aa_blur_radius { 1. - distance.powf(self.feather_exponent) + } else if distance < 1. { + // TODO: Replace this with a proper analytical AA implementation + edge_opacity * ((1. - distance) / aa_blur_radius) } else { return None; };