URP Custom Pass (Blit) flickering in Scene View

Hi all,

I have a custom render pass for URP. I take the rendered image (color buffer), blur it and store it in a render texture (timing: RenderPassEvent.BeforeRenderingPostProcessing). The pass it self is just some Blit(cmd, source, target, material, 0); calls, nothing extraordinary.

Everything works fine, except that for some reason if I use that render texture on an UGUI graphic as texture (CanvasRenderer.SetTexture(renderTexture);) then all hell breaks loose in the Scene View.

Tested on: Unity 2021.2.0, Unity 2021.3.x

It works just fine in the Game View and in the Player. It also works if I open the Frame Debugger.

My guess: maybe it is a timing issue? I do not know when the UGUI rendering grabs the content from the render texture. I could try buffering but then I would require two render textures.

  • The Render texture shown in the video (bottom) is not the one I am using. Just ignore it plz. I noticed just now but I do not want to re-record the video.

If anyone knows a fix or has seen this before I would be greatful for any insights.
Thank you.

Update:

I have been able to work around this by only updating my render texture when rendering for the game view. It ain’t pretty but it works. Though I have no idea what side-effects this might have. So I am still interested in a proper solution.

public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
    if (renderingData.cameraData.cameraType == CameraType.SceneView || renderingData.cameraData.cameraType == CameraType.Preview)
        return;
       
    // Render (Blit) stuff and store in render texture.
}