Search Unity

Question Is it really impossible to achieve the depth-of-field (blurring background) effect in 2D with URP?

Discussion in 'Universal Render Pipeline' started by znagler, Oct 10, 2022.

  1. znagler

    znagler

    Joined:
    Sep 25, 2022
    Posts:
    9
    Hi,

    It's hard for me to believe, but it seems impossible to make depth-of-field work (blurring the distance) in 2D games with URP. This seems like such a basic/important visual (which makes Hollow Knight and many other games look great). Here is my experience:

    • If you use a depth-of-field post-processor in 2D, it just blurs everything. The Gaussian/bokeh knobs don’t work (see this thread). The workaround that people seem to use is to make two separate cameras (one for background and one for everything else), and apply depth-of-field post processing to only the background camera. This achieves the goal pretty nicely for non-URP games.
    • But in URP you can’t do multiple camera rendering EXCEPT “Base” and “overlay”. For the background-blur effect, you need a background camera, not an “overlay” camera in front, which is the only option. I don't think you can move the Overlay to be behind the Base (and if you can, it would be a hack since Overlay is designed for being in front). This was easily doable before URP with the “depth” property, but that's gone now as shown in the unity docs.
    Has anyone figured out a way to do this? I can't find any working example and it's frustrating. Thanks.
     
    RemDust and KnuckleCracker like this.
  2. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    432

    Already came to the same conclusion and I just think it's just CRAZY that there is still no solution for this.
    Unity was kind of proud to say about Hollow Knight "hey, look at gorgeous we can make a game in Unity with basic technics, so imagine what you will be able to do with our new gen pipeline !"

    Well, Team Cherry was very lucky (or clever) to work with the Built In Renderer ! xD
     
  3. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,086
    Yes, they did a lot of texture customisation and swapping to get the DOF effects looking good. Same with Ori.

    It would be wonderful if an "out of the box" DOF effect worked well.
     
  4. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    432
    Nope, they actually used a gaussian blur FX as you may think, they used a mesh plan with a blur shader right behind the player plan, in front of every background assets.
    But at that time the Built In renderer was used and there was a lot of great shaders available on the assetstore for this pipeline... :)
     
    Unifikation likes this.
  5. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,086
    Still are and still is. I keep trying URP, but it's still just a trier.
     
    RemDust likes this.
  6. Scala28

    Scala28

    Joined:
    Jan 14, 2022
    Posts:
    1
    Hi, maybe I'm late and you already figured out another way to achieve the effect you are looking for. I had the same issue trying to achieve the depht of field effect, and as you say the problem is that the overlay camera renders in front of the Base camera; so I simply added another overlay camera that renders everything (except for the background) and you can define which camera render on top of the other. I found this helpfull:
    (just watch from minute 17:20)