Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feature Request Post Processing with multiple cameras is currently very problematic

Discussion in 'Universal Render Pipeline' started by dev_34Disorder, Dec 26, 2020.

  1. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    The Unity team is planning to resolve this issue. Please submit your use case here to help with proper implementation. Big thanks to Ali Mohebali!
    ___________________


    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://forum.unity.com/threads/cam...y-different-post-processing-to-the-ui.830778/
    https://www.reddit.com/r/Unity3D/comments/i3bmz2/applying_totally_discrete_postprocessing_to/
    https://forum.unity.com/threads/ren...rking-anymore-in-urp-coming-from-lwrp.749441/
    https://issuetracker.unity3d.com/is...when-post-processing-is-enabled-on-the-camera

    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:
    https://forum.unity.com/threads/urp-post-processing-just-one-layer.984712/
    https://forum.unity.com/threads/post-processing-on-specific-stack-layer.938363/
    https://forum.unity.com/threads/post-processing-volume-multi-camera-question.917000/
    https://forum.unity.com/threads/post-processing-different-per-camera.517166/

    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.
     
    Last edited: May 15, 2023
    d0dler, Gasimo, tbg10101_ and 35 others like this.
  2. diesersam

    diesersam

    Joined:
    Sep 15, 2018
    Posts:
    4
    Same issue here
     
  3. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    120
    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.
     
    Prodigga, niallmc and dev_34Disorder like this.
  4. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    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.
     
    hkalterkait likes this.
  5. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,276
    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
     
  6. KisKil

    KisKil

    Joined:
    Sep 13, 2014
    Posts:
    1
    Yes I need RenderTexture with PostProcessing to support alpha
     
  7. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,276
    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...
     
    dev_34Disorder likes this.
  8. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    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.
     
    hkalterkait likes this.
  9. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,276
    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.
     
  10. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    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!
     
    JesOb and joshcamas like this.
  11. erikabar

    erikabar

    Unity Technologies

    Joined:
    Jan 26, 2017
    Posts:
    36
    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?
     
  12. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    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.
     
  13. Jessespike

    Jessespike

    Joined:
    Jul 9, 2012
    Posts:
    44
    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.
     
    Last edited: Jan 21, 2021
    dev_34Disorder likes this.
  14. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    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.
     
    Last edited: Feb 8, 2021
    joshcamas and Jessespike like this.
  15. SquaLLio

    SquaLLio

    Joined:
    Jun 16, 2019
    Posts:
    9
    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?
     
    dev_34Disorder likes this.
  16. JTAU

    JTAU

    Joined:
    May 12, 2019
    Posts:
    24
    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)?
     
    dev_34Disorder likes this.
  17. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    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.
     
    Lars-Steenhoff likes this.
  18. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    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.)
     
    Last edited: Feb 8, 2021
  19. JTAU

    JTAU

    Joined:
    May 12, 2019
    Posts:
    24
    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.
     
    dev_34Disorder likes this.
  20. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    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.
     
    Last edited: Feb 13, 2021
  21. lennardbeers

    lennardbeers

    Joined:
    Apr 28, 2017
    Posts:
    10
    I really need to apply Post Processing to different layers/cameras/objects. Why is Post Processing even a available when this is not possible? Who wants to apply color grading also to the UI??
     
  22. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,221
    Could you update the comparison tables?
     
    joshcamas and dev_34Disorder like this.
  23. Annoyedb

    Annoyedb

    Joined:
    May 22, 2014
    Posts:
    1
    Adding my reply here to make it known we still want Post Processing composition for URP.

    ... which I made the mistake of assuming was an already built-in feature.
     
    mowax74 and dev_34Disorder like this.
  24. RoyBarina

    RoyBarina

    Joined:
    Jul 3, 2017
    Posts:
    98
  25. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    I'm using split screen, with 2 cameras, will this also apply in my case?
     
    dev_34Disorder likes this.
  26. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    If both sides of the screen have only one camera with no camera overlaying/stacking then you should be fine, although i've no idea how PPV deals with viewport rect, which i'll assume you're using. And if you want different effects or no effects for the GUI then you're out of luck :/
     
    SertanC and joshcamas like this.
  27. StrongCube

    StrongCube

    Joined:
    Nov 22, 2016
    Posts:
    50
    Same problem... another rake (
     
    SertanC and dev_34Disorder like this.
  28. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Hey all, in trying to upgrade my own project (which successfully used stacked cams with post-pro on different ones) I've run into this same error so came across this thread.

    What are the main effects everyone is using in scenarios like this? IE: Bloom, color correction, ? May look at building this functionality into my own postpro seeing as it'll probably take Unity another 12 months as per usual.

    For those wanting a quick fix, writing your own custom PostPro shader that just renders to a RT does 'work' - the finicky thing is managing the RT (across screen sizes, dynamic resolution, canvases, etc). You'll also lose some potential performance this way, as it costs another FS blit + read vs doing it all 'properly', and if you have effects like barrel distortion on an earlier camera, that affect the UV of the scene, good luck.
     
    dev_34Disorder likes this.
  29. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    Very happy to see the initiative!
    Joshcamas figured out a way to keep transparency for render textures (see post #9), but that only works for effects that don't change alpha, so right now we're looking for a way to make things like bloom and motion blur work, since those affect the final transparency.
    As for the custom shader fix, i'm not exactly adept at this kind of stuff ^_^" so if anyone wants to give it a try then please report back here with how it went, that'd be super cool.
    Again, thanks for the initiative and good luck!
     
    GoGoGadget likes this.
  30. blanc_digital

    blanc_digital

    Joined:
    Dec 12, 2020
    Posts:
    1
    +1

    This feature would be really useful in AR apps so you could, for example, add bloom to a 3D character without adding bloom to the real world around it.
     
    Last edited: Mar 5, 2021
  31. abj2023

    abj2023

    Joined:
    May 21, 2013
    Posts:
    11
    i have this problem as well. What should I do? My UI and in game need different effects.

    Unbelievable
     
    mowax74, ExtraCat, niskander and 3 others like this.
  32. anthonov

    anthonov

    Joined:
    Sep 24, 2015
    Posts:
    160
    I was looking for a way to have another bloom dedicated to my UI. Im surpised this is not possible.
     
  33. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    Oh wow, i didn't even think how problematic this is when it comes to AR. Now i'm even more upset haha

    Take a look at post #28, but you'll have to know about all that fancy shader stuff to try n pull it off, and you may lose some performance apparently.

    Right there with ya...


    so
    REMINDER:
    A unity staff member in this thread said that the best way to get Unity to listen to us about this is by telling them about it through here. Apparently it has something to do with "Post Processing composition" so maybe mention that in your ticket. I've already sent my request, so if you have a moment then please do so as well. Just please don't spam them, one request per person, we don't want to be annoying about this :D
     
  34. SeanBannister

    SeanBannister

    Joined:
    Jul 13, 2020
    Posts:
    23
    I found this post because I was trying to disable Post Processing on my UI while keeping it on everything else, on first reading this thread I presumed it wasn't possible but I've found a simple solution. I don't have a need for different post processing effects on different objects. I thought I'd post this hoping it helps someone else, or in case I've completely missed something. Here's what I did:

    You need to apply separate layers to gameobjects you want post processing on and gameobjects you don't. We'll then select which layers get post processing.

    Create two cameras:
    upload_2021-3-17_0-35-52.png

    For the "No Post-Processing Camera":
    Note: Under "Culling Mask" select ONLY the layers you don't want post processing on.
    upload_2021-3-17_0-44-13.png


    For the "Base Camera" set the following:
    Note: Under "Culling Mask" select ONLY the layers you want post processing on.
    upload_2021-3-17_0-38-24.png

    This works in the game view but in the scene view you'll still have Post Processing on everything, let me know if you figure out how to fix that.
     
  35. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    The problem at hand doesn't apply in your case because our issue is that Post Processing gets applied to the camera it's tied too and all other cameras underneath it. This is not a problem for you since you want the bottom part of the camera stack affected by PP but not the top part (UI). If you instead wanted to have PP on the UI but not on all the other objects, only then you would face the difficulty.
    In terms of the scene view thing; When in scene view, you're looking at the game through the editor camera which works differently from the cameras in the scene. To make it work with PP the same way your camera stack does you'd probably have to resort to some really hacky work-arounds.
     
  36. RoyBarina

    RoyBarina

    Joined:
    Jul 3, 2017
    Posts:
    98
    Yea, I also have a setup like you @SeanBannister but I needed a slightly different bloom effect on my UI from the game
    It won't work for me because the game is getting bloom effect applied twice.. even if the effect I wanted was exactly the same I guess I can apply it to the UI and it'll "leak" to the game.. but in this way the effect looks wrong (no HDR accounting?)

    So I ended up using "half" the effect on each volume :S
    It looks OK as seen here:
     
    Last edited: Mar 18, 2021
  37. maewionn

    maewionn

    Joined:
    Jan 18, 2016
    Posts:
    37
  38. M4R5

    M4R5

    Joined:
    Apr 11, 2013
    Posts:
    33
    +1
     
    dev_34Disorder likes this.
  39. harringtonsp

    harringtonsp

    Joined:
    Apr 2, 2017
    Posts:
    6
  40. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    Details: URP 7, Unity 2020.1.17, VR and Non-VR

    Update: I just noticed the problem is in 2020.1.7. I made a small reproduction in 2020.3.6 and it seems to work there in the editor. No gray / missing items.
    My next problem is, due to an other shader I have, it is incompatible with 2020.2 or higher.
    So I am stuck on 2020.1.17 that doesn't get updates anymore. so I will probably have to work around the incompatible shader.


    I've been trying to get a blurred background while rendering UI on top that is not blurred.
    But this is seemingly difficult to achieve.
    Base camera renders Default and UI which is post processed with a gaussian blur.
    then I have an overlay camera which renders the Non-Blurred UI without post processing.

    This seems to work for Non-VR

    upload_2021-5-4_11-21-2.png

    But when I enter VR (Mock HMD Single Pass Instanced) it is not blurred and the left eye is gray and missing the blurred version
    With the Oculus Quest 1 in MultiView I get the left eye but then locked to my screen while this is a world space canvas.

    upload_2021-5-4_11-21-47.png

    The effect I am trying to achieve is that all 3D and UI on a layer is getting blurred
    While some other UI on a different layer is not blurred at all.
    I need this to work for both VR and Non-VR.

    The only workaround for VR I have in mind is to completely blacken the background and only show the non-blurred UI.
    But this is something I want to avoid of course if possible.

    So is this part of the Post Processing composition? I don't see it listed on the board yet either.

    If anyone else knows a workaround for this, please let me know. I've been trying custom shaders as well with no luck.
    Scene Color doesn't take into account the UI which needs to be blurred
    I tried a custom Gaussian implementation which didn't work for Single Pass Instancing nor was it performant and Unity doesn't seem to provide a blur filter node.
    I am not a shader nor render wizzard to do these kinds of things but after fiddling with so many things as shaders and camera stacking I am running out of options for a simple blur on specific objects or layers.
     
    Last edited: May 4, 2021
    dev_34Disorder likes this.
  41. dev_34Disorder

    dev_34Disorder

    Joined:
    Aug 7, 2018
    Posts:
    47
    Hi and thanks for the reply!
    Personally i'm not a shader wizard either so unfortunately i won't be able to help but i will advise You to make sure that when You're blurring the screen, make sure to always display something that's not blurred in the middle of the view. I know close to nothing about VR development but i remember playing something on my Quest 2 and at one point the entire screen blurred with nothing to focus on and it was extremely disorienting. Sorry if this is something obvious. I'm mostly immune to VR sickness so god knows what effect a fullscreen blur might have on someone more susceptible, that's why i'm going out of my way to say this. Of course it shouldn't be a problem here, since You're specifically trying to keep the UI un-blurred, just please make sure to always have something un-blurred on screen during transitions, etc.
    Good luck!
     
  42. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    IM having the same problem. Unfortunately, this has brought my project to a halt. I need have a 3d skybox with separate fog and camera position for each layer.

    I tried putting the sky on base, but this breaks all of the depth based post for the overlay.

    I tried putting the sky on the overlay and use stencils but this breaks transparency passes between both layers.

    Seriously there has to be a way around this.
     
    dev_34Disorder likes this.
  43. zt3ff3n

    zt3ff3n

    Joined:
    Feb 19, 2016
    Posts:
    37
    Was going crazy trying to figure out why the Bloom PP of my overlay camera was "bleeding" onto the main camera. Unfortunately it didn't make me happy to find out I'm not the only one stuck on this. Using 2021.1.1f1 URP

    I thought this would be trivial as Unity themselves released a cam stacking example meant to showcase this exact usecase.

    Watching the thread and crossing my fingers for a fix.
     
    mowax74 and dev_34Disorder like this.
  44. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    Yeah it got some bug reports out on the camera stacking functionality. Which some of them are being fixed or have already been but not released yet. I am still waiting for a "yes we fixed it in Unity 2020 LTS"...

    Our application is supposed to release in about 1~2 months, so I hope they fix all the issues by then.
    Else I have to remove the functionality temporary and work around it. Which will delay the release.
     
    dev_34Disorder likes this.
  45. drmyrrthsicopath

    drmyrrthsicopath

    Joined:
    Apr 21, 2017
    Posts:
    2
  46. diesersam

    diesersam

    Joined:
    Sep 15, 2018
    Posts:
    4
  47. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I was surprised that camera stacking did not support individual post processing. I want different global post processing applied to my stacked cameras from the base camera.

    This kind of technique is so common and been there for legacy pipeline. After so many years URP (LWRP) still does not support this. Wow.

    + 11111111111111 For URP individual camera post processing.
     
  48. transporter_gate_studios

    transporter_gate_studios

    Joined:
    Oct 17, 2016
    Posts:
    219
    i gave up and switched to using one camera.
     
    dev_34Disorder likes this.
  49. Threeyes

    Threeyes

    Joined:
    Jun 19, 2014
    Posts:
    80
    +1, My project AliveCursor needs Transparent Background, without PostProcessing, it looks dull:( Can't unity provide a toggle this feature?
     
    dev_34Disorder likes this.
  50. Fernan_

    Fernan_

    Joined:
    Sep 23, 2018
    Posts:
    1
    +1
     
    dev_34Disorder likes this.