Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add MultiPassKawaseBlur pass #635

Open
wants to merge 2 commits into
base: v7
Choose a base branch
from

Conversation

balraj-johal
Copy link

Related issue: #580

Description

Adds a MultiPassKawaseBlur pass,
Adds the aforementioned pass to the blur demo, comparing it against the GaussianBlur pass,
Adds associated tests.

Notes

@vanruesc I've allowed the Kawase Blur pass to be applied at a custom number of levels, as I thought this may be more flexible than the default dual pass approach. There might be tradeoffs to this I'm not aware of however, and so have made these changes in a commit I can easily revert if it's preferred to do so.

I've also left the previously existing KawaseBlurMaterial, as the Tilt Shift effect relies on it, and I wanted to get this in first.

I've left some TODO comments in the two areas I'm a little unsure about.

@balraj-johal balraj-johal changed the title Feat/dual pass kawase feat: add MultiPassKawaseBlur pass May 8, 2024
// p1.addBinding(kawaseBlurPass.fullscreenMaterial, "scale", { min: 0, max: 2, step: 0.01 });
// p1.addBinding(kawaseBlurPass.resolution, "scale", { label: "resolution", min: 0.5, max: 1, step: 0.05 });
const p1 = tab.pages[1];
// TODO: is it ok that the following two scale parameters are independant from each other?
Copy link
Author

Choose a reason for hiding this comment

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

Not sure about this: "is it ok that the following two scale parameters are independent from each other?"

Copy link
Member

Choose a reason for hiding this comment

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

It's probably not safe to scale the sampling patterns like this.

let { width, height } = this.resolution;


// TODO: unsure about what to assign as the fullscreen material when the pass requires multiple
Copy link
Author

Choose a reason for hiding this comment

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

also not sure about the following: "unsure about what to assign as the fullscreen material when the pass requires multiple"

Copy link
Member

Choose a reason for hiding this comment

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

"when the pass requires multiple..." materials? It's fine like this. The fullscreenMaterial can be set to any material defined in the class declaration. Choosing a fullscreen material depends on the render task(s) that should be performed right after. Most passes only use one, but switching is fine too.

@balraj-johal balraj-johal marked this pull request as ready for review May 8, 2024 22:35
@vanruesc
Copy link
Member

I'm a bit short on time right now - I'll take a look when I'm free.

@vanruesc
Copy link
Member

This Dual Kawase implementation looks very similar to the existing MipmapBlurPass. The sampling pattern is different, but there's not much else that distinguishes the two passes.

It seems like this implementation introduces aliasing and shimmering when the scale is set to anything other than 1.0. Scaling the kernel is tricky since it affects the stability of the blur. There might also be something wrong with the sampling pattern since it seems to produce diamond shaped artifacts.

The existing MipmapBlurPass produces stable blurs when the radius is set to 1.0 and seems better overall. I kind of expected the Dual Kawase algorithm to be more complex, but if it's basically another mipmap blur, we can probably bin it.

I'm not completely sure about that though - I'll need to take a closer look at the reference materials at some point.

* @category Effects
*/

export class MultiPassKawaseBlurEffect extends Effect {
Copy link
Member

Choose a reason for hiding this comment

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

There's no need to create an effect for a blur pass - the TextureEffect can be used to draw the blurred image.

* @category Passes
*/

export interface MultiPassKawaseBlurPassOptions {
Copy link
Member

Choose a reason for hiding this comment

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

The pass should be named DualKawaseBlurPass.

// p1.addBinding(kawaseBlurPass.fullscreenMaterial, "scale", { min: 0, max: 2, step: 0.01 });
// p1.addBinding(kawaseBlurPass.resolution, "scale", { label: "resolution", min: 0.5, max: 1, step: 0.05 });
const p1 = tab.pages[1];
// TODO: is it ok that the following two scale parameters are independant from each other?
Copy link
Member

Choose a reason for hiding this comment

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

It's probably not safe to scale the sampling patterns like this.

let { width, height } = this.resolution;


// TODO: unsure about what to assign as the fullscreen material when the pass requires multiple
Copy link
Member

Choose a reason for hiding this comment

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

"when the pass requires multiple..." materials? It's fine like this. The fullscreenMaterial can be set to any material defined in the class declaration. Choosing a fullscreen material depends on the render task(s) that should be performed right after. Most passes only use one, but switching is fine too.

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.

None yet

2 participants