Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add noise to blur shaders#1518

Merged
yshui merged 7 commits into
yshui:nextfrom
anthonyde:blur-noise
Jun 1, 2026
Merged

Add noise to blur shaders#1518
yshui merged 7 commits into
yshui:nextfrom
anthonyde:blur-noise

Conversation

@anthonyde

Copy link
Copy Markdown
Contributor

This patch series adds noise to blur shaders that can be used to create a frosted glass effect.

Noise can be configured using the --blur-noise-radius and --blur-noise-scale options, or in the blur section of the configuration file:

blur: {
  method = "dual_kawase";
  strength = 16;
  noise-radius = 80;
  noise-scale = 0.5;
};

Closes #1015

Comparison

dual_kawase blur (strength=16, noise-radius=80, noise-scale=0.5):

0-none 10-r80-s5-kawase
Background Window

3x3 box blur with various noise-radius/noise-scale values:

r=10 r=20 r=50
s=0.005 1-r10-s005-box 4-r20-s005-box 7-r50-s005-box
s=0.05 2-r10-s05-box 5-r20-s05-box 8-r50-s05-box
s=0.5 3-r10-s5-box 6-r20-s5-box 9-r50-s5-box

@yshui

yshui commented May 13, 2026

Copy link
Copy Markdown
Owner

wow, thanks. this is a very interesting effect. i haven't read your code yet, just wondering, does this have to be tied with blur? can this be a separate effect by itself? seems like it works a lot better with box blur than with dual-kawase?

@anthonyde

Copy link
Copy Markdown
Contributor Author

It could be done separately from the blur effect, but that seems like it would complicate the implementation since the non-blur case would have to handle the distortion either in the window shader or in a separate render command (but in that case I'd have to duplicate some of the back buffer code from blur). I didn't think there would be much use for this without any blur, so I didn't try to figure that out.

The effect is more subtle in the dual_kawase sample because the blur is more uniform with that configuration. Here's what it looks like with a different configuration (strength=4, noise-radius=80, noise-scale=0.05):

11-r80-s05-kawase-4

Comment thread src/backend/gl/blur.c
anthonyde added 2 commits May 31, 2026 16:52
A base struct is defined for arguments common to all blur methods.

The create_blur_context interface method is changed to accept a pointer
to the base type instead of a void pointer. It can't be a
pointer-to-const because generate_dual_kawase_params may modify it.

Changelog: Internal: Breaking changes to backend API: a `base` field of
type `struct blur_args` is added to each blur args struct; the interface
method `create_blur_context` now accepts `struct blur_args *` instead of
`void *`.
Blur noise options are currently unused.

Changelog: NewFeature: `--blur-noise-radius` and `--blur-noise-scale`
global options are added for noise configuration.

Changelog: NewFeature: `noise-radius` and `noise-scale` options are
added to the `blur` configuration section.
anthonyde added 5 commits May 31, 2026 16:59
ctx is not used after it is set to NULL.
The extension string is always empty when building the kernel blur
shader.
This change is needed to apply noise with kernel blur, which requires
normalized texture coordinates in the final pass.

It is no longer necessary to track the presence of the pixel_norm
uniform, since all passes now use it.
Two new uniforms are defined for noise configuration. They are currently
unused.

This also corrects an off-by-one error in NUMBER_OF_UNIFORMS.
If configured, noise displaces texture coordinates when sampling a
blurred window background with any blur method. This can be used to
create a rippled (low scale) or frosted glass (high scale) effect.

The radius of the noise limits the displacement amount. This allows
only features within the radius to contribute to the distorted
background.

Noise is only implemented for the OpenGL backend, and is only enabled
when a blur method is configured. Noise is not applied to shadows.

The Simplex noise implementation uses MIT-licensed shader code from
Ashima Arts. See https://github.com/stegu/webgl-noise

Changelog: NewFeature: Blur noise is implemented for the OpenGL backend.
@yshui

yshui commented May 31, 2026

Copy link
Copy Markdown
Owner

force pushed to fix coding style, otherwise LGTM.

@yshui yshui enabled auto-merge May 31, 2026 16:03
@yshui yshui merged commit bef564e into yshui:next Jun 1, 2026
13 checks passed
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.

[Feature request] Option to add noise to blur

2 participants