Skip to content

Commit 20d45e0

Browse files
committed
Use the size of the input texture
to calculate the texel size for sampling
1 parent e53967e commit 20d45e0

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/passes/GaussianBlurPass.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,21 @@ export class GaussianBlurPass extends Pass<GaussianBlurMaterial> {
160160

161161
protected override onResolutionChange(): void {
162162

163-
const resolution = this.resolution;
164-
const width = resolution.width;
165-
const height = resolution.height;
163+
const inputBuffer = this.input.defaultBuffer?.value ?? null;
164+
165+
if(inputBuffer === null) {
166+
167+
return;
166168

167-
this.renderTargetA.setSize(width, height);
168-
this.renderTargetB.setSize(width, height);
169+
}
170+
171+
const resolution = this.resolution;
172+
this.renderTargetA.setSize(resolution.width, resolution.height);
173+
this.renderTargetB.setSize(resolution.width, resolution.height);
169174

170-
// Optimization: 1 / (TexelSize * ResolutionScale) = FullResolution
171-
this.blurMaterial.setSize(resolution.baseWidth, resolution.baseHeight);
175+
// Use the size of the input texture to calculate the texel size for sampling.
176+
const imgData = inputBuffer.source.data as ImageData;
177+
this.blurMaterial.setSize(imgData.width, imgData.height);
172178

173179
}
174180

0 commit comments

Comments
 (0)