Search Unity

Render target resettting when upgrading 2020.3.32f1 (SRP)

Discussion in 'Universal Render Pipeline' started by konikun, May 17, 2022.

  1. konikun

    konikun

    Joined:
    May 11, 2011
    Posts:
    3
    Hey everyone, I started seeing an issue when upgrading unity and I was wondering if someone has some tips on what could've caused it. I'm pretty green with graphics programming / SRP in general, FYI.

    The issue doesn't happen on the original version (2020.3.19f1, using URP package 10.6.0), but I'm seeing all black as soon as I move to 2020.2.32f, which automatically upgraded me to URP 10.8.1.

    We're using a pretty customized SRP. I managed to narrow down the issue to a specific ScriptableRendererFeature. What we're doing there is basically:
    • we listen to RenderPipelineManager.beginFrameRendering and create 4 render textures in it (msaa color buffer, msaa depth buffer, a color texture and a depth texture)
    • we release those textures on RenderPipelineManager.endFrameRendering
    • the feature has 2 passes, one for BeforeRenderingOpaques and one for BeforeRendereringTransparents
      • BeforeRenderingOpaques:
        • here we set the render target to our msaa color/depth buffers
        • we do a ClearRenderTarget
      • BeforeRendereringTransparents :
        • here we set the render target to our color/depth texture and draw to them
        • then pass those textures to _CameraOpaqueTexture & _CameraDepthTexture using SetGlobalTexture
        • then set the render target back to our msaa color/depth buffers
    All the render targets setting is being done using CommandBuffer.SetRenderTarget(RenderTargetIdentifier, RenderTargetIdentifier).

    One difference we noticed using the Frame Debugger is that the RenderTarget resets to unity's own `_CameraColorTexture` as soon as DrawOpaqueObjects start. This didn't happen before upgrading, we would still keep our own MSAA color buffers as a RenderTarget while DrawOpaqueObjects was happening.

    I hope this wall of text makes sense! Any tips appreciated as I'm still learning how all this works :)