docs(10_Wiki): Topic_Business/General/Graphic/Programming을 Topics/ 하위로 이동
최상위 10_Wiki/Topic_*였던 4개 카테고리 폴더를 10_Wiki/Topics/Topic_* 로 재배치. 콘텐츠 변경 없음(순수 폴더 이동) — Topics/ 하위 나머지 폴더는 이미 지난 커밋에서 전부 정리된 상태(잔존 항목은 에이전트 운영 상태 및 사용자가 보존을 요청한 업데이트0615/무제 3.canvas 뿐).
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
---
|
||||
id: wiki-2026-0508-overdraw
|
||||
title: Overdraw
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [pixel overdraw, fill rate waste]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [graphics, rendering, performance, gpu]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: hlsl
|
||||
framework: 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 컨셉)
|
||||
```hlsl
|
||||
// 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)
|
||||
```cpp
|
||||
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
|
||||
```hlsl
|
||||
// 매 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)
|
||||
```cpp
|
||||
// 매 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
|
||||
```hlsl
|
||||
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)
|
||||
```cpp
|
||||
// 매 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
|
||||
- 부모: [[Fill Rate]]
|
||||
- 응용: [[Z-Prepass]] · [[Nanite]]
|
||||
- Adjacent: [[Depth Pre-Pass|Early-Z]]
|
||||
|
||||
## 🤖 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 |
|
||||
Reference in New Issue
Block a user