Issues with flickering/pop-in depth of field effect with Post Processing v2

Hi,

I’m currently using the Built-in Render Pipeline with the Post Processing v2 stack, (Version 2.3.0) and I’m having issues flickering issues with the depth of field effect. Right now, I’ve got sprite renderers to render all the objects in the game, and they are set to use a shader that writes to the depth buffer. The shaders I’m using can be found here: GitHub - traggett/UnitySpriteShaders: An Uber Shader for rendering Sprites in Unity.

I’m using the depth of field effect to achieve a “tilt-shift” look, and it does mostly work, but it often has issues with certain objects; They tend to flicker in/out of focus and the effect is inconsistent with certain larger sprites.

Here’s a video of the issue:

You can see that the trees, especially at the bottom tend to flicker in/out of focus as the camera moves.
Here’s how the scene is set up from a side-view:

And here are the depth of field settings:
6414234--716571--Unity_2020-10-13_12-44-05.png

I’ve tried adjusting the clipping planes on the camera, adjusting anti-aliasing settings, and depth of field settings but nothing has alleviated or solved the issue. Has anyone had this issue before and have any advice?

Thanks!

Found a solution to the problem, GPU instancing must be disabled on the material(s). I’m not entirely sure why yet, but that fixes the issue. If someone has an explanation why GPU instancing affects this, please let me know!