Skip to content

Commit 848e23f

Browse files
Fix blur artifacts (#518)
Following https://github.com/webgpu/webgpu-samples/pull/181/files#r889367976 suggestion, this PR fixes blur artifacts (around the eye most notably) that happen with `filterSize: 2` and `iterations: 10`. FIX #180 <img src=https://github.com/user-attachments/assets/e47dc3f7-82cd-4b33-8afe-6df365c6ae60 width=49%> <img src=https://github.com/user-attachments/assets/7487e278-216f-4884-af92-15e14c9c2418 width=49%> <i> Before (left) / After (right)</i>
1 parent d46c701 commit 848e23f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sample/imageBlur/blur.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn main(
5050
tile[r][4 * LocalInvocationID.x + u32(c)] = textureSampleLevel(
5151
inputTex,
5252
samp,
53-
(vec2f(loadIndex) + vec2f(0.25, 0.25)) / vec2f(dims),
53+
(vec2f(loadIndex) + vec2f(0.5, 0.5)) / vec2f(dims),
5454
0.0
5555
).rgb;
5656
}

sample/imageBlur/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ const settings = {
220220

221221
let blockDim: number;
222222
const updateSettings = () => {
223-
blockDim = tileDim - (settings.filterSize - 1);
223+
blockDim = tileDim - settings.filterSize;
224224
device.queue.writeBuffer(
225225
blurParamsBuffer,
226226
0,
227-
new Uint32Array([settings.filterSize, blockDim])
227+
new Uint32Array([settings.filterSize + 1, blockDim])
228228
);
229229
};
230230
const gui = new GUI();

0 commit comments

Comments
 (0)