New: 36 free tools for Unreal Engine and Unity developers.Try them →

Sprite Atlas Padding, Extrusion and Trimming Explained

Why thin lines appear around sprites in a texture atlas, and how padding, edge extrusion and trimming fix it in Unity and Unreal Engine.

In this article
  1. Why lines appear
  2. Padding: space between sprites
  3. Extrusion: repeat the edge pixels
  4. Trimming: remove empty space
  5. Recommended settings
  6. Other fixes worth knowing
  7. Summary
  8. FAQ

You pack your sprites into an atlas, everything looks fine, and then you notice it: a thin line along the edge of a sprite, a faint coloured border, or a flicker when the camera moves. This is called texture bleeding, and it is one of the most common 2D problems in any engine. The fix is three settings most packers offer: padding, extrusion and trimming.

Why lines appear

When the GPU draws a sprite, it reads colours from the atlas. With bilinear filtering it blends the four nearest pixels. At the very edge of a sprite, one of those pixels belongs to whatever is next to it in the atlas: empty space, or worse, another sprite.

Three things make it worse:

  • Scaling and rotation: pixels no longer line up with screen pixels.
  • Sub-pixel camera movement: edges land between pixels.
  • Mipmaps: smaller versions of the atlas are averaged down, so neighbouring sprites blend together even more.

Padding: space between sprites

Padding leaves a gap of empty pixels between sprites. It stops one sprite's colours from bleeding into another.

  • 2 px is a safe default for most games.
  • With mipmaps, use more: every mip level halves the gap, so 2 px becomes 1 px at the first mip and half a pixel at the next.

Padding alone has a weakness: the gap is transparent, so the edge of a sprite can blend toward transparency and look slightly lighter or dark-fringed.

Extrusion: repeat the edge pixels

Extrusion fixes that. It copies the outermost row of pixels of each sprite outward, 1–2 pixels in every direction. Now when the GPU samples just outside the sprite, it gets the sprite's own edge colour.

This matters most for:

  • Tiles, where any gap or fringe shows as a grid of lines across the level.
  • Sprites that scale or rotate.
  • Atlases with mipmaps.

Padding and extrusion work together: extrusion fills the first pixels around each sprite with its edge colour, and padding keeps a clean gap beyond that.

Trimming: remove empty space

Many sprites have large transparent borders, especially animation frames drawn on a fixed canvas. Trimming cuts those borders off before packing, so many more sprites fit in one atlas.

The packer saves each sprite's original size and offset in the atlas data. A good importer uses them to place the trimmed sprite exactly where the untrimmed one would have been. If your frames jump around after trimming, the importer is ignoring those offsets.

SituationPaddingExtrusionTrim
UI and icons, no mipmaps2 px1 pxOn
Characters and animations2 px1–2 pxOn (if the importer reads offsets)
Tilesets2 px2 pxOff (tiles must stay grid-sized)
Atlas with mipmaps4–8 px2 pxOn
Pixel art, point filtering2 px1 pxOn

The free Sprite Sheet Packer has all three options, shows frame outlines in the preview, and exports data for Unity, Unreal Paper2D and TexturePacker-compatible engines. For the full packing and import workflow, see How to Make a Sprite Sheet for Unity and Unreal Paper2D.

Other fixes worth knowing

  • Pixel art: use point (Unity) or nearest (Unreal) filtering and no compression.
  • Unity Sprite Atlas: has its own Padding setting, and turning on Tight Packing only when needed avoids overlaps with odd shapes.
  • Camera snapping: for pixel art, snap the camera to whole pixels (Unity's Pixel Perfect Camera does this).
  • Avoid mipmaps on UI atlases that are always shown at full size.

Summary

  • Lines come from filtering reading neighbouring pixels.
  • Padding separates sprites; extrusion repeats edges so samples stay inside.
  • Use 2 px padding and 1–2 px extrusion by default; more with mipmaps.
  • Trimming saves space as long as your importer uses the offsets.

Frequently asked questions

How much padding should a sprite atlas have?

2 pixels is a safe default. Use more (4 to 8) if the atlas uses mipmaps, because each smaller mip level halves the gap between sprites.

What is sprite extrusion?

Extrusion copies the outermost pixels of each sprite outward by a few pixels. When the GPU samples slightly outside the sprite, it gets the sprite's own edge colour instead of empty space or a neighbour.

Does pixel art need padding and extrusion?

With point filtering and whole-pixel camera positions, bleeding is rare. But sub-pixel movement, scaling or zooming can still sample a neighbour, so 1–2 px of extrusion is cheap insurance.

Will trimming break my animations?

Not if the engine uses the trim offsets saved in the atlas data. If frames jump around, either your importer ignores the offsets or trimming should be turned off for that animation.

  • #2d
  • #sprites
  • #textures
Written by Renish

Indie Unreal Engine developer and founder of Tvashta Studio. Builds the Shopping Simulator Kit plugin in UE5 C++ and the free tools on this site, and writes these guides from that work for Unreal Engine and Unity developers. More about the studio.

Related articles

All articles →