Class PowerOfTwoTextureAtlas
Texture atlas with rectangular power of two size.
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public class PowerOfTwoTextureAtlas : Texture2DAtlas
Constructors
PowerOfTwoTextureAtlas(int, int, GraphicsFormat, FilterMode, string, bool)
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 |
---|---|---|
int | size | The size of the atlas in pixels. Must be power of two. |
int | 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 |
bool | useMipMap | Use mip maps |
Properties
mipPadding
Used mipmap padding size in power of two.
Declaration
public int mipPadding { get; }
Property Value
Type | Description |
---|---|
int |
Methods
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 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 |
int | width | Request width in pixels. |
int | height | Request height in pixels. |
int | overrideInstanceID | Override texture instance ID. |
Returns
Type | Description |
---|---|
bool | True on success, false otherwise. |
Overrides
BlitOctahedralTexture(CommandBuffer, Vector4, Texture, Vector4, bool, int)
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). |
bool | blitMips | Blit mip maps. |
int | overrideInstanceID | Override texture instance ID. |
Overrides
BlitOctahedralTextureMultiply(CommandBuffer, Vector4, Texture, Vector4, bool, int)
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). |
bool | blitMips | Blit mip maps. |
int | overrideInstanceID | Override texture instance ID. |
BlitTexture(CommandBuffer, Vector4, Texture, Vector4, bool, int)
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). |
bool | blitMips | Blit mip maps. |
int | overrideInstanceID | Override texture instance ID. |
Overrides
BlitTextureMultiply(CommandBuffer, Vector4, Texture, Vector4, bool, int)
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). |
bool | blitMips | Blit mip maps. |
int | overrideInstanceID | Override texture instance ID. |
GetApproxCacheSizeInByte(int, int, bool, GraphicsFormat)
Get cache size in bytes.
Declaration
public static long GetApproxCacheSizeInByte(int nbElement, int resolution, bool hasMipmap, GraphicsFormat format)
Parameters
Type | Name | Description |
---|---|---|
int | nbElement | |
int | resolution | Atlas resolution (square). |
bool | hasMipmap | Atlas uses mip maps. |
GraphicsFormat | format | Atlas format. |
Returns
Type | Description |
---|---|
long |
GetMaxCacheSizeForWeightInByte(int, bool, 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 |
---|---|---|
int | weight | Atlas size in bytes. |
bool | hasMipmap | Atlas uses mip maps. |
GraphicsFormat | format | Atlas format. |
Returns
Type | Description |
---|---|
int |
GetPayloadScaleOffset(Texture, in 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(in Vector2, in Vector2, in 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 |
---|---|
bool | True if all textures have successfully been re-inserted in the atlas |
ReserveSpace(Texture)
Reserves the space on the texture atlas
Declaration
public bool ReserveSpace(Texture texture)
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | The source texture |
Returns
Type | Description |
---|---|
bool | True if the space is reserved |
ReserveSpace(Texture, int, int)
Reserves the space on the texture atlas
Declaration
public bool ReserveSpace(Texture texture, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | The source texture |
int | width | The width |
int | height | The height |
Returns
Type | Description |
---|---|
bool | True if the space is reserved |
ReserveSpace(Texture, Texture, int, int)
Reserves the space on the texture atlas
Declaration
public bool ReserveSpace(Texture textureA, Texture textureB, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Texture | textureA | The source texture A |
Texture | textureB | The source texture B |
int | width | The width |
int | height | The height |
Returns
Type | Description |
---|---|
bool | True if the space is reserved |
ResetRequestedTexture()
Clear tracked requested textures.
Declaration
public void ResetRequestedTexture()