Version: Unity 6.0 (6000.0)
언어 : 한국어
URP에서 렌더 그래프 시스템을 사용하여 렌더 패스 작성
URP의 렌더 그래프 시스템의 텍스처

Blit using the render graph system in URP

To__ blit__‘bit block transfer’의 약어입니다. blit 동작은 데이터 블록을 메모리의 한 곳에서 다른 곳으로 전송하는 과정입니다.
See in Glossary
from one texture to another in the render graph system in the Universal Render Pipeline (URP), use the AddBlitPass API. The API generates a render pass automatically, so you don’t need to use a method like AddRasterRenderPass.

Follow these steps:

  1. To create a shader and material that works with a blit render pass, from the main menu select Assets > Create > Shader > SRP Blit Shader, then create a material from it.

    To use shader graph instead, refer to Create a low-code custom post-processing effect.

    For more information about writing shaders in URP, refer to Writing custom shaders in URP.

  2. Add using UnityEngine.Rendering.RenderGraphModule.Util to your render pass script.

  3. In your render pass, create a field for the blit material. For example:

    public class MyBlitPass : ScriptableRenderPass
    {
        Material blitMaterial;
    }
    
  4. Set up the texture to blit from and blit to. For example:

    TextureHandle sourceTexture = renderGraph.CreateTexture(sourceTextureProperties);
    TextureHandle destinationTexture = renderGraph.CreateTexture(destinationTextureProperties);
    

    For more information, refer to Get data from the current frame in URP and Create a temporary texture for a single render pass.

  5. To set up the material, textures, and shader pass for the blit operation, create a RenderGraphUtils.BlitMaterialParameters object. For example:

    // Create a BlitMaterialParameters object with the blit material, source texture, destination texture, and shader pass to use.
    var blitParams = new RenderGraphUtils.BlitMaterialParameters(blitMaterial, sourceTexture, destinationTexture, 0);
    
  6. To add a blit pass, call the AddBlitPass method with the blit parameters. For example:

    renderGraph.AddBlitPass(blitParams, "Pass created with AddBlitPass");
    

For a complete example, refer to the example called BlitWithMaterial in the render graph examples of the Universal Render Pipeline (URP) package samples.

If you use AddBlitPass with a default material, Unity might use the AddCopyPass API instead, to optimize the render pass so it accesses the framebuffer from the on-chip memory of the GPU instead of video memory. This process is sometimes called framebuffer fetch. For more information, refer to AddCopyPass API.

Avoid blitting back

After a blit, you usually blit the destination texture back to the active color texture. However in the render graph system, you can update the frame data to point to the destination texture instead, so you only blit once. For example:

// Set the camera color as the destination texture you blitted to.
frameData.cameraColor = destinationTexture;

For more information, refer to Avoid blitting to and from the color buffer.

Additional resources

URP에서 렌더 그래프 시스템을 사용하여 렌더 패스 작성
URP의 렌더 그래프 시스템의 텍스처
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961