Search Unity

implementing battletoads background pass in URP

Discussion in 'Universal Render Pipeline' started by BloodMarked, Jun 20, 2021.

  1. BloodMarked

    BloodMarked

    Joined:
    Dec 11, 2013
    Posts:
    28
    i am trying to implement this example:


    the basic idea is:
    1. render the background with a separate camera into a rendertexture (lower resolution, differnt settings etc)
    2. render the rendertexture to the main camera before rendering the foreground
    now, for step 2, in the video they use:
    Code (CSharp):
    1.  
    2. commandBuffer = new CommandBuffer();
    3.         commandBuffer.Blit(rtToBlit, BuiltinRenderTextureType.CurrentActive);
    4.         commandBuffer.name = "blit Half Res";
    5.  
    6.         targetCamera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, commandBuffer);
    7.  
    to copy the rendertexture onto the main camera before rendring the objects.
    however, this command buffer is no longer executed in URP

    i though of (unsuccessfull) solutions:

    A) do everything the same, but do the copy to the main camera in a renderfeature.
    but this has the problem, that RendererFeatures are executed on all cameras, including the background camera, creating a feedbackloop.

    B) use the RenderObjects render Feature to render the background first, then the foreground.
    this has the issue, that we cannot define a rendertexture to the background pass, so we cannot adjust the resolution / effects.

    C) use camera stacking
    same issue as B: we cannot define a rendertexture or resolution for stacked cameras. they all render to the same buffer.
     
  2. shadowmatt

    shadowmatt

    Joined:
    Jun 2, 2013
    Posts:
    10
    Did you solve this?
     
  3. Jonas-Mortensen

    Jonas-Mortensen

    Unity Technologies

    Joined:
    Jan 3, 2020
    Posts:
    110
    I think option A is the way to go.
    In URP you can set a renderer per camera. Renderer features are set up per renderer so you could have two renderers added to to the pipeline asset; One for rendering the background and one with the renderer feature that blits the background.
    Do you think that would work?