Files
2nd/10_Wiki/Topics/Architecture/Overdraw.md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

5.0 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-overdraw Overdraw 10_Wiki/Topics verified self
pixel overdraw
fill rate waste
none A 0.9 applied
graphics
rendering
performance
gpu
2026-05-10 pending
language framework
hlsl unreal-engine

Overdraw

매 한 줄

"매 한 pixel을 두 번 이상 칠하면 그건 낭비다". 매 GPU fragment shader 가 같은 pixel을 여러 번 실행하는 현상. 매 fill-rate bottleneck의 주범, 매 mobile/VR에서 frame budget을 갉아먹는 1순위 원인.

매 핵심

매 왜 발생하나

  • Transparent / alpha-blended: 매 depth write X → 매 뒤 surface 도 그려짐.
  • Back-to-front draw order: 매 멀리 → 가까이 그리면 가까운 게 멀리 위에 덮어씀.
  • Particle systems: 매 수천 quad가 겹침.
  • UI layering: 매 panel 위 panel 위 button → 매 3-4x overdraw 흔함.
  • Post-processing fullscreen passes: 매 screen 전체 매 pass 마다 1x.

매 측정

  • Quad overdraw view (Unreal viewmode quadoverdraw, Unity Frame Debugger): 매 색깔 heatmap, 매 빨강 = 5x+.
  • GPU profiler: 매 fragment shader invocations / pixels filled ratio.
  • Mobile GPU counters: Mali/Adreno/Apple Metal Frame Debugger 의 overdraw counter.

매 완화

  1. Front-to-back opaque sort + early-Z / Hi-Z: 매 depth test 가 fragment shader 전에 reject.
  2. Z-prepass: 매 depth만 먼저 그림 → 매 main pass에서 fragment shader 1 pixel 당 1번.
  3. Occlusion culling (HZB, Nanite): 매 안 보이는 mesh 자체 제외.
  4. Alpha-test 대신 alpha-to-coverage 또는 opaque + dither.
  5. Particle LOD / fewer overlapping quads.

💻 패턴

Z-prepass (Vulkan / DX12 컨셉)

// Pass 1: Depth only — null pixel shader, ColorMask=0
[earlydepthstencil]
void DepthOnlyPS() {} // empty

// Pass 2: Color — DepthFunc=Equal, no depth write
float4 MainPS(VSOut i) : SV_Target {
    return ShadeExpensive(i); // 매 pixel 당 1번만 실행 보장
}

Front-to-back sorting (opaque)

std::sort(opaque_draws.begin(), opaque_draws.end(),
    [&](const Draw& a, const Draw& b) {
        float da = length(a.center - cam.pos);
        float db = length(b.center - cam.pos);
        return da < db; // 매 가까운 것 먼저
    });
// 매 transparent 는 반대로 back-to-front

Quad overdraw debug shader

// 매 stencil 또는 RWByteAddressBuffer 로 increment
RWStructuredBuffer<uint> OverdrawCounter : register(u0);

float4 DebugPS(uint2 pos : SV_Position) : SV_Target {
    uint idx = pos.y * ScreenWidth + pos.x;
    InterlockedAdd(OverdrawCounter[idx], 1);
    return 0;
}
// 매 후에 heatmap 으로 visualize

Particle culling (Niagara / VFX Graph)

// 매 GPU sim particle: distance/screen-coverage based kill
if (length(world_pos - cam.pos) > kill_distance) Kill();
if (screen_size_pixels < 2.0) Kill(); // 매 sub-pixel particle 제거

Alpha-tested foliage → dither

float4 FoliagePS(VSOut i) : SV_Target {
    float4 c = SampleAlbedo(i.uv);
    // 매 hashed alpha-to-coverage 로 dither (UE5 default)
    if (c.a < InterleavedGradientNoise(i.pos.xy)) discard;
    return c; // 매 opaque pipeline 의 early-Z 활용
}

Nanite / mesh shader culling (UE 5.x)

// 매 cluster-level Hi-Z occlusion + frustum culling 자동
// 매 1 triangle = 1 pixel scenario에서 overdraw 거의 제거

매 결정 기준

상황 Approach
Opaque heavy scene Front-to-back sort + early-Z
Expensive PS (PBR + raymarch) Z-prepass
Foliage / leaves Alpha-to-coverage dither
Particle smoke LOD + reduced layer count
Mobile / VR Tile-based GPU 의 hidden surface removal 활용 + Z-prepass 회피 (TBDR 자체로 충분)
UI Atlas + minimal layering, pre-bake 합성

기본값: Opaque front-to-back + Z-prepass for expensive shaders + alpha dither.

🔗 Graph

🤖 LLM 활용

언제: 매 GPU profile 의 PS bound + fragment invocations >> rendered pixels. 매 mobile thermal throttling. 언제 X: 매 vertex bound 또는 매 bandwidth bound — 매 overdraw 가 main 문제 아님.

안티패턴

  • Back-to-front for opaque: 매 early-Z 무력화.
  • Alpha-blend everywhere: 매 UI/effects의 fully opaque 도 blend → fill cost 증가.
  • Z-prepass on TBDR mobile: 매 Apple/Mali tiler가 이미 hidden surface 처리 → prepass 의 추가 overhead.
  • Fullscreen quad post FX 무한 chain: 매 pass 5+ → 매 5x overdraw 보장.

🧪 검증 / 중복

  • Verified (UE5 docs, Unity SRP rendering, Arm Mali best practices, GPU Gems).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — overdraw causes + mitigations + shader patterns