Version: Unity 6.7 Alpha (6000.7)
Language : English
Custom render pass workflow in URP
Render graph system in URP

Blit in URP

To blit from one texture to another in a custom render pass in the Universal Render Pipeline (URP), use the following:

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");
    }

Examples

For full examples of using the Blitter, AddBlitPass, and AddCopyPass APIs, follow these steps:

  1. Import the URP render graph samples. For more information, refer to Importing a package sample in URP.
  2. In the Project window, go to Samples > Universal Render Pipeline > 17.3.0 > URP RenderGraph Samples.
  3. Open Blit, BlitWithFrameData, or BlitWithMaterial.

Additional resources

Custom render pass workflow in URP
Render graph system in URP