Search Unity

Question Create a render feature to that draws on a specific sorting layer

Discussion in 'Universal Render Pipeline' started by DavidNLN, Mar 5, 2023.

  1. DavidNLN

    DavidNLN

    Joined:
    Sep 27, 2018
    Posts:
    90
    Hi, as the title says I'm trying to create a render feature that would blit a render texture I create onto a specific sorting layer (as I want my render texture to be above and under certain objects)

    Is there a way to do this? could you please provide some guidence?
     
    Hozgen90 and mitaywalle like this.
  2. Hozgen90

    Hozgen90

    Joined:
    Jan 20, 2021
    Posts:
    19
    Did you find any solution?
     
  3. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    315
    I never implemented something like this, but also had thoughts about integrating this into my project. I had two ideas:

    One simple idea I had was using a Canvas with a RawImage. The RawImage gets the RenderTexture and the Canvas has a SortingLayer so it can be ordered accordingly. But in this approach the RenderTexture has to be updated before the camera renders the Canvas for example using a RenderPassFeature rendering before the Camera or using another Camera with lower priority, otherwise the RenderTexture contains the results of the last frame.

    Another more complicated idea I had was using multiple cameras. Each camera having their own layers to render and their own Renderer. So in between of each camera/each Renderer you are able to place your own RenderPassFeature for blitting the RenderTexture. But sure there are a couple of issues to be solved here, like possible overdrawing of camera result of the first camera from the second one and so on. Also performance will likely suffer more with such customization.