Search Unity

Multiple Render Targets in URP

Discussion in 'Universal Render Pipeline' started by SgerbwdGwyn, Mar 3, 2021.

  1. SgerbwdGwyn

    SgerbwdGwyn

    Joined:
    Dec 2, 2013
    Posts:
    25
    I'm trying to create a multiple render target shader in the most recent version of URP, based on this simple example: https://github.com/keijiro/UnityMrtTest

    In the built-in render pipeline it works as intended as shown in the git repository, but when switching to URP it simply does nothing - no errors.
    I haven't been able find any examples or documentation on MRTs in the Universal RP - does URP actually support this?
     
  2. revolute

    revolute

    Joined:
    Jul 28, 2014
    Posts:
    50
    See URP postprocess part, especially the gaussian blur. It uses 2 render targets.
     
  3. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I have the same question. And did take a look at the URP postprocess.

    the shader part is simple enough, but I don't want the post processing, but I would like normal rendering happening to two rendering targets. In order to set that up do I have to use command buffer?

    I want to write to screen buffer and my other custom rendertexture at the same time using mrt
     
    Last edited: Mar 7, 2021
  4. revolute

    revolute

    Joined:
    Jul 28, 2014
    Posts:
    50
    As far as I know, command buffer is the way to do it. CommandBuffer.SetRenderTarget accepts an array of RenderTargetIdentifier. Each array element should correspond with the output buffer in shader.
    It should be easy enough to test it by creating custom scriptable render pass and rendering it to multiple textures.
     
    dobeek likes this.
  5. AlexVillalba

    AlexVillalba

    Joined:
    Feb 7, 2017
    Posts:
    346
    I just tried to set MRT for a camera using the 2DRenderer. This can't be done since the engine (I guess the render pipeline) calls SetRenderTargets internally replacing my color buffers with _CameraColorTexture before rendering. I would have to search for the code that manages that in the package and change it. I'm not sure if I've enough will to do so.
    RenderDocCapture.PNG
     
  6. acnestis

    acnestis

    Joined:
    Sep 11, 2019
    Posts:
    15