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

Question UI rendering to wrong RenderTextre after Multiple Render Targets

Discussion in 'General Graphics' started by coltonhash, Oct 6, 2023.

  1. coltonhash

    coltonhash

    Joined:
    Nov 20, 2018
    Posts:
    6
    Hi,

    I am using a custom render pipeline, where I have separate sceneColor and sceneData render textures generated before post processing effects. I just implemented this with Multiple Render Targets, using camera.SetTargetBuffers().

    Everything works as expected, except for UI elements, which are now rendering to my sceneColor texture in the middle of my render pipeline versus on top of the final rendered image after all post processing effects. The image bellow shows my UI distorted with screen-space displacement, and getting blurred with depth blur and anti-aliasing effects.



    Before using MRT with camera.SetTargetBuffers(), the UI was simply rendered as an overlay on top of the final image after all post-processing effects were applied.

    My UI canvas is set to the default Screen Space - overlay.


    With Frame Debugger, I can see that the UI elements are rendering to my sceneColorBuffer, even after disabling the UI culling mask for this camera.

    I can get my UI to render correctly onto a separate render texture if I set the canvas to Screen Space - Camera with a new camera that only renders UI culling masks. But this creates a separate image that I will then need to merge with my final rendered scene in an additional post processing step.

    I am wondering why the UI components are not rendering as an overlay on top of final render after implementing MRTs? Thanks!
     
    Last edited: Oct 6, 2023
  2. coltonhash

    coltonhash

    Joined:
    Nov 20, 2018
    Posts:
    6
    I figured out my problem- My scene camera with MRTs had a depth set to 1, setting it to 0 fixes the rendering order for UI elements.