ABOUT PORTFOLIO GAMES DEVLOG DOCS TOOLS CONTACT
HOME > DOCS > Unity / C# > 2D Sprite Atlas 패킹과 Sorting Layer · SortingGroup 드로우콜(Draw Call) 최적화2D Sprite Atlas Packing, Sorting Layers, and SortingGroup Draw Call Optimization
Unity / C# Intermediate Unity 2021.3+ / Unity 6

2D Sprite Atlas 패킹과 Sorting Layer · SortingGroup 드로우콜(Draw Call) 최적화2D Sprite Atlas Packing, Sorting Layers, and SortingGroup Draw Call Optimization

개별 텍스처로 인해 깨지는 스프라이트 배칭 복구, Sprite Atlas 패킹 세팅, 다중 부품 캐릭터의 렌더 순서 꼬임을 방지하는 SortingGroup 가이드.Restoring broken sprite batching caused by separate textures, configuring Sprite Atlas packing, and using SortingGroup to prevent render order interleaving on multi-part characters.

#Unity #2D #SpriteAtlas #DrawCalls #SortingGroup #Optimization
핵심 개념화면에 2D 스프라이트가 다수 배치되어 있어도, 같은 텍스처 아틀라스와 동일한 머티리얼을 공유한다면 단일 드로우콜(Draw Call / Batched SetPass)로 묶어 렌더링할 수 있습니다. 텍스처 패킹(Sprite Atlas)과 정렬 레이어(SortingGroup)를 체계적으로 설계하면 모바일 및 저사양 환경에서 렌더링 성능을 개선할 수 있습니다.
Core ConceptEven with many 2D sprites on screen, Unity can render them in a single draw call (Batched SetPass) if they share the same texture atlas and material. Structuring texture packing (Sprite Atlas) and sorting hierarchy (SortingGroup) systematically helps improve rendering performance on mobile and lower-spec hardware.

1. 2D 배칭 중단 원인과 해결책1. Causes of Broken 2D Batching and Solutions

좌우로 밀어서 표 전체 내용을 확인하세요
원인발생 현상해결 방법
텍스처 분리스프라이트마다 별도의 고유 텍스처를 바인딩하여 드로우콜 증가동일 챕터/캐릭터 스프라이트들을 하나의 Sprite Atlas(2048x2048)로 묶음
Sorting Layer 섞임A 아틀라스(배경)와 B 아틀라스(캐릭터)가 앞뒤로 교차 렌더링되며 배칭 중단명확한 Sorting Layer 우선순위 정의 (Background > Enemies > Player > Foreground > UI)
다중 파츠 정렬 꼬임캐릭터의 몸체·무기·모자가 서로 다른 레이어에 섞여 다른 캐릭터와 인터리빙캐릭터 루트에 SortingGroup 컴포넌트를 달아 캐릭터 전체를 단일 단위로 묶음
Z축 깊이 불일치스프라이트들의 Transform Z 위치가 제각각 달라 깊이 정렬 불일치 발생2D 씬의 모든 스프라이트 Z 좌표를 0으로 고정하고 Sorting Layer 및 Order in Layer로만 순서 제어
Swipe horizontally to view the full table
CauseSymptomSolution
Separate TexturesBinding individual textures per sprite increases draw callsPack sprites from the same chapter or character into a shared Sprite Atlas (e.g., 2048x2048)
Interleaved Sorting LayersAtlas A (background) and Atlas B (character) alternate back and forth, breaking batchingDefine strict Sorting Layer priority (Background > Enemies > Player > Foreground > UI)
Multi-Part Character InterleavingBody, weapon, and hat sprites overlap across layers and interleave with other charactersAttach a SortingGroup component to the character root to sort the entire character as one unit
Inconsistent Z DepthVarying Transform Z positions across sprites cause depth sorting mismatchesFix all 2D sprite Z positions to 0 and control render order strictly via Sorting Layer and Order in Layer

2. Sprite Atlas v2 설정 가이드2. Sprite Atlas v2 Configuration Guide

  • Include in Build: 런타임에 즉시 메모리에 올라가야 하는 기본 아틀라스는 체크하고, 에셋번들이나 Addressables로 별도 로드할 아틀라스는 체크 해제합니다.
  • Padding = 4px 이상: 텍스처 아틀라스 패킹 시 스프라이트 간 여백(Padding)이 너무 좁으면, 카메라 줌이나 서브픽셀 렌더링 시 인접 스프라이트의 픽셀이 번져 들어오는 타일 블리딩(Texture Bleeding) 현상이 발생할 수 있습니다.
  • Tight Packing 옵션: 알파 여백이 많은 캐릭터·오브젝트 스프라이트는 Tight Packing을 켜서 아틀라스 면적을 절약하고, 격자 타일맵 스프라이트는 사각형 경계 유지를 위해 해제합니다.
  • Include in Build: Enable this option for core atlases required immediately at runtime, and disable it for atlases loaded on demand via AssetBundles or Addressables.
  • Padding = 4px or Higher: Insufficient padding between packed sprites can cause Texture Bleeding, where pixels from adjacent sprites bleed in during camera zooming or sub-pixel rendering.
  • Tight Packing Option: Enable Tight Packing for organic character or prop sprites with large alpha margins to save atlas space, and disable it for grid-based tilemap sprites to preserve rectangular bounds.

프레임 디버거(Frame Debugger)를 통해 배칭이 끊기는 지점을 확인하고, 아틀라스 구성과 Sorting Layer 순서를 정리하면 불필요한 상태 전환 비용을 줄일 수 있습니다.

Inspecting batching breaks with the Frame Debugger and organizing your atlas grouping and Sorting Layer order reduces unnecessary render state changes.

참고자료 & 관련 링크