Skip to main content

TexturePacker

A static class in Root.Township, Alta.Customization.

Packs every cosmetic part's texture and normal map into the character's 4096 atlas render textures. Used by CosmeticPacker.

Fields​

9 private and internal fields
MemberWhat it is
private static Dictionary<TexturePacker.ExistingBlit, Vector4> existingSpots already used per texture and colour pair in this pack.
private static Logger loggerNLog logger for this class.
private const RenderTextureFormat NormalRenderTextureFormatFormat of the normal atlas (ARGB32).
private const int NormalSizeNormal atlas size, 4096. Not scaled by the size multiplier.
private const RenderTextureFormat renderTextureFormatFormat of the diffuse atlas (ARGB32).
private const int SizeDiffuse atlas size before the multiplier, 4096.
private const int StepGrid cell size in pixels, 32.
private static int[,] takenGrid of used cells, cleared each pack.
private const int TakenSizeCells per side of the grid, 128.

Methods​

MemberWhat it is
static async Task Pack(Dictionary<CosmeticPacker.PartId, ICosmeticMeshPartBase> partMap, IEnumerable<CosmeticPacker.Input> parts, Texture2D defaultNormal, RenderTexture diffuse, RenderTexture normals, bool isSharingAllowed = true, float sizeMultiplier = 1)Places each part's texture in a free spot on a 32 px grid, largest first, and blits diffuse and normals there. Same texture and colours reuse a spot.
static void SetupTextures(ref RenderTexture diffuse, ref RenderTexture normals, float sizeMultiplier = 1)Creates the diffuse (scaled by the multiplier) and normal atlas render textures if they are null.