TExcelTAD
Home › Assets, Tools & Shipping › UVs & Texture Memory

UVs & Texture Memory

Textures are usually the largest part of a game, on disk and in video memory. This lesson covers how a mesh finds its pixels (UV coordinates), how to estimate what a texture really costs once mipmaps and GPU compression are counted, and how to set a texture budget.

UV coordinates

A UV map flattens a 3D surface onto the 2D texture, like unfolding a cardboard box. Each vertex gets a coordinate (u, v) from 0 to 1 across the texture. Things to know as a programmer:

  • Seams are where the unfolded pieces (UV islands) are cut. Vertices on a seam are split, as in Meshes, Vertices & Normals.
  • Texel density is how many texture pixels cover one metre of surface. Keep it consistent across assets, or a crate next to a wall looks blurry or sharp in a way players notice.
  • Padding (a few pixels between islands) prevents colours bleeding across seams when the GPU samples smaller mipmaps.
  • Second UV set: lightmaps need non-overlapping UVs, so baked-lighting projects often add a UV1 channel (Unity and Unreal can generate one on import).
  • The v axis points up in OpenGL and Blender and down in DirectX-style image space; importers flip it, but a hand-written loader may not.

Texel density is easy to check with a few lines:

python · try it yourself
def texel_density(texture_px, surface_m, uv_fraction=1.0):
    """pixels per metre along one side; uv_fraction = share of the texture width the island uses"""
    return texture_px * uv_fraction / surface_m

target = 512  # px per metre: a common mid-range choice for a third-person game
assets = [
    ("crate 1 m, 1024 px, full UV", 1024, 1.0, 1.0),
    ("wall 4 m, 1024 px, full UV", 1024, 4.0, 1.0),
    ("barrel 1.2 m, 2048 px, 40% UV", 2048, 1.2, 0.4),
]
for name, px, metres, frac in assets:
    d = texel_density(px, metres, frac)
    verdict = "ok" if 0.75 * target <= d <= 1.5 * target else ("too blurry" if d < target else "wasteful")
    print(f"{name:<32} {d:7.1f} px/m  {verdict}")
crate 1 m, 1024 px, full UV       1024.0 px/m  wasteful
wall 4 m, 1024 px, full UV         256.0 px/m  too blurry
barrel 1.2 m, 2048 px, 40% UV      682.7 px/m  ok

What a texture costs in memory

Three things multiply a texture's cost:

  1. Size: width × height pixels.
  2. Format: bytes per pixel. Uncompressed RGBA8 is 4 bytes per pixel. GPU block compression stores 4×4 pixel blocks in 8 or 16 bytes: BC1 (DXT1) is 0.5 byte per pixel, BC3/BC5/BC7 are 1 byte per pixel. Mobile GPUs use ASTC (block sizes from 4×4 = 1 byte per pixel down to 12×12 ≈ 0.11 byte per pixel) or ETC2.
  3. Mipmaps: the chain of half-size copies used for distant surfaces adds about one third.
python · try it yourself
FORMATS = {           # bytes per pixel
    "RGBA8 (uncompressed)": 4.0,
    "BC7 / BC3 / ASTC 4x4": 1.0,
    "BC1 (no alpha)": 0.5,
    "ASTC 6x6": 16 / 36,
    "ASTC 8x8": 16 / 64,
}

def texture_bytes(width, height, bpp, mips=True):
    total = 0
    while True:
        total += max(width, 1) * max(height, 1) * bpp
        if not mips or (width == 1 and height == 1):
            return total
        width, height = max(width // 2, 1), max(height // 2, 1)

for name, bpp in FORMATS.items():
    mib = texture_bytes(2048, 2048, bpp) / (1024 * 1024)
    print(f"2048x2048 {name:<22} {mib:6.2f} MiB")
ratio = texture_bytes(1024, 1024, 4) / texture_bytes(1024, 1024, 4, mips=False)
print(f"mip chain overhead: +{(ratio - 1) * 100:.1f}%")
2048x2048 RGBA8 (uncompressed)    21.33 MiB
2048x2048 BC7 / BC3 / ASTC 4x4     5.33 MiB
2048x2048 BC1 (no alpha)           2.67 MiB
2048x2048 ASTC 6x6                 2.37 MiB
2048x2048 ASTC 8x8                 1.33 MiB
mip chain overhead: +33.3%

(The function ignores that block formats round tiny mips up to a 4×4 block; that changes the result by a few bytes.)

Two lessons hide in those numbers. First, a 2048² texture left uncompressed costs 4 times more than BC7 and 8 times more than BC1. Always check the import settings: Unity's per-platform Compression and Max Size, Unreal's Compression Settings and LOD Group, Godot's Compress → Mode (VRAM Compressed for 3D). Second, halving a texture's width and height divides its cost by four: dropping one unnecessary 4K texture saves more than a week of mesh optimisation.

A texture budget

Decide a budget per platform before production, then check it. For example:

python · try it yourself
budget_mib = {"PC": 2048, "Switch-class handheld": 900, "mid-range phone": 400}
level = [  # (name, size, bytes per pixel, count)
    ("environment albedo", 2048, 1.0, 24),
    ("environment normal", 2048, 1.0, 24),
    ("environment ORM", 2048, 1.0, 24),
    ("characters (all maps)", 2048, 1.0, 18),
    ("UI atlas", 4096, 1.0, 2),
    ("lightmaps", 2048, 1.0, 6),
]
total = 0
for name, size, bpp, count in level:
    mib = size * size * bpp * 4 / 3 * count / (1024 * 1024)
    total += mib
    print(f"{name:<22} {count:3} x {size}^2  {mib:7.1f} MiB")
print(f"{'total':<22} {'':13} {total:7.1f} MiB")
for platform, limit in budget_mib.items():
    status = "fits" if total <= limit else f"over by {total - limit:.0f} MiB -> drop to 1024 or use ASTC 6x6+"
    print(f"  {platform:<22} {status}")
environment albedo      24 x 2048^2    128.0 MiB
environment normal      24 x 2048^2    128.0 MiB
environment ORM         24 x 2048^2    128.0 MiB
characters (all maps)   18 x 2048^2     96.0 MiB
UI atlas                 2 x 4096^2     42.7 MiB
lightmaps                6 x 2048^2     32.0 MiB
total                                  554.7 MiB
  PC                     fits
  Switch-class handheld  fits
  mid-range phone        over by 155 MiB -> drop to 1024 or use ASTC 6x6+

Real engines stream mip levels in and out (Unity's Mipmap Streaming, Unreal's texture streaming pool, Godot's VRAM compression and import size limits), so not every texture's top mip is resident at once. A spreadsheet like this still catches the big mistakes early.

Test yourself

How much extra memory does a full mipmap chain add to a texture?

  1. About 10%
  2. About one third
  3. Double
  4. Nothing

A 2048x2048 RGBA8 texture with mips costs about 21 MiB. What does BC1 bring it to?

  1. About 10.7 MiB
  2. About 5.3 MiB
  3. About 2.7 MiB
  4. About 0.7 MiB

What is texel density?

  1. The number of UV islands
  2. Texture pixels per metre of surface
  3. Triangles per texture
  4. The size of the mip chain