Skip to content

GaussianBlurNode: Merge adjacent taps into bilinear fetches. - #34478

Open
mrdoob wants to merge 1 commit into
devfrom
gaussianblur-linear-sampling
Open

mrdoob wants to merge 1 commit into
devfrom
gaussianblur-linear-sampling

Conversation

@mrdoob

@mrdoob mrdoob commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Pairs of adjacent Gaussian taps are fetched once at their weighted offset, relying on the linear filtering of the render targets (the same linear-sampling trick BloomNode already uses). Taps per pass drop from 2 * kernelSize - 1 to kernelSize: 21 to 11 at the default sigma, 45 to 23 at sigma 10. The premultiplied alpha path keeps single taps, since the hardware lerp happens before the per-tap premultiplication.

Measured on an M1 with GPU timestamps (blur passes only, contenders interleaved in one page):

Input sigma before after
pass() texture, 1080p 4 3.41 ms 1.87 ms
pass() texture, 1080p 10 8.07 ms 3.81 ms
pass() texture, 4K 4 13.2 ms 7.0 ms
pass() texture, 4K 10 32.9 ms 14.7 ms

Output is unchanged in exact arithmetic; on hardware the result differs by at most one 8-bit step on 0.6% of pixels (half-float: 1 to 2 ulp). The e2e screenshots for webgpu_postprocessing_lensflare, webgpu_volume_lighting, webgpu_mrt_mask and webgpu_shadow_contact pass with 0.0% diff.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LfmxBc2caqoNZRmM44vCgF

const wb = ( step === 2 && i + 1 < kernelSize ) ? gaussianCoefficients[ i + 1 ] : 0;

const x = float( ( i * wa + ( i + 1 ) * wb ) / ( wa + wb ) );
const w = float( wa + wb );

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good as in BloomNode but there is one behavior change:

If a user passes a nearest filtered texture to the blur node, the merged fetch snaps to one texel instead of blending two. This is not an issue in the bloom code because the blur operators only on internal render targets which never end up nearest filtered.

Blurring a nearest-filtered texture is a valid use case and it seems this PR would introduce a regression.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants