Files
2nd/10_Wiki/Topic_Programming/Architecture/Overdraw.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +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