Skip to content

Commit

Permalink
Use the size of the input texture
Browse files Browse the repository at this point in the history
to calculate the texel size for sampling
  • Loading branch information
vanruesc committed Jan 27, 2025
1 parent e53967e commit 20d45e0
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/passes/GaussianBlurPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,21 @@ export class GaussianBlurPass extends Pass<GaussianBlurMaterial> {

protected override onResolutionChange(): void {

const resolution = this.resolution;
const width = resolution.width;
const height = resolution.height;
const inputBuffer = this.input.defaultBuffer?.value ?? null;

if(inputBuffer === null) {

return;

this.renderTargetA.setSize(width, height);
this.renderTargetB.setSize(width, height);
}

const resolution = this.resolution;
this.renderTargetA.setSize(resolution.width, resolution.height);
this.renderTargetB.setSize(resolution.width, resolution.height);

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

}

Expand Down

0 comments on commit 20d45e0

Please # to comment.