Skip to content

Commit 74d9fcb

Browse files
authored
Merge pull request #3 from Eskils/develop
Fix applying gradientBlur causes unintended blurring
2 parents bd34a6c + 343e9ec commit 74d9fcb

18 files changed

+30
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ let package = Package(
5151
dependencies: [
5252
.package(
5353
url: "https://github.com/Eskils/VariableBlurImageView",
54-
.upToNextMinor(from: "1.1.1") // or `.upToNextMajor
54+
.upToNextMinor(from: "1.1.2") // or `.upToNextMajor
5555
)
5656
],
5757
targets: [

Sources/VariableBlurImageView/VariableBlur.metal

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,16 @@ kernel void gradientVariableBlur(
182182
const float4 gradientValue = gradient.read(gradientGid);
183183
const half luma = ((half)gradientValue.x + (half)gradientValue.y + (half)gradientValue.z) / 3;
184184

185-
half radius = max(luma * (half)maxRadius, 1.0h);
185+
half radius = luma * (half)maxRadius;
186+
187+
float4 colorOut;
188+
189+
if (radius >= 1.0h) {
190+
colorOut = (float4)colorForBlurAtPixel(hGid, textureIn, radius);
191+
} else {
192+
colorOut = textureIn.read(gid);
193+
}
186194

187-
float4 colorOut = (float4)colorForBlurAtPixel(hGid, textureIn, radius);
188195

189196
textureOut.write(colorOut, gid);
190197
}
-646 KB
Loading
-84.3 KB
Loading
-34.5 KB
Loading
-197 KB
Loading
110 KB
Loading
102 KB
Loading
1.32 MB
Loading
1.32 MB
Loading

0 commit comments

Comments
 (0)