Skip to content

Commit df261f9

Browse files
bderodnfield
authored andcommitted
Fix minor mask blur issues (flutter#149)
1 parent 68d88ae commit df261f9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

impeller/entity/contents/filters/border_mask_blur_filter_contents.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ bool BorderMaskBlurFilterContents::RenderFilter(
9292

9393
VS::FrameInfo frame_info;
9494
frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1));
95-
auto scale = entity.GetTransformation().GetScale();
96-
frame_info.sigma_uv = Vector2(scale.x, scale.y) *
97-
Vector2(sigma_x_.sigma, sigma_y_.sigma).Abs() /
95+
frame_info.sigma_uv = Vector2(sigma_x_.sigma, sigma_y_.sigma).Abs() /
9896
input_snapshot->texture->GetSize();
9997
frame_info.src_factor = src_color_factor_;
10098
frame_info.inner_blur_factor = inner_blur_factor_;

impeller/entity/shaders/border_mask_blur.frag

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ const float kHalfSqrtTwo = 0.70710678118;
3333

3434
// Indefinite integral of the Gaussian function (with constant range 0->1).
3535
float GaussianIntegral(float x, float sigma) {
36-
return 0.5 + 0.5 * erf(x * (kHalfSqrtTwo / sigma));
36+
// ( 1 + erf( x * (sqrt(2) / (2 * sigma) ) ) / 2
37+
// Because this sigmoid is always > 1, we remap it (n * 1.07 - 0.07)
38+
// so that it always fades to zero before it reaches the blur radius.
39+
return 0.535 * erf(x * (kHalfSqrtTwo / sigma)) + 0.465;
3740
}
3841

3942
float BoxBlurMask(vec2 uv) {

0 commit comments

Comments
 (0)