Post Processing with multiple cameras is currently very problematic

An alpha preservation checkbox has been added in Unity 6000.0.0 Beta 16. Thank you to everyone who contributed to the thread and submitted a use case!
___________________

Having multiple cameras stacked on top of each other with discrete Post Processing effects is currently imposible on URP without complicated work arounds.

The most sensible approach to achieve “stacked post processing” would of course be to use the URP camera stacking, with different post processing volumes for each camera.
problem: A post processing volume applied to any of the overlaid cameras also gets applied to every camera underneath it in the stack.
Since that’s not acceptable, the next thing that comes to mind would be to use the same approach people used before in-engine camera stacking was a thing: Render Textures.
problem: A render texture does not retain transparency when the camera rendering to it has urp post processing enabled, meaning you cannot stack render textures with post processing since only the top-most one would be visible.

I am yet to find any simple approach for stacked post processing, even though this issue and the problems listed above have been brought up multiple times. Here’s some examples:

https://www.reddit.com/r/Unity3D/comments/i3bmz2/applying_totally_discrete_postprocessing_to/

Any solution that doesn’t require advanced knowledge of rendering-related coding would be greatly appreciated, but i see it as an issue that should be officially addressed by unity, since camera stacking was introduced specifically to make stuff like this easier, yet instead made it signifficantly harder.

edit: More examples of people facing the same problem:

This is a widespread issue. I understand that URP is still under development, but with so many people looking for a solution and there currently being no work around, i feel like this has to be addressed.

40 Likes

Same issue here

4 Likes

This is actually not a trivial issue. As I understand it, the difficult part is handling alpha for stuff like bloom and depth of field that changes alpha of a source image. It is also not clear how to handle stuff like blending bloom, because it would be blended additively to the image rendered by an overlay camera, but alpha-blended to the image rendered by the base camera (since it will be a part of the overlay camera’s rendering result), so it would produce incorrect look. I would also guess that postprocessing does not preserve alpha because handling it would add unnecessary complexity and performance cost.
If you only need to apply stuff like color grading (or anything that does not affect alpha), there is a relatively simple way of doing it. It requires rendering overlay camera to a render texture instead of stacking, and then using a scriptable renderer feature to save alpha before PP to a separate render texture to use it later to blend postprocessed image to base camera’s color target. I can describe the process in more detail if anyone needs it, but then again, it makes sense only for effects that do not alter alpha.

3 Likes

What you’re saying about alpha makes a lot of sense, but before transitioning to URP, as in on the default unity renderer, i used RenderTextures for camera stacking and everything worked and looked perfectly fine. The RenderTextures kept the transparency and the bloom looked completely passable to me, even though, as you said, it was alpha-blended to the lower cameras.
The work around for color grading does seem like a good idea. However from what i’ve seen bloom and motion blur seem to be the most popular effects. My project specifically benefits a lot from these two visually.
If possible, i feel like the perfect solution would be the ability to force PostProcessing to preserve alpha, even with the performance hit that you mentioned. Though that would be for the folks at Unity to figure out.
Thanks for the reply.

1 Like

I agree that having a flag to preserve alpha is needed. I’m going to have to make my own post processing effects+effect system for my character screen (render texture in the UI, like in Oblivion) because PPS doesn’t support alpha sigh

2 Likes

Yes I need RenderTexture with PostProcessing to support alpha

3 Likes

How can we communicate this need to Unity? They don’t seem to read the forums much, and apart from the new questionnaire thing (to which I doubt they will be reading all of the text-based questions) there is essentially no way to communicate with the devs…

1 Like

From what i can gather, Unity’s preffered way of communicating feedback like that is specifically through the forums, so i guess what we’re doing right now is as much as we can do. I hope that if the thread stays “alive” for long enough, someone up there is eventually gonna have to respond to it.

To anyone who just stumbled upon this thread having the same issue: Please post a reply saying that you’re also struggling with this. This will keep the thread up in the thread list and when Unity finally decides to read it they’ll know that this is a problem affecting many users.
I’m not asking to spam, just post a single reply if you’re affected.

1 Like

I found a hacky solution that works for me.

The post processing frag shader (UberPost.shader) applies 1 to the alpha. All you need to do to fix this is to apply the original color to alpha. It’s true that certain effects may not work with this, but I think at least allowing it in the first place is important!

Note that simply modifying the UberPost shader will only fix the alpha issue if you do not use FXAA - if you do, you’ll need to modify the FinalPost.shader. Also, it’s not perfect, since of course the various AA’s do not handle alpha.

In other words, very hacky, only works in certain cases.

3 Likes

We’re finally onto something! From what i understand, what you’re essentially doing is replacing the final alpha (1.0) with the original input alpha, yes? That would mean that all strictly color-related effects now work with transparency. Amazing! I’ll have to keep bothering Unity for bloom and motion blur though. Still, this work-around should be sufficent for a lot of people. Thanks a lot!

2 Likes

hey @dev_34Disorder , this requires Post Processing composition which we don’t currently support in URP. Would you mind adding a feature request into our Product board so we could take this into consideration?

7 Likes

Thank You, i’ve submitted the idea. Never heard of such a thing as a Unity product board before.
Could You elaborate on what Post Processing composition means? It might improve my understanding of the issue.

Ran into this recently when trying to apply a tonemap and noticed a doubling-up effect.

dev_34Disorder can you provide the link to the product board ticket so we can endorse it.

1 Like

I don’t think that’s how that works. When i sent the thing on Productboard all it asked me for is to confirm my email and then showed this:

(“Browse other ideas” just took me to the main page with the things that Unity already implemented).

As far as i’m aware, it’s entirely private. I guess what you could do is submit your own ticket, this way they’ll know that this as an issue affecting multiple people.

2 Likes

I am also unable to separate post processing from gameplay and UI. Major road block using volume mask.
Tried both camera stack and 2 separate base cameras.
Has anyone come up with a solution? Is it a missing feature? Is it a bug?

1 Like

Looking for a solution to this as well, is there a workaround to get this working at least for the basic post processing features (color/brightness/contrast for example)?

1 Like

Still no solution so far. As far as i understand the reason for this problem is that post processing does not deal with alpha in any way, meaning it can’t take in an image with transparency and work with it for camera stacking (although that’s also a problem with camera stacking itself) nor can it produce an image with transparency for render texture stacking.
Pretty much the only thing we can do right now is submit tickets to https://portal.productboard.com/unity/1-unity-graphics/tabs/3-universal-render-pipeline asking for post processing to work with camera stacking. I already did this but if they receive requests from multiple people about the same thing they’ll probably take it more seriously.

1 Like

Take a look at joshcamas’ latest reply (post #9.) It should work fine for effects like this that don’t change transparency but you’ll have to use stacked render textures as opposed to camera stacking (just make all the cameras output to render textures and display them through GUI as raw image objects.)

Yeah I was trying to avoid that. I suppose the other alternative is writing a custom UI shader that would allow me to adjust colour & contrast? I believe that may be possible.

1 Like

Yeah, that should work. I guess a fullscreen image effect with a layer mask for whatever you want it to apply to would do the trick but there might be some better way. Feel free to report back here if you figure anything out, it might help other people.