"매 한 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.
매 완화
Front-to-back opaque sort + early-Z / Hi-Z: 매 depth test 가 fragment shader 전에 reject.
Z-prepass: 매 depth만 먼저 그림 → 매 main pass에서 fragment shader 1 pixel 당 1번.
Occlusion culling (HZB, Nanite): 매 안 보이는 mesh 자체 제외.
Alpha-test 대신 alpha-to-coverage 또는 opaque + dither.
Particle LOD / fewer overlapping quads.
💻 패턴
Z-prepass (Vulkan / DX12 컨셉)
// Pass 1: Depth only — null pixel shader, ColorMask=0[earlydepthstencil]voidDepthOnlyPS(){}// empty// Pass 2: Color — DepthFunc=Equal, no depth writefloat4MainPS(VSOuti):SV_Target{returnShadeExpensive(i);// 매 pixel 당 1번만 실행 보장}
Front-to-back sorting (opaque)
std::sort(opaque_draws.begin(),opaque_draws.end(),[&](constDraw&a,constDraw&b){floatda=length(a.center-cam.pos);floatdb=length(b.center-cam.pos);returnda<db;// 매 가까운 것 먼저
});// 매 transparent 는 반대로 back-to-front
Quad overdraw debug shader
// 매 stencil 또는 RWByteAddressBuffer 로 incrementRWStructuredBuffer<uint>OverdrawCounter:register(u0);float4DebugPS(uint2pos:SV_Position):SV_Target{uintidx=pos.y*ScreenWidth+pos.x;InterlockedAdd(OverdrawCounter[idx],1);return0;}// 매 후에 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
float4FoliagePS(VSOuti):SV_Target{float4c=SampleAlbedo(i.uv);// 매 hashed alpha-to-coverage 로 dither (UE5 default)if(c.a<InterleavedGradientNoise(i.pos.xy))discard;returnc;// 매 opaque pipeline 의 early-Z 활용}
Nanite / mesh shader culling (UE 5.x)
// 매 cluster-level Hi-Z occlusion + frustum culling 자동
// 매 1 triangle = 1 pixel scenario에서 overdraw 거의 제거
언제: 매 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).