Class PowerOfTwoTextureAtlas
Texture atlas with rectangular power of two size.
Inherited Members
Namespace: UnityEngine.Rendering
Syntax
public class PowerOfTwoTextureAtlas : Texture2DAtlas
Constructors
PowerOfTwoTextureAtlas(Int32, Int32, GraphicsFormat, FilterMode, String, Boolean)
Create a new texture atlas, must have power of two size.
Declaration
public PowerOfTwoTextureAtlas(int size, int mipPadding, GraphicsFormat format, FilterMode filterMode = FilterMode.Point, string name = "", bool useMipMap = true)
Parameters
| Type | Name | Description | 
|---|---|---|
| Int32 | size | The size of the atlas in pixels. Must be power of two.  | 
| Int32 | mipPadding | Amount of mip padding in power of two.  | 
| GraphicsFormat | format | Atlas texture format  | 
| FilterMode | filterMode | Atlas texture filter mode.  | 
| String | name | Name of the atlas  | 
| Boolean | useMipMap | Use mip maps  | 
Properties
mipPadding
Used mipmap padding size in power of two.
Declaration
public int mipPadding { get; }
Property Value
| Type | Description | 
|---|---|
| Int32 | 
Methods
AllocateTexture(CommandBuffer, ref Vector4, Texture, Int32, Int32, Int32)
Allocate space from the atlas for a texture and copy texture contents into the atlas.
Declaration
public override 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 | Allocated scale (.xy) and offset (.zw)  | 
| Texture | texture | Source Texture  | 
| Int32 | width | Request width in pixels.  | 
| Int32 | height | Request height in pixels.  | 
| Int32 | overrideInstanceID | Override texture instance ID.  | 
Returns
| Type | Description | 
|---|---|
| Boolean | True on success, false otherwise.  | 
Overrides
BlitOctahedralTexture(CommandBuffer, Vector4, Texture, Vector4, Boolean, Int32)
Blit octahedral texture into the atlas with padding.
Declaration
public override 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).  | 
| Boolean | blitMips | Blit mip maps.  | 
| Int32 | overrideInstanceID | Override texture instance ID.  | 
Overrides
BlitOctahedralTextureMultiply(CommandBuffer, Vector4, Texture, Vector4, Boolean, Int32)
Blit octahedral texture into the atlas with padding.
Declaration
public void BlitOctahedralTextureMultiply(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).  | 
| Boolean | blitMips | Blit mip maps.  | 
| Int32 | overrideInstanceID | Override texture instance ID.  | 
BlitTexture(CommandBuffer, Vector4, Texture, Vector4, Boolean, Int32)
Blit texture into the atlas with padding.
Declaration
public override 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).  | 
| Boolean | blitMips | Blit mip maps.  | 
| Int32 | overrideInstanceID | Override texture instance ID.  | 
Overrides
BlitTextureMultiply(CommandBuffer, Vector4, Texture, Vector4, Boolean, Int32)
Blit texture into the atlas with padding and blending.
Declaration
public void BlitTextureMultiply(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).  | 
| Boolean | blitMips | Blit mip maps.  | 
| Int32 | overrideInstanceID | Override texture instance ID.  | 
GetApproxCacheSizeInByte(Int32, Int32, Boolean, GraphicsFormat)
Get cache size in bytes.
Declaration
public static long GetApproxCacheSizeInByte(int nbElement, int resolution, bool hasMipmap, GraphicsFormat format)
Parameters
| Type | Name | Description | 
|---|---|---|
| Int32 | nbElement | |
| Int32 | resolution | Atlas resolution (square).  | 
| Boolean | hasMipmap | Atlas uses mip maps.  | 
| GraphicsFormat | format | Atlas format.  | 
Returns
| Type | Description | 
|---|---|
| Int64 | 
GetMaxCacheSizeForWeightInByte(Int32, Boolean, GraphicsFormat)
Compute the max size of a power of two atlas for a given size in byte (weight).
Declaration
public static int GetMaxCacheSizeForWeightInByte(int weight, bool hasMipmap, GraphicsFormat format)
Parameters
| Type | Name | Description | 
|---|---|---|
| Int32 | weight | Atlas size in bytes.  | 
| Boolean | hasMipmap | Atlas uses mip maps.  | 
| GraphicsFormat | format | Atlas format.  | 
Returns
| Type | Description | 
|---|---|
| Int32 | 
GetPayloadScaleOffset(Texture, Vector4)
Get location of the actual texture data without padding in the atlas.
Declaration
public Vector4 GetPayloadScaleOffset(Texture texture, in Vector4 scaleOffset)
Parameters
| Type | Name | Description | 
|---|---|---|
| Texture | texture | The source texture cached in the atlas.  | 
| Vector4 | scaleOffset | Cached atlas location (scale and offset) for the source texture.  | 
Returns
| Type | Description | 
|---|---|
| Vector4 | Scale and offset for the source texture without padding.  | 
GetPayloadScaleOffset(Vector2, Vector2, Vector4)
Get location of the actual texture data without padding in the atlas.
Declaration
public static Vector4 GetPayloadScaleOffset(in Vector2 textureSize, in Vector2 paddingSize, in Vector4 scaleOffset)
Parameters
| Type | Name | Description | 
|---|---|---|
| Vector2 | textureSize | Size of the source texture  | 
| Vector2 | paddingSize | Padding size used for the source texture.  | 
| Vector4 | scaleOffset | Cached atlas location (scale and offset) for the source texture.  | 
Returns
| Type | Description | 
|---|---|
| Vector4 | Scale and offset for the source texture without padding.  | 
RelayoutEntries()
sort all the requested allocation from biggest to smallest and re-insert them. This function does not moves the textures in the atlas, it only changes their coordinates
Declaration
public bool RelayoutEntries()
Returns
| Type | Description | 
|---|---|
| Boolean | True if all textures have successfully been re-inserted in the atlas  | 
ReserveSpace(Texture)
Reserve space from atlas for a texture.
Declaration
public bool ReserveSpace(Texture texture)
Parameters
| Type | Name | Description | 
|---|---|---|
| Texture | texture | Source texture.  | 
Returns
| Type | Description | 
|---|---|
| Boolean | True on success, false otherwise.  | 
ReserveSpace(Texture, Int32, Int32)
Reserve space from atlas for a texture.
Declaration
public bool ReserveSpace(Texture texture, int width, int height)
Parameters
| Type | Name | Description | 
|---|---|---|
| Texture | texture | Source texture.  | 
| Int32 | width | Request width in pixels.  | 
| Int32 | height | Request height in pixels.  | 
Returns
| Type | Description | 
|---|---|
| Boolean | True on success, false otherwise.  | 
ReserveSpace(Texture, Texture, Int32, Int32)
Declaration
public bool ReserveSpace(Texture textureA, Texture textureB, int width, int height)
Parameters
| Type | Name | Description | 
|---|---|---|
| Texture | textureA | |
| Texture | textureB | |
| Int32 | width | |
| Int32 | height | 
Returns
| Type | Description | 
|---|---|
| Boolean | 
ResetRequestedTexture()
Clear tracked requested textures.
Declaration
public void ResetRequestedTexture()