To blit from one texture to another in a custom render pass in the Universal Render Pipeline (URP), use the following:
AddBlitPass API in the render graph system. For more information, refer to Blit using the render graph system.The shader you use with the Blitter API must be a hand-coded shader. Shader Graph shaders aren’t compatible with the Blitter API.
Note: Don’t use the CommandBuffer.Blit or Graphics.Blit APIs, or APIs that use them internally such as RenderingUtils.Blit. These APIs might break XR rendering, and aren’t compatible with native render passes.
For example in the Execute function in a render pass, add the following:
{
Blitter.BlitCameraTexture(commandBuffer, sourceTexture, destinationTexture, materialToUse, passNumber);
}
You can also use the AddBlitPass or AddCopyPass APIs in your RecordRenderGraph method to blit or copy textures. For example:
using UnityEngine.Rendering.RenderGraphModule.Util;
...
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) {
// Set up the source texture, destination texture, material, and shader pass number for the blit
RenderGraphUtils.BlitMaterialParameters parameters = new(sourceTexture, destinationTexture, materialToUse, passNumber);
// Add the blit pass
renderGraph.AddBlitPass(parameters, passName: "My Blit Pass");
}
For full examples of using the Blitter, AddBlitPass, and AddCopyPass APIs, follow these steps: