Unity - Post process foreground, but leave background as is

Viewed 1480

I am using Unity 2019.3.5f1 and I am using the Universal Render Pipeline (URP).

I am trying to use the post processing in URP for the foreground only (in my case, the players), and I want the leave the background (which in my case, is just a quad with a texture), as is.

I have tried using the Camera Stack but it wont work for me because the overlay camera can't have post processing effects according to the documentation.

The only solution that I could come up with is create the some sort of custom render which:

  1. Render the background to buffer A.
  2. Render the foreground to buffer B, and save the depth.
  3. Combine the two using a shader that gets both textures, and the depth texture, and based on the depth, takes buffer A or buffer B.

The problem with this I believe is that I cant use it with the post processing for Unity.

Any idea what I can do?

EDIT:

I tried another thing in Unity which seem to not be working (might be a bug):

  1. I created 3 cameras: Foreground Camera, Depth Camera (only render the foreground), and a Background Camera.
  2. I set up the Depth camera so it will render to a render texture and, indeed now I have a render texture with the proper depth I need.

Now, from here everything went wrong, there seem to be odd things happening when using Unity new Post processing (the built in one):

  1. The Foreground Camera is set to Tag=MainCamera, and when I enable Post Processing and add an effect, indeed we can see it. (as expected)
  2. The Background Camera is essentially a duplicate of the Foreground one, but with Tag=Untagged, I use the same options (enabled Post).

Now, the expected thing is we see the Background Camera with effects like Foreground, but no:

  1. When using Volume Mask on my background layer, the Post processing just turns off, no effect at all no matter what (and I have set my background the Background layer).
  2. When I disable the Foreground Camera (or remove its tag) and set the Background Camera to MainCamera, still nothing changes, the post still wont work.
  3. When I set Volume Mask to Default (or everything), the result is shown ONLY in the scene view, I tried rendering the camera to a RenderTexture but still, you clearly see no effect applied!
0 Answers
Related