Replacing Blit with RTHandles in unity 6

I’m trying to do an Oil Painting effect, but i got an error CS0619 : ‘ScriptableRenderPass.Blit(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, Material, int)’ is obsolete : ‘Use RTHandles for source and destination’

using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

public class OilPaintingEffectPass : ScriptableRenderPass
{
    private RenderTargetIdentifier source;
    private RenderTargetIdentifier destination;
    
    private RenderTexture structureTensorTex;
        
        private readonly Material structureTensorMaterial;
        
        public OilPaintingEffectPass(Material structureTensorMaterial)
        {
            this.structureTensorMaterial = structureTensorMaterial;
        }
    public void Setup(OilPaintingEffect.Settings settings)
    {

    }

    public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
    {
        RenderTextureDescriptor blitTargetDescriptor = renderingData.cameraData.cameraTargetDescriptor;
        blitTargetDescriptor.depthBufferBits = 0;

        var renderer = renderingData.cameraData.renderer;

        source = renderer.cameraColorTargetHandle;
        destination = renderer.cameraColorTargetHandle;
        
        structureTensorTex = RenderTexture.GetTemporary(blitTargetDescriptor.width, blitTargetDescriptor.height, 0, RenderTextureFormat.ARGBFloat);
    }

    public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
    {
        CommandBuffer cmd = CommandBufferPool.Get("Oil Painting Effect");
        
        Blit(cmd, source, structureTensorTex, structureTensorMaterial, -1);
        Blit(cmd, structureTensorTex, destination);
        
        context.ExecuteCommandBuffer(cmd);
        CommandBufferPool.Release(cmd);
    }

    public override void FrameCleanup(CommandBuffer cmd)
    {
        RenderTexture.ReleaseTemporary(structureTensorTex);
    }
}

how do I update my code ?

1 Like

Introduction of Render Graph in the Universal Render Pipeline (URP) - Unity Engine - Unity Discussions
I reccomend asking on the render graph thread but there are examples included in the package manager.