docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Import a texture into the render graph system in SRP Core

    To use a texture from outside the render graph system, or to make sure a texture is available across frames and cameras, import it into the render graph system using the ImportTexture API.

    For example, you can import the back buffer, or create a texture that points to a texture in your project, such as a texture asset.

    The render graph system doesn't manage the lifetime of imported textures, so it can't optimize the render graph by removing unneeded render passes. Where possible, Create a texture inside the render graph system instead, so the render graph system manages its lifetime.

    Import a texture

    To import a texture, follow these steps:

    1. Create a RenderTextureDescriptor object with the texture properties you need.

      For example:

      RenderTextureDescriptor textureProperties = new RenderTextureDescriptor(Screen.width, Screen.height, RenderTextureFormat.Default, 0);
      
    2. Use the RenderTextureDescriptor to instantiate a new render texture. For example:

      RenderTexture renderTexture = new RenderTexture(textureProperties);
      
    3. Create a handle to the render texture. For example:

      RTHandle renderTextureHandle = RTHandles.Alloc(renderTexture);
      
    4. Import the texture, to convert the RTHandle object to a TextureHandle object the render graph system can use.

      For example:

      TextureHandle texture = renderGraph.ImportTexture(renderTextureHandle);
      

    You can then use the TextureHandle object to read from or write to the render texture.

    Dispose of the render texture

    You must free the memory a render texture uses at the end of a render pass.

    For example, you can create the following Dispose method:

    public void Dispose()
    {
        renderTexture.Release();
    }
    

    Additional resources

    • Textures
    • The RTHandle system
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)