Search Unity

Is it possible to exlude Menu UI from in depth of field image effect?

Discussion in 'General Graphics' started by khos85, Feb 2, 2016.

  1. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Hi,

    Is it possible to exclude Menu UI from in depth of field image effect?
    I have attached a screenshot to show you my issue, the menu /canvas is blurred in places, I'd like to use the DOF image effect but ignore the UI in the effect, I cannot find much information about this yet in my searches.
    Untitled.jpg
    Could any offer any advice on this topic?
    Thanks, in advance for any advice offered
     
  2. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    Make a second camera that ONLY renders the GUI, and remove rendering of the GUI from the camera with the effects.
     
    Kiwasi and Ryiah like this.
  3. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Thanks for the info, I tried this but did not have much luck, is this true for the newer Canvas style GUI stuff too, which is rendering to world space?
     
  4. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    I believe so, as the effects are camera based, IIRC. Some things to consider:

    1) GUI objects should be in the layer you are displaying with the GUI Camera.
    2) The GUI camera should only show the GUI layer.
    3) The main camera should not show the GUI layer.
    4) The canvas should be set to use the GUI Camera.

    I believe that should be it, but I'm not at home to double check.
     
  5. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    • Make secondary camera
    • Copy transform component settings from main camera (cogwheel)
    • Paste settings into second camera
    • Remove UI from the culling mask on the camera with the effects
    • Set the culling mask on the effect-free camera to only show UI
    Voilà:


    (Click here for single-camera with blur for comparison)

    You can improve things by making the UI-only camera a child of the main one so moving things around is easier.
     
    dev1_unity835, Martin_H and Ryiah like this.
  6. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Hi, many thanks for all your help, I think I have it sussed now, the 2 camera setup works now, thanks again!
     
    dev1_unity835 likes this.
  7. NatCou

    NatCou

    Joined:
    Jan 29, 2017
    Posts:
    26
    Sorry ill add since this helped me get my UI to render without post processing
    (I'm using one camera to render the scene and had my canvas attached to this camera)
    Remove the Main Camera object under Render Camera when you're in Screen Space - Camera.
    It now renders the canvas without the effects :) Hope it helps another person
     
  8. RoyBarina

    RoyBarina

    Joined:
    Jul 3, 2017
    Posts:
    98
    So no way to only exclude some effects from UI?
    Lets say my environment has PP effects DOF and Bloom, on my UI I want to keep the bloom but exclude the DOF.
    Not possible
     
  9. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,145
    If you're following the advice in this thread and creating a second camera you simply need to create a second post process effect (as well as all of the requirements that come with post processing like a second volume).
     
    Last edited: Mar 5, 2021
  10. Tombezlar

    Tombezlar

    Joined:
    Mar 5, 2021
    Posts:
    1
    Great, these tips helped me too!
     
  11. RoyBarina

    RoyBarina

    Joined:
    Jul 3, 2017
    Posts:
    98
    Well.. let me rephrase :p making separate pp effects is not possible
     
  12. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,139
    Since when?
     
  13. RoyBarina

    RoyBarina

    Joined:
    Jul 3, 2017
    Posts:
    98
    Alright I see I need to be much more specific here.

    Lets take a specific scenario where there's a scene with 3d game objects such as a character and a terrain and a canvas for UI.
    On the character and terrain I want to add DOF, bloom and motion blur effects.
    On the UI I want a separated bloom, nothing else.

    So what I need to do is to make 2 separated volumes, right? 1 for game objects (set to the default layer for instance) and a second one for the UI (set to the UI layer).
    I also need 2 cameras with PP enabled;
    1 set to "Overlay" as render type and set to draw nothing but UI and UI layer is selected in the volume mask under environment (so this camera will only be affected by volumes from this layer).
    2 base camera to draw all layers but UI and set the volume mask to default layer. here we also need to stack the other camera.
    Is this correct?

    So now I have a stack of 2 cameras with PP enabled with TWO bloom effect stacking on top of each other.
    This is weird right? I kinda wanted 2 bloom effects.. but the UI bloom is affecting my character and terrain which aren't on the UI layer.
    So the UI PP is "leaking" into the base PP and you can see artifacts..

    This is maybe miniscule on this specific scenario but I think when using HDR the first bloom doesn't take it into account and you'll get unwanted effect.

    Now imagine using other effects like two "separated" tonemapping or color correction. you'll get horrible effects.

    SO. one cannot simply make two separated pp's that have some similarities like 2 bloom effect and without "leaking".
    The overlayed PP will also affect the base.
    At least with this approach.. if you have another way of doing this that's actually works I'll be glad to hear.

    There's a similar ongoing thread here:
    Feature Request - Post Processing with multiple cameras is currently very problematic - Unity Forum
     
  14. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,145
    No. If your UI bloom is affecting your character and terrain then its not set up properly. Unity's post processing only affects the layer that it is assigned to. All other layers will be ignored except for the purposes of alpha (ie if the UI is set to blur and is semi-transparent it will blur the any results that came before it).

    Bypassing the alpha limitations is done by first rendering to a texture and then applying that texture on screen.

    I briefly skimmed through the thread you linked and it appears that the URP is currently not playing nice but that doesn't change that this is the way you're supposed to be able to do it. URP and HDRP are limited compared to built-in. If you were on built-in this would work just fine which is why some games still use it.
     
    Last edited: Mar 8, 2021
    RoyBarina likes this.
  15. RoyBarina

    RoyBarina

    Joined:
    Jul 3, 2017
    Posts:
    98
    This is interesting, will it still apply if the alpha is set to 0? lets say using a canvas group component. or an image component with 0 alpha..