Skip to content

Commit

Permalink
Fix minor mask blur issues (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdero authored and dnfield committed Apr 27, 2022
1 parent 68d88ae commit df261f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ bool BorderMaskBlurFilterContents::RenderFilter(

VS::FrameInfo frame_info;
frame_info.mvp = Matrix::MakeOrthographic(ISize(1, 1));
auto scale = entity.GetTransformation().GetScale();
frame_info.sigma_uv = Vector2(scale.x, scale.y) *
Vector2(sigma_x_.sigma, sigma_y_.sigma).Abs() /
frame_info.sigma_uv = Vector2(sigma_x_.sigma, sigma_y_.sigma).Abs() /
input_snapshot->texture->GetSize();
frame_info.src_factor = src_color_factor_;
frame_info.inner_blur_factor = inner_blur_factor_;
Expand Down
5 changes: 4 additions & 1 deletion impeller/entity/shaders/border_mask_blur.frag
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ const float kHalfSqrtTwo = 0.70710678118;

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

float BoxBlurMask(vec2 uv) {
Expand Down

0 comments on commit df261f9

Please sign in to comment.