- Home /
How to get quality Depth Of Field effect with Post Processing Stack V2?
When using the Post Processing Stack V2 Depth Of Field effect in my game, I'm finding that at a certain distance objects abruptly transition from no blur at all, to very heavy blur (see attached image). The blur does not increase gradually with distance from the camera as expected.
I've played with the Aperture, Focal Length and Max Blur Size settings, but haven't found a way to fix this immediate transition from no blur to heavy blur.
Has anyone else encountered this problem and found a way to get a more natural blur transition out of this effect?
(I also tried the Universal Render Pipeline's Depth of Field effect, and it doesn't have this problem -- it works beautifully. However, the URP's motion blur effect doesn't blur objects that are in motion (just camera motion), so switching to URP is not an option for my game.)
I won't put this as an answer, because it is very objective, but I personally don't think you can get quality DOF with the post-processing stack's default effects. They have a really wide linear blend that looks horrible, combined with the realistic CoC calculation means that most regions will be somewhere inbetween blurred and clear. The legacy image effect's depth of field handled this really well by running two filters - one at low res, and a cheaper one at full res such that the blend was impossible to see, but those have been deprecated and cannot be accessed anymore (also probably wouldn't be compatible with the rest of the stack). I personally use my own depth of field for this exact reason, but that isn't really an option for most people as these kinds of effects are not easy to write and have very little documentation. Catlike coding has a great DOF tutorial as a starting place, but it's purpose is literally to recreate this exact effect, so you would need to modify it (mainly just reduce the range over which blending occurs);
https://catlikecoding.com/unity/tutorials/advanced-rendering/depth-of-field/
@Namey5 Thanks for the info! The catlikecoding tutorial looks potentially useful. I don't suppose you would be interested in selling your custom DoF solution on the asset store?
I have always planned on doing so (here's a video of it from a year ago where I say that), but it still requires a decent amount of optimisation and quality work. I'm currently in the middle of updating it and also transitioning to the post-processing stack (as that wasn't customisable when I first wrote it). I also wrote a cheap gaussian DOF a couple of weeks ago as a test effect for the stack that I would be happy to put up on github (although it only handles blur from near or far plane, not both simultaneously).
Answer by Logopolis · May 12, 2020 at 01:57 AM
Update for anyone else having a similar problem:
After trying several alternatives I found the Beautify 2 asset (https://assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/beautify-2-163949). It includes a fast, high quality, mobile friendly depth of field effect (as well as a bunch of other post processing effects). I chose to turn off its default effects that amp up saturation, contrast and sharpness. It's worth the price for the depth of field effect alone.
Here's an example of a similar scene to above, but using Beautify 2's depth of field instead of the post processing V2 effect. Notice that the transition from sharp to blurry is gradual. Also note that it has the option to blur near objects as well as far objects.
Your answer
Follow this Question
Related Questions
Modify values on VolumeProfile URP. 1 Answer
How to properly use RTHandles in HDRP for post effects 0 Answers
Custom post processing 0 Answers
(Unity 2019.2) Post Processing errors with Deferred Rendering Path 1 Answer
Custom URP Postprocessing 0 Answers