docs.unity3d.com
    Show / Hide Table of Contents

    Class RTUtils

    Provides a utility class for getting and releasing RenderTextures handles.

    Inheritance
    Object
    RTUtils
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEditor.TerrainTools
    Syntax
    public static class RTUtils
    Remarks

    Tracks the lifetimes of these RenderTextures. Any RenderTextures that aren't released within several frames are regarded as leaked RenderTexture resources, which generate warnings in the Console.

    Methods

    Destroy(RenderTexture)

    Destroys a RenderTexture created using new RenderTexture().

    Declaration
    public static void Destroy(RenderTexture rt)
    Parameters
    Type Name Description
    RenderTexture rt

    The RenderTexture to destroy.

    See Also
    Destroy(Object, Single)
    DestroyImmediate(Object, Boolean)

    GetDescriptor(Int32, Int32, Int32, GraphicsFormat, Int32, Boolean)

    Gets a RenderTextureDescriptor set up for RenderTexture operations on GPU.

    Declaration
    public static RenderTextureDescriptor GetDescriptor(int width, int height, int depth, GraphicsFormat format, int mipCount = 0, bool srgb = false)
    Parameters
    Type Name Description
    Int32 width

    The width of the RenderTexture.

    Int32 height

    The height of the RenderTexture.

    Int32 depth

    The depth of the RenderTexture.

    GraphicsFormat format

    The RenderTextureFormat of the RenderTexture.

    Int32 mipCount

    The mip count of the RenderTexture. Default is 0.

    Boolean srgb

    The flag that determines whether RenderTextures created using this descriptor are in sRGB or Linear space.

    Returns
    Type Description
    RenderTextureDescriptor

    Returns a RenderTextureDescriptor object.

    GetDescriptor(Int32, Int32, Int32, RenderTextureFormat, Int32, Boolean)

    Gets a RenderTextureDescriptor for RenderTexture operations on GPU.

    Declaration
    public static RenderTextureDescriptor GetDescriptor(int width, int height, int depth, RenderTextureFormat format, int mipCount = 0, bool srgb = false)
    Parameters
    Type Name Description
    Int32 width

    The width of the RenderTexture.

    Int32 height

    The height of the RenderTexture.

    Int32 depth

    The depth of the RenderTexture.

    RenderTextureFormat format

    The RenderTextureFormat of the RenderTexture.

    Int32 mipCount

    The mip count of the RenderTexture. Default is 0.

    Boolean srgb

    The flag that determines whether RenderTextures created using this descriptor are in sRGB or Linear space.

    Returns
    Type Description
    RenderTextureDescriptor

    Returns a RenderTextureDescriptor object.

    See Also
    GetDescriptor(Int32, Int32, Int32, RenderTextureFormat, Int32, Boolean)

    GetDescriptorRW(Int32, Int32, Int32, GraphicsFormat, Int32, Boolean)

    Gets a RenderTextureDescriptor for RenderTexture operations on GPU with the enableRandomWrite flag set to true.

    Declaration
    public static RenderTextureDescriptor GetDescriptorRW(int width, int height, int depth, GraphicsFormat format, int mipCount = 0, bool srgb = false)
    Parameters
    Type Name Description
    Int32 width

    The width of the RenderTexture.

    Int32 height

    The height of the RenderTexture.

    Int32 depth

    The depth of the RenderTexture.

    GraphicsFormat format

    The RenderTextureFormat of the RenderTexture.

    Int32 mipCount

    The mip count of the RenderTexture. Default is 0.

    Boolean srgb

    The flag that determines whether RenderTextures created using this descriptor are in sRGB or Linear space.

    Returns
    Type Description
    RenderTextureDescriptor

    Returns a RenderTextureDescriptor object.

    See Also
    GetDescriptor(Int32, Int32, Int32, RenderTextureFormat, Int32, Boolean)

    GetDescriptorRW(Int32, Int32, Int32, RenderTextureFormat, Int32, Boolean)

    Gets a RenderTextureDescriptor for RenderTexture operations on GPU with the enableRandomWrite flag set to true.

    Declaration
    public static RenderTextureDescriptor GetDescriptorRW(int width, int height, int depth, RenderTextureFormat format, int mipCount = 0, bool srgb = false)
    Parameters
    Type Name Description
    Int32 width

    The width of the RenderTexture.

    Int32 height

    The height of the RenderTexture.

    Int32 depth

    The depth of the RenderTexture.

    RenderTextureFormat format

    The RenderTextureFormat of the RenderTexture.

    Int32 mipCount

    The mip count of the RenderTexture. Default is 0.

    Boolean srgb

    The flag that determines whether RenderTextures created using this descriptor are in sRGB or Linear space.

    Returns
    Type Description
    RenderTextureDescriptor

    Returns a RenderTextureDescriptor object.

    See Also
    GetDescriptor(Int32, Int32, Int32, RenderTextureFormat, Int32, Boolean)

    GetHandleCount()

    Gets the number of RTHandles that have been requested and not released yet.

    Declaration
    public static int GetHandleCount()
    Returns
    Type Description
    Int32

    Returns the number of RTHandles that have been requested and not released.

    GetNewHandle(Int32, Int32, Int32, GraphicsFormat)

    Gets an RTHandle for a RenderTexture acquired with new RenderTexture(desc).

    Declaration
    public static RTHandle GetNewHandle(int width, int height, int depth, GraphicsFormat format)
    Parameters
    Type Name Description
    Int32 width

    The width of the RenderTexture.

    Int32 height

    The height of the RenderTexture.

    Int32 depth

    The depth of the RenderTexture.

    GraphicsFormat format

    The format of the RenderTexture.

    Returns
    Type Description
    RTHandle

    Returns an RTHandle.

    Remarks

    Use Release(RTHandle) to release the RTHandle.

    GetNewHandle(RenderTextureDescriptor)

    Gets an RTHandle for a RenderTexture acquired with new RenderTexture(desc).

    Declaration
    public static RTHandle GetNewHandle(RenderTextureDescriptor desc)
    Parameters
    Type Name Description
    RenderTextureDescriptor desc

    The RenderTextureDescriptor for the RenderTexture.

    Returns
    Type Description
    RTHandle

    Returns an RTHandle.

    See Also
    RenderTextureDescriptor

    GetTempHandle(Int32, Int32, Int32, GraphicsFormat)

    Gets an RTHandle for a RenderTexture acquired with GetTemporary(RenderTextureDescriptor).

    Declaration
    public static RTHandle GetTempHandle(int width, int height, int depth, GraphicsFormat format)
    Parameters
    Type Name Description
    Int32 width

    The width of the RenderTexture.

    Int32 height

    The height of the RenderTexture.

    Int32 depth

    The depth of the RenderTexture.

    GraphicsFormat format

    The format of the RenderTexture.

    Returns
    Type Description
    RTHandle

    Returns a temporary RTHandle.

    Remarks

    Use Release(RTHandle) to release the RTHandle.

    GetTempHandle(RenderTextureDescriptor)

    Gets an RTHandle for a RenderTexture acquired with GetTemporary(RenderTextureDescriptor).

    Declaration
    public static RTHandle GetTempHandle(RenderTextureDescriptor desc)
    Parameters
    Type Name Description
    RenderTextureDescriptor desc

    RenderTextureDescriptor for the RenderTexture.

    Returns
    Type Description
    RTHandle

    Returns a temporary RTHandle.

    Remarks

    Use Release(RTHandle) to release the RTHandle.

    See Also
    RenderTextureDescriptor

    Release(RTHandle)

    Releases the RenderTexture resource associated with the specified RTHandle.

    Declaration
    public static void Release(RTHandle handle)
    Parameters
    Type Name Description
    RTHandle handle

    The RTHandle from which to release RenderTexture resources.

    See Also
    ReleaseTemporary(RenderTexture)
    Back to top
    Copyright © 2023 Unity Technologies
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on Friday, November 3, 2023