URP 13.1.8 is adding Clear() after my custom RenderPass if start BeforeRenderingOpaque?

Hi, I updated my project from URP 12 to URP 13, and since then my render pass is followed automagically by a “Clear” color, which is the opposite of what I want.
If I’m writing inside the RenderTarget in the BeforeRenderingOpaques this for a good reason why this “Clear” appear from nowhere?

8175284--1064303--upload_2022-6-2_10-37-53.png

Also, if I call the BlitToStack pass on the AfterRenderingOpaques, no clear appear automagically between my pass and the next pass. Where this clear come from? And why urp assume we need a clear here? It was working perfectly on URP 12 without this clear.

private RTHandle _target;
        private RTHandle _rtd;
       
        void Dispose()
        {
            _rtd?.Release();
        }
       
        public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
        {
            _target = renderingData.cameraData.renderer.cameraColorTargetHandle;
            var desc = renderingData.cameraData.cameraTargetDescriptor;
            desc.depthBufferBits = 0; // Color and depth cannot be combined in RTHandles
            RenderingUtils.ReAllocateIfNeeded(ref _rtd, desc, FilterMode.Point, TextureWrapMode.Clamp, name: "_MergeBufferHandle");
        }

        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            var cb = CommandBufferPool.Get("BlitToStack");
            CreateCommandBuffer(cb);
            context.ExecuteCommandBuffer(cb);
            CommandBufferPool.Release(cb);
        }

        private void CreateCommandBuffer(CommandBuffer cb)
        {
            if (StackTexture.Count > 1)
            {
                for (var i = 0; i < StackTexture.Count; i++)
                {
                    cb.SetGlobalTexture("_MainTex", StackTexture[i]);
                    cb.Blit(StackTexture[i], _rtd, Mat, 0);//, new Vector2(1f, -1f), new Vector2(0, 1f));
                }
                cb.Blit(_rtd, _target);
            }
            else
            {
                cb.Blit(StackTexture[0], _target);
            }
        }

Did you ever figure this out? I am running into the same issue.

@kankane I’ve not encountered the issue before, but in OnCameraSetup() have you tried calling ConfigureClear(ClearTarget.none, Color.clear) by any chance?

1 Like

Hey @AurochChris , thanks for the idea. I just tried that but no change unfortunately.

Actually, I spoke too soon. It does seem to work on the mobile device but not in the editor. I can work with that for now. Thanks!