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:
- Render the background to buffer A.
- Render the foreground to buffer B, and save the depth.
- 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):
- I created 3 cameras: Foreground Camera, Depth Camera (only render the foreground), and a Background Camera.
- 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):
- The Foreground Camera is set to Tag=MainCamera, and when I enable
Post Processingand add an effect, indeed we can see it. (as expected) - 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:
- When using
Volume Maskon my background layer, the Post processing just turns off, no effect at all no matter what (and I have set my background theBackgroundlayer). - 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.
- When I set
Volume MasktoDefault(or everything), the result is shown ONLY in the scene view, I tried rendering the camera to aRenderTexturebut still, you clearly see no effect applied!