[URP] Drawings not visible in scene view when using a custom ScriptableRendererFeature

Edit: Original title: [URP] Drawings not visible in scene view - bug? I then realized it’s being caused by my custom ScriptableRendererFeature. Please see my reply below.


I’m new to ALINE, but I expected drawings to be visible in both scene view and game view, but they’re only visible in the game view.

I’m simply using the static Draw.WireSphere(point, 10f, Color.green) in a MonoBehaviour.Update() and also from a MonoBehaviourGizmos.DrawGizmos() override. The wire spheres show up in the game view and look beautiful, but there’s nothing in scene view even if I have both views open side-by-side.

Gizmos is toggled on in the scene view - I do see normal Debug/Gizmos API drawings.

Were my expectations wrong or is this a bug?

Setup:
Unity 2020.2.5
URP 10.3.1
ALINE 1.4.0

Oh, I suddenly got a hunch that it might have something to do with me using a custom ScriptableRendererFeature, and when I toggled it off it did indeed fix the issue - the drawings finally show up in scene view.

Could I get some help figuring out why my ScriptableRendererFeature is interfering with ALINE’s render pass (in the scene view specifically - game view works fine)? The code looks like this:

TransparentTextureRendererFeature.cs
using System.CodeDom;
using System.Collections.Generic;
using palimon;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

public class TransparentTextureRendererFeature : ScriptableRendererFeature
{
    private class TransparentTextureRenderPass : ScriptableRenderPass
    {
        private RenderTargetHandle transparentTextureHandle;
        
        private const string ProfilerTag = "Transparent Texture";
        
        private List<ShaderTagId> shaderTagList = new List<ShaderTagId>();
        
        public TransparentTextureRenderPass()
        {
            renderPassEvent = RenderPassEvent.AfterRenderingTransparents;
            transparentTextureHandle.Init("_CameraTransparentTexture");
            
            shaderTagList.Add(new ShaderTagId("UniversalForward"));
            shaderTagList.Add(new ShaderTagId("LightweightForward"));
            shaderTagList.Add(new ShaderTagId("SRPDefaultUnlit"));
        }

        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer cmd = CommandBufferPool.Get(ProfilerTag);
            
            var descriptor = renderingData.cameraData.cameraTargetDescriptor;
            descriptor.msaaSamples = 1;
            descriptor.depthBufferBits = 0;
            cmd.GetTemporaryRT(transparentTextureHandle.id, descriptor);
            
            RenderTargetIdentifier destinationIdentifier = transparentTextureHandle.Identifier();
            cmd.Blit(BuiltinRenderTextureType.CameraTarget, destinationIdentifier);
            cmd.SetGlobalTexture(transparentTextureHandle.id, destinationIdentifier);
            
            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
            
            // Draw the objects that are using materials associated with this pass.
            var drawingSettings = CreateDrawingSettings(shaderTagList, ref renderingData, SortingCriteria.CommonTransparent);
            var filteringSettings = new FilteringSettings(RenderQueueRange.transparent, LayerMask.GetMask("TransparentFX"));
            context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);
        }

        public override void FrameCleanup(CommandBuffer cmd)
        {
            cmd.ReleaseTemporaryRT(transparentTextureHandle.id);
        }
    }

    private TransparentTextureRenderPass pass;

    public override void Create()
    {
        pass = new TransparentTextureRenderPass();
    }

    // Here you can inject one or multiple render passes in the renderer.
    // This method is called when setting up the renderer once per-camera.
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        renderer.EnqueuePass(pass);
    }
}

So it works much like URP’s “Opaque Texture”, except it captures the screen after (rather than before) the transparents pass. I’m a noob when it comes to this stuff, so any pointers would be appreciated.

Hmm, I’m not sure how that could interfere.
You could try using Unity’s frame debugger to see if you can spot any more clues?

Doesn’t seem possible to use the Frame Debugger on the scene view, and this issue only affects the scene view.

Only solution I can come up with is to modify AlineURPRenderPassFeature to do:

m_ScriptablePass.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing;

instead of:

m_ScriptablePass.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing-1;

I assume the drawback by doing that is that post-process effects like bloom won’t apply to the lines when using Draw.ingame.x commands, which is fine in my case. Unless you can think of some other issues it could cause?

That seems like a reasonable solution in your case.
It uses AfterRenderingPostProcessing by default since you usually do not want the debug lines to be affected by post processing.