docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Texture2DAtlas

    A generic Atlas texture of 2D textures. An atlas texture is a texture collection that collects multiple sub-textures into a single big texture. Sub-texture allocation for Texture2DAtlas is static and will not change after initial allocation. Does not add mipmap padding for sub-textures.

    Inheritance
    object
    Texture2DAtlas
    PowerOfTwoTextureAtlas
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Rendering
    Assembly: Unity.RenderPipelines.Core.Runtime.dll
    Syntax
    public class Texture2DAtlas

    Constructors

    Texture2DAtlas(int, int, GraphicsFormat, FilterMode, bool, string, bool)

    Creates a new empty texture atlas.

    Declaration
    public Texture2DAtlas(int width, int height, GraphicsFormat format, FilterMode filterMode = FilterMode.Point, bool powerOfTwoPadding = false, string name = "", bool useMipMap = true)
    Parameters
    Type Name Description
    int width

    Width of the atlas in pixels.

    int height

    Height of atlas in pixels.

    GraphicsFormat format

    GraphicsFormat of the atlas.

    FilterMode filterMode

    Filtering mode of the atlas.

    bool powerOfTwoPadding

    Power of two padding.

    string name

    Name of the atlas

    bool useMipMap

    Use mip maps

    Properties

    AtlasTexture

    Handle to the texture of the atlas.

    Declaration
    public RTHandle AtlasTexture { get; }
    Property Value
    Type Description
    RTHandle

    maxMipLevelPadding

    Maximum mip padding (pow2) that can be applied to the textures in the atlas

    Declaration
    public static int maxMipLevelPadding { get; }
    Property Value
    Type Description
    int

    Methods

    AddTexture(CommandBuffer, ref Vector4, Texture)

    Add a texture into the atlas.

    Declaration
    public virtual bool AddTexture(CommandBuffer cmd, ref Vector4 scaleOffset, Texture texture)
    Parameters
    Type Name Description
    CommandBuffer cmd

    Command buffer used for texture copy.

    Vector4 scaleOffset

    Sub-texture rectangle for the added texture. Scale in .xy, offset int .zw

    Texture texture

    The texture to be added.

    Returns
    Type Description
    bool

    True if the atlas contains the texture, false otherwise.

    AllocateTexture(CommandBuffer, ref Vector4, Texture, int, int, int)

    Allocate space from the atlas for a texture and copy texture contents into the atlas.

    Declaration
    public virtual bool AllocateTexture(CommandBuffer cmd, ref Vector4 scaleOffset, Texture texture, int width, int height, int overrideInstanceID = -1)
    Parameters
    Type Name Description
    CommandBuffer cmd

    Target command buffer for graphics commands.

    Vector4 scaleOffset

    Destination scale (.xy) and offset (.zw)

    Texture texture

    Source Texture

    int width

    Request width in pixels.

    int height

    Request height in pixels.

    int overrideInstanceID

    Override texture instance ID.

    Returns
    Type Description
    bool

    True if the texture was successfully allocated and copied; false otherwise.

    AllocateTextureWithoutBlit(int, int, int, ref Vector4)

    Allocate space from the atlas for a texture.

    Declaration
    public virtual bool AllocateTextureWithoutBlit(int instanceId, int width, int height, ref Vector4 scaleOffset)
    Parameters
    Type Name Description
    int instanceId

    Source texture instance ID.

    int width

    Request width in pixels.

    int height

    Request height in pixels.

    Vector4 scaleOffset

    Allocated scale (.xy) and offset (.zw).

    Returns
    Type Description
    bool

    True on success, false otherwise.

    AllocateTextureWithoutBlit(Texture, int, int, ref Vector4)

    Allocate space from the atlas for a texture.

    Declaration
    public bool AllocateTextureWithoutBlit(Texture texture, int width, int height, ref Vector4 scaleOffset)
    Parameters
    Type Name Description
    Texture texture

    Source texture.

    int width

    Request width in pixels.

    int height

    Request height in pixels.

    Vector4 scaleOffset

    Allocated scale (.xy) and offset (.zw).

    Returns
    Type Description
    bool

    True on success, false otherwise.

    BlitCubeTexture2D(CommandBuffer, Vector4, Texture, bool, int)

    Blit and project Cube texture into a 2D texture in the atlas.

    Declaration
    public virtual void BlitCubeTexture2D(CommandBuffer cmd, Vector4 scaleOffset, Texture texture, bool blitMips = true, int overrideInstanceID = -1)
    Parameters
    Type Name Description
    CommandBuffer cmd

    Target command buffer for graphics commands.

    Vector4 scaleOffset

    Destination scale (.xy) and offset (.zw)

    Texture texture

    Source Texture

    bool blitMips

    Blit mip maps.

    int overrideInstanceID

    Override texture instance ID.

    BlitOctahedralTexture(CommandBuffer, Vector4, Texture, Vector4, bool, int)

    Blit octahedral texture into the atlas.

    Declaration
    public virtual void BlitOctahedralTexture(CommandBuffer cmd, Vector4 scaleOffset, Texture texture, Vector4 sourceScaleOffset, bool blitMips = true, int overrideInstanceID = -1)
    Parameters
    Type Name Description
    CommandBuffer cmd

    Target command buffer for graphics commands.

    Vector4 scaleOffset

    Destination scale (.xy) and offset (.zw)

    Texture texture

    Source Texture

    Vector4 sourceScaleOffset

    Source scale (.xy) and offset(.zw).

    bool blitMips

    Blit mip maps.

    int overrideInstanceID

    Override texture instance ID.

    BlitTexture(CommandBuffer, Vector4, Texture, Vector4, bool, int)

    Blit 2D texture into the atlas.

    Declaration
    public virtual void BlitTexture(CommandBuffer cmd, Vector4 scaleOffset, Texture texture, Vector4 sourceScaleOffset, bool blitMips = true, int overrideInstanceID = -1)
    Parameters
    Type Name Description
    CommandBuffer cmd

    Target command buffer for graphics commands.

    Vector4 scaleOffset

    Destination scale (.xy) and offset (.zw)

    Texture texture

    Source Texture

    Vector4 sourceScaleOffset

    Source scale (.xy) and offset(.zw).

    bool blitMips

    Blit mip maps.

    int overrideInstanceID

    Override texture instance ID.

    ClearTarget(CommandBuffer)

    Clear atlas texture.

    Declaration
    public void ClearTarget(CommandBuffer cmd)
    Parameters
    Type Name Description
    CommandBuffer cmd

    Target command buffer for graphics commands.

    GetTextureID(Texture)

    Get sub-texture ID for the atlas.

    Declaration
    public int GetTextureID(Texture texture)
    Parameters
    Type Name Description
    Texture texture

    Source texture.

    Returns
    Type Description
    int

    Texture instance ID.

    GetTextureID(Texture, Texture)

    Get sub-texture ID for the atlas.

    Declaration
    public int GetTextureID(Texture textureA, Texture textureB)
    Parameters
    Type Name Description
    Texture textureA

    Source texture A.

    Texture textureB

    Source texture B.

    Returns
    Type Description
    int

    Combined texture instance ID.

    IsCached(out Vector4, int)

    Check if the atlas contains the texture.

    Declaration
    public bool IsCached(out Vector4 scaleOffset, int id)
    Parameters
    Type Name Description
    Vector4 scaleOffset

    Texture scale (.xy) and offset (.zw).

    int id

    Source texture instance ID.

    Returns
    Type Description
    bool

    True if the texture is in the atlas, false otherwise

    IsCached(out Vector4, Texture)

    Check if the atlas contains the textures.

    Declaration
    public bool IsCached(out Vector4 scaleOffset, Texture texture)
    Parameters
    Type Name Description
    Vector4 scaleOffset

    Texture scale (.xy) and offset (.zw).

    Texture texture

    Source texture

    Returns
    Type Description
    bool

    True if the texture is in the atlas, false otherwise.

    IsCached(out Vector4, Texture, Texture)

    Check if the atlas contains the textures.

    Declaration
    public bool IsCached(out Vector4 scaleOffset, Texture textureA, Texture textureB)
    Parameters
    Type Name Description
    Vector4 scaleOffset

    Texture scale (.xy) and offset (.zw).

    Texture textureA

    Source texture A.

    Texture textureB

    Source texture B.

    Returns
    Type Description
    bool

    True if the texture is in the atlas, false otherwise.

    NeedsUpdate(Texture, bool)

    Check if contents of a texture needs to be updated in the atlas.

    Declaration
    public virtual bool NeedsUpdate(Texture texture, bool needMips = false)
    Parameters
    Type Name Description
    Texture texture

    Source texture.

    bool needMips

    Texture uses mips.

    Returns
    Type Description
    bool

    True if texture needs update, false otherwise.

    NeedsUpdate(Texture, Texture, bool)

    Check if contents of a texture needs to be updated in the atlas.

    Declaration
    public virtual bool NeedsUpdate(Texture textureA, Texture textureB, bool needMips = false)
    Parameters
    Type Name Description
    Texture textureA

    Source texture A.

    Texture textureB

    Source texture B.

    bool needMips

    Texture uses mips.

    Returns
    Type Description
    bool

    True if texture needs update, false otherwise.

    Release()

    Release atlas resources.

    Declaration
    public void Release()

    ResetAllocator()

    Clear atlas sub-texture allocations.

    Declaration
    public void ResetAllocator()

    UpdateTexture(CommandBuffer, Texture, Texture, ref Vector4, Vector4, bool, bool)

    Update a texture in the atlas.

    Declaration
    public virtual bool UpdateTexture(CommandBuffer cmd, Texture oldTexture, Texture newTexture, ref Vector4 scaleOffset, Vector4 sourceScaleOffset, bool updateIfNeeded = true, bool blitMips = true)
    Parameters
    Type Name Description
    CommandBuffer cmd

    Target command buffer for graphics commands.

    Texture oldTexture

    Texture in atlas.

    Texture newTexture

    Replacement source texture.

    Vector4 scaleOffset

    Destination scale (.xy) and offset (.zw)

    Vector4 sourceScaleOffset

    Source scale (.xy) and offset(.zw).

    bool updateIfNeeded

    Enable texture blit.

    bool blitMips

    Blit mip maps.

    Returns
    Type Description
    bool

    True on success, false otherwise.

    UpdateTexture(CommandBuffer, Texture, ref Vector4, bool, bool)

    Update a texture in the atlas.

    Declaration
    public virtual bool UpdateTexture(CommandBuffer cmd, Texture texture, ref Vector4 scaleOffset, bool updateIfNeeded = true, bool blitMips = true)
    Parameters
    Type Name Description
    CommandBuffer cmd

    Target command buffer for graphics commands.

    Texture texture

    Texture in atlas.

    Vector4 scaleOffset

    Destination scale (.xy) and offset (.zw)

    bool updateIfNeeded

    Enable texture blit.

    bool blitMips

    Blit mip maps.

    Returns
    Type Description
    bool

    True on success, false otherwise.

    Extension Methods

    ReflectionUtils.GetField(object, string)
    ReflectionUtils.GetFields(object)
    ReflectionUtils.Invoke(object, string, params object[])
    ReflectionUtils.SetField(object, string, object)
    AnalyticsUtils.ToNestedColumnWithDefault<T>(T, T, bool)
    AnalyticsUtils.ToNestedColumn<T>(T, T)
    In This Article
    Back to top
    Copyright © 2024 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)