Flickering when updating kernel of BlurPostProcess

Hi folks, not sure if this is a bug or if I’m not using BlurPostProcess as intended. When changing the kernel value of BlurPostProcess, the screen flickers. Here’s an example of the behavior:

You can see that after the initial animation to kernel 25, the flickering stops. I think it might be related to compiling the effect, and once it’s cached, everything is smooth?

I’m looking for a way to animate the blur effect, so if there’s another way to do that, or maybe to pre-compile certain kernel levels to avoid the flickering, I’m interested in hearing about it!

I managed to come up with a workaround for the flickering using multiple BlurPostProcess objects and attaching/detaching them.

I wonder if PostProcess objects can provide an async compilation function like this one Material | Babylon.js Documentation

Yes, that is the reason why it is flickering.

That’s what I was going to suggest :slight_smile:

That would not fix the problem because while it is compiling we would not have any effect to use to render the post process, hence the flickering.

What we could do maybe is to keep the current effect while the new one is compiling, and when it is ready replace the current by the new one… I will have to discuss this with the team.

Yeah, I was just thinking this would be a “nice to have”, not necessarily to fix this issue. I suppose it should be fairly trivial to implement myself though using _blockCompilation = true and updateEffect callbacks.

I think that would be a nice feature for PostProcess effects in general since then they would work similarly to materials. Though I don’t know how common this case is.

Here’s a way to do it by hooking PostProcess.update:

1 Like

The main issue is to deal with uniform or sampler changes for instance as we tried to do in materials :slight_smile:

I am wondering how frequently we are using defines or dynamic code in Post processes. I would say let’s bookmark this thread and improve this part next time we face the issue ? as it will complexify the code a bit and I d like to only do it if absolutely required ?

No problem, I provided a PG that is able to do it for cases where the new effect has the same uniform/sampler lists (as it is the case when we simply update the kernel value of BlurPostProcess).