[URP 2021.3] How to have a view in realtime on customrenderpass texture ?

Hi, I’m looking for help and I have already read everything I have found on the subject in the documentation and other threads but I haven’t find any answers.

So here is my problem :

I’m trying to make a custom renderpass with the ScriptableRendererFeature, based on the Jump Flood Algorithm explain in this paper (the code down this paper is in HDRP, so I’m trying to redo the process for URP)

First, I need to make renderpass that will draw everythings black except a specific layermask.
So now I have this code, but I have no Idea if it’s actualy working like I want or not cause I can’t see the result any where.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

public class JumpFloodRenderFeatures : ScriptableRendererFeature
{
    class AlphaPass : ScriptableRenderPass
    {
        private RenderTargetHandle alphaAttachmentHandle {get; set;}
        internal RenderTextureDescriptor descriptor {get; private set;}

        private Material alphaMaterial = null;
        private FilteringSettings filteringSettings;
        private List<ShaderTagId> shaderTagIds = new List<ShaderTagId>{
            new ShaderTagId("UniversalForward"),
            new ShaderTagId("UniversalForwardOnly"),
            new ShaderTagId("LightweightForward"),
            new ShaderTagId("SRPDefaultUnlit")
        };

        public AlphaPass(RenderQueueRange renderQueueRange, LayerMask layerMask)
        {
            alphaMaterial = CoreUtils.CreateEngineMaterial("Universal Render Pipeline/Unlit");
            alphaMaterial.color = Color.white;
            filteringSettings = new FilteringSettings(renderQueueRange, (int) layerMask);
        }

        public void Setup(RenderTextureDescriptor baseDescriptor, RenderTargetHandle alphaAttachmentHandle)
        {
            this.alphaAttachmentHandle = alphaAttachmentHandle;
            baseDescriptor.colorFormat = RenderTextureFormat.R8;
            descriptor = baseDescriptor;
        }

        public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
        {
            cmd.GetTemporaryRT(alphaAttachmentHandle.id,descriptor,FilterMode.Point);
            ConfigureTarget(alphaAttachmentHandle.Identifier());
            ConfigureClear(ClearFlag.All, Color.black);
        }

        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer cmd = CommandBufferPool.Get();
            using (new ProfilingScope(cmd, new ProfilingSampler("AlphaPass")))
            {
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();
                DrawingSettings drawSetting =  CreateDrawingSettings(shaderTagIds,ref renderingData, renderingData.cameraData.defaultOpaqueSortFlags);
                drawSetting.overrideMaterial = alphaMaterial;
                if(XRGraphics.enabled)
                    context.StartMultiEye(renderingData.cameraData.camera);
                context.DrawRenderers(renderingData.cullResults, ref drawSetting, ref filteringSettings);
                cmd.SetGlobalTexture("_AlphaCameraTexture", alphaAttachmentHandle.id);
            }
            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }

        public override void OnCameraCleanup(CommandBuffer cmd)
        {
            cmd.ReleaseTemporaryRT(alphaAttachmentHandle.id);
        }
    }

    AlphaPass alphaPass;
    RenderTargetHandle alphaTexture;
    [SerializeField] private LayerMask layerMask;

    public override void Create()
    {
        alphaPass = new AlphaPass(RenderQueueRange.opaque, layerMask);
        alphaPass.renderPassEvent = RenderPassEvent.AfterRenderingPrePasses;
        alphaTexture.Init("_AlphaCameraTexture");
    }

    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        alphaPass.Setup(renderingData.cameraData.cameraTargetDescriptor, alphaTexture);
        renderer.EnqueuePass(alphaPass);
    }
}

If anyone know where are stored renderpasses, I will be glade to know :slight_smile:

I have try this to catch the result and make it pop on a object as material, but no result, the object is grey and don’t change at all.

Have you looked in the Frame Debugger?

Ok, thank you ! I didn’t know it was there.

Actualy my problem was a little bit different than what I thought, I forgot to change the renderpipeline asset in my project settings. Dumb issu with dumb solution XD.