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

Unity 2019.1.14f1 - HELP - Post processing volume affecting both cameras, want to just affect UI Cam

Discussion in 'Image Effects' started by WimB, Oct 2, 2019.

  1. WimB

    WimB

    Joined:
    Sep 23, 2014
    Posts:
    35
    Hi

    I am using Unity 2019.1.14f1 I have the volume applied to a game object with various post effects applied which all works fine.
    The problem is we have a second camera which is rendering the UI and also some 3D buttons, we want the post to not effect the UI camera and only the background on the first camera. We used to use the dont clear flag on older Unity versions which worked fine but now there is no such option.
    We have tried setting the cameras layers and the volume layer mask but the post either effects no cameras or all cameras, we cannot work out how to apply the post to just one camera.

    Any help is greatly appreciated
    Regards
     
  2. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,008
    I ran into a similar issue not long ago, where I wanted different post processing on the UI camera and the main camera. Seems like layered cameras is a bit of a no-no for unity's new rendering system, and while there were some purported solutions out there they always involved 'I don't know why this works but..." and didn't work for me anyway.

    The way I solved it was to create a custom post process effect where I rendered a depth-only camera into a render texture, and applied it to the final image without unwanted post processing by putting it last in the stack.

    By the way writing custom effects for Post Processing Stack v2 is pretty easy.
     
  3. TahaDama

    TahaDama

    Joined:
    Apr 8, 2019
    Posts:
    1
    hey @Billy4184 could you please provide an example for the aforementioned solution!!
     
  4. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,008
    Here you go.

    1. OverlayRenderTexture.cs and OverlayRenderTexture.shader must be in a Resources folder.
    2. Create a render texture to store the UI graphics.
    3. Add SetRendTex to your UI camera and add the render texture in the inspector.
    4. On your main camera, in the Post Process Volume click Add Effect and add Overlay Render Texture effect, set the render texture and opacity in the inspector.

    I can't provide any support for anyone who uses this, hope it helps.
     

    Attached Files: