Blit in URP
Understand the different ways to perform a blit operation in URP and best practices to follow when writing custom render passes.
阅读时间1 分钟最后更新于 1 个月前
To blit from one texture to another in a custom render pass in the Universal Render Pipeline (URP), use the following:
- The API in the render graph system. For more information, refer to Blit using the render graph system.
AddBlitPass - The Blitter API from the Core Scriptable Render Pipeline (SRP).
The shader you use with the API must be a hand-coded shader. Shader Graph shaders aren't compatible with the API.
BlitterBlitterFor example in the function in a render pass, add the following:
Execute{ Blitter.BlitCameraTexture(commandBuffer, sourceTexture, destinationTexture, materialToUse, passNumber);}
You can also use the or APIs in your method to blit or copy textures. For example:
AddBlitPassAddCopyPassRecordRenderGraphusing 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 , , and APIs, follow these steps:
BlitterAddBlitPassAddCopyPass- Import the URP render graph samples. For more information, refer to Importing a package sample in URP.
- In the Project window, go to Samples > Universal Render Pipeline > 17.3.0 > URP RenderGraph Samples.
- Open , BlitWithFrameData, or BlitWithMaterial.Blit
?