Depth of Field issue: Blur overwritten by meshes further away

It’s hard for me to make a playground to reproduce the issue since it actually works correctly in the sandbox. But for some reason the rendering order is off. Even disabling depth in the engine options makes no difference. I’m using the DefaultRenderingPipeline in BabylonJS 5.6. Could anyone point me in the right direction for how to debug this?

1 Like

This would be extremely hard without a repro unfortunately :frowning: could you try to make the most minimalistic experience possible in the playground so that I can have a look ?


Hi @sebavan makes complete sense.
Even though it worked in the sandbox out of the box, I’m able to reproduce it in the playground (thank god).
If you can, please take a look:

Not really sure if its a bug or just not the right settings for the filter?

I think the problem is the fStop and distance.
Here is an example with tweaked values.

That’s making the one in the back blurry, I’m hoping to blur the one in the front :slight_smile: what seems to happen when I do that is that the blur of the front sphere is cut off where the second one starts.

1 Like

hmm yeah I see what you are saying, no matter what the settings are the shading line between them is very sharp when trying to just blur the front sphere.

This is unfortunately an artifact from the technique we use :frowning: I will see if there is anything we can improve without an extreme added cost.

But basically at the moment we use the depth where we figure we are on a target so no blur to use :-*( and I am not sure how we could know the other sphere blur should be on top without lots of texture samples around.

@sebavan Ah that’s a bummer, I do think I have something working when looking at this example:

Would you know what the difference is between the two?

It might be more visible with a smaller focal length I guess.

Will you always know which object you are trying to focus on? @Sem

If so you could do two passes, one for the blurred stuff and then one for focused thing and then combine them.

nope as it is distance based :slight_smile:

1 Like

I’m talking specifically in this person’s setup. If they have a certain setup and it’s not needing to be dynamic I’m pretty sure you could do this.

What about checking on the camera distance to target to object to adjust fStop?
Something like this (sry for the dirty PG, it’s just ment for design thinking)

Edit: Worked it just a little realizing you want the targeted sphere blured and objects in the back not blured. I guess it can be worked with adjusting lensSize and Distance based on camera from target.
Still just a rough idea though