Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. 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. ali_mohebali

    ali_mohebali

    Unity Technologies

    Joined:
    Apr 8, 2020
    Posts:
    118
    I have added it here to reflect its status publicly.

    Specific effects like separate Bloom/Depth of Field (DoF) effects on different layers might not produce correct/expected results generally though (or at least not in a performant way as a general workflow, and we are investigating). So it would be good to get some feedback on your specific/tangible use cases, your camera setup, and the post-processing configuration for each camera so we can understand different expectations.
     
    Last edited: Apr 3, 2023
  2. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,262
    Thanks for the update! I think people will not at all mind the performance hit nor the alpha blending issues as long as supporting alpha is possible in the first place, as it's a very common use case for cameras, and without it SRP is definitely not at parity with builtin.
     
  3. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,508
    Still nope?
     
  4. MrDizzle26

    MrDizzle26

    Joined:
    Feb 8, 2015
    Posts:
    34
  5. luistorres_emvenci

    luistorres_emvenci

    Joined:
    Aug 23, 2021
    Posts:
    16
  6. Nebuchaddy

    Nebuchaddy

    Joined:
    Apr 8, 2019
    Posts:
    2
    It's been more than 2 years...

    +1
     
  7. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,434
    Screenshot 2023-05-11 at 00.29.57.png
    It's under planned, happy to see that.
     
  8. StripeGuy

    StripeGuy

    Joined:
    Dec 30, 2016
    Posts:
    52
    +10,000 Please!
     
  9. PabloIH

    PabloIH

    Joined:
    Sep 20, 2014
    Posts:
    12
    +1

    Example use case I was trying:
    2D Parallax with 3 layers
    - 1st camera without depth of field
    - 2nd camera with some depth of field
    - 3rd camera with a strong depth of field

    You can see things like this in many games like Darkest Dungeon II, or CloudberryKingdom
     
  10. StripeGuy

    StripeGuy

    Joined:
    Dec 30, 2016
    Posts:
    52
    So we'll have to wait another 2 years for them to do it then if it's only in planned. :(
     
  11. Felixbaum1

    Felixbaum1

    Joined:
    Aug 12, 2020
    Posts:
    1
  12. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    239
  13. SherryFall

    SherryFall

    Joined:
    Dec 1, 2022
    Posts:
    1
  14. NibbleByteSSG

    NibbleByteSSG

    Joined:
    Jan 7, 2020
    Posts:
    32
    +1 for UI separate post processing on URP.
     
    JesOb likes this.
  15. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,434
    Is this a related temporary solution?
    #14
     
  16. ALGNam

    ALGNam

    Joined:
    Sep 2, 2018
    Posts:
    2
    +1 It's okay if the performance is broken, so we need a temporary solution.
     
  17. Warwlock

    Warwlock

    Joined:
    Aug 17, 2018
    Posts:
    40
    I was working on a new tool called PULSE - Post-Processing Utilities, LUTs, and Special Effects. It allows you to post process overlay cameras without effecting other cameras. Also you can create your own custom effects with minimal amount of code.

    Left is overlay camera with post processing, right is main camera with no post processing:

    overlayCamera.png

    You can get PULSE on Github: https://github.com/Warwlock/PULSE
    You can find installation and usage on Github page.

    Also PULSE is part of bigger project called CATS, it is also open source: https://github.com/Warwlock/C.A.T.S

    Also there is main thread: https://forum.unity.com/threads/pulse-post-processing-utilities-luts-and-special-effects.1460305/
     
  18. tbg10101_

    tbg10101_

    Joined:
    Mar 13, 2011
    Posts:
    191
    This is blocking my adoption of URP. My current setup (in the built-in pipeline) works like this:
    • base camera render a star field
    • overlay camera to render the exterior of a space ship (using post-FX profile A)
    • overlay camera to render the interior of a space ship (using post-FX profile B)
    • overlay camera to render elements I don't want to have post-FX applied to like 3D UI elements
    • camera to render the current screen contents to a RenderTexture and blur it (for use in the UI)
    • camera to render 2D UI to a texture with MSAA (UI uses SVG and this removes the jagged edges)
    • overlay camera to composite the UI into the screen
    Seems like this just isn't possible with URP - or it would be a giant pain to get it working.
     
  19. pravusjif

    pravusjif

    Joined:
    Jul 24, 2012
    Posts:
    18
    This solution takes some steps but it workd for URP 14.0.8 (Unity 2022.3.6f1) to have transparency working for the environment background solid color with alpha of a "Base" render-type camera having post-processing on, only 1 camera:

    1. Create a "Universal Render Pipeline Asset" asset file and a "Universal Renderer Data" (Assets->Create->Rendering->URP Asset (with Universal Renderer) will create both files already referenced). Make sure your custom URP Asset is being used by referencing it at Project Settings -> Scriptable Render Pipeline Settings.

    2. Look for the UberPost.shader used for post-processing by your URP version: in your Project tab search for "uberpost" and change the search "In Assets" setting to "All" to see UPM internal packages files as well. Duplicate the UberPost.shader file (that should be at Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/UberPost.shader) into a folder of your own in /Assets.

    3. Open your duplicated version of the original UberPost.shader and look for the fragment shader (it may be called Frag, or FragUberPost or similar, depending on your URP version used) and inside there look for the first real color variable assignation (normally at the
    else
    of the
    _CHROMATIC_ABERRATION
    conditional; e.g.
    color = SAMPLE_TEXTURE2D_X(_SourceTex, sampler_LinearClamp, uvDistorted).xyz;
    ) to know the exact texture property name being used (normally it will be either
    _SourceTex
    or
    _BlitTexture
    ).

    4. Go to the bottom of the fragment shader before the last closure and replace
    return half4(color, 1.0);
    with:
    Code (CSharp):
    1.  
    2. half alpha = SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_LinearClamp, uvDistorted).w;
    3.  
    4. return half4(color, alpha);
    5.  
    That's needed so that manipulating the alpha of the camera environment background color actually makes it transparent (by default it's always 1.0 for whatever reason...).
    Here's an example of a custom UberPost.shader file with those modifications.

    5. Open the
    .meta
    file of your custom UberPost.shader in a text editor and copy the
    guid
    hash

    6. Create a "Post Process Data" asset file (Assets->Create->Rendering->URP Post-process Data), open it in a text editor and paste the
    guid
    hash of your custom UberPost.shader.meta file into the
    uberPostPS
    property.

    7. Select your "Universal Render Data" asset file and replace the Post-processing data file reference with your newly created "Post Process Data File".

    8. Finally configure your camera accordingly, make sure the "Renderer" used is your "Universal Render Data" asset file:

    Screen Shot 2023-08-10 at 04.19.51.png

    Screen Shot 2023-08-10 at 04.28.14.png

    Screen Shot 2023-08-10 at 04.28.53.png

    Hopefully this will help someone save a lot of time.
     
    Last edited: Aug 10, 2023
  20. KristofferB

    KristofferB

    Joined:
    Oct 28, 2019
    Posts:
    8
    THANK YOU!
    I have been dealing with this problem on and off since 5 months ago!
    In the end I settled for having some sort of worse bloom effects because I couldn't properly get post processing while rendering gameobjects in front of unity UI toolkit on a render texture.

    And then today I got frustrated and I found this post

    You solved my issue and I simply can't thank you enough - so to anyone struggling with this, what pravusjif wrote WORKS.

    On a sidenote, I really need to learn to read / write shaders so I could have solved it when I looked into it myself.

    THANKS AGAIN!
     
    pravusjif and Lars-Steenhoff like this.
  21. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    115
    @pravusjif hmm, I have tried, but i'm still not sure. Where my problem is I need to enable post-processing on camera1base, and camera2overlay. But when enable post processing on both camera, the post-processing is multiplied.

    Tried to camera2 as base, but it hidden camera1 rendering.
     
  22. diesoftgames

    diesoftgames

    Joined:
    Nov 27, 2018
    Posts:
    114
    Just chiming in with my use-case: I'm looking to do an overlay UI without post-processing in URP 2D, but I don't want to use ScreenSpaceOverlay because I want it to respect my camera's viewport rect. When I do this, the UI camera seems to "undo" all of the post-processing that happens in the main camera. This is especially weird because in the frame debugger I can still see the post processing happening in the main camera's rendering. It looks like it's overlaying the UI camera over the results of the DrawAllRenderers step rather than the final output of the main camera, which is unexpected.

    Ideally I could use distinct volumes to only apply some of the post-processing to the UI (essentially what I'm really trying to do is just not have bloom on UI), but I understand how that could quickly get confusing with how alpha is handled.
     
    leohilbert likes this.
  23. leohilbert

    leohilbert

    Joined:
    Nov 28, 2015
    Posts:
    15
  24. alexoh205

    alexoh205

    Joined:
    Mar 18, 2020
    Posts:
    19
    @restush96 You can just enable post-processing for only the overlay camera and it will be applied to the main camera as well.