SceneView "Overdraw" mode is misleading

I’m trying to understand what the “Overdraw” mode in Unity’s Scene view Control Bar is actually visualizing, because it doesn’t seem to visualize actual overdraw.

The common definition of overdraw is (link):

… which makes perfect sense to me.

In order to reduce overdraw, we use opaque materials and render those objects front-to-back. This causes the depth buffer to get filled and it’s used to reject pixels from objects that would be rendered next, behind those.

However, if I look at the overdraw visualization in Unity, it shows overdraw even for opaque objects that are rendered in front-to-back order. This does not make sense to me.

If overdraw is defined as “same pixel is drawn multiple times”, then the visualization seems to be wrong, because the pixel is not drawn multiple times in this case. The pixels’ depth value is tested multiple times, but the pixel isn’t written multiple times.

I did set up a test project and I double-checked it in RenderDoc. The area where the two opaque objects overlap, pixels are written only once.

Therefore, I don’t understand what the Overdraw mode in Unity is actually visualizing, because it can’t be how often the same pixel was drawn and I hope someone can shed some light into that.

I recorded a video where I go over these steps.

3 Likes

You are correct that Unity’s “Overdraw” view mode isn’t really overdraw. Unity just swaps all materials in the scene for an additive shader with a constant color and disables ZWrite. The result isn’t really true overdraw, but does have the advantage of showing off areas of otherwise hidden geometry that could be culled. It also doesn’t tell you anything about the cost of any of those surfaces, as multiple overlapping additive shaders are nearly free compared to just two or three overlapping standard shaders. It should also be noted that depth rejected surfaces are not free, so in some ways it’s still valid to show they exist, even if this isn’t true overdraw.

Unreal’s Shader Complexity view mode is much better at this. It properly uses depth and non depth writing shaders, and takes into account each shaders’ relative complexity. A heatmap post processes is then applied at the end to further help show areas of high cost.

6 Likes

Yeah it’s just a part of Unity that’s frankly just a bit crappy. There’s a bunch of much better visualisations built into HDRP, so I imagine they’ll just keep working on that. I hope.