I've realized that I don't have a clear understanding of some of the technical specifics of overdraw in Unity. I often work on mobile, where overdraw is much more of a concern than it would be on a computer or console.
I understand the basics: Overdraw occurs when pixels on the screen are drawn multiple times; this consumes more GPU time and causes the frame to take longer to render. The more pixels on-screen that are suffering from overdraw, and the more times those pixels are redrawn, the greater the performance impact. One of the primary causes of overdraw is transparent sprites, particularly with overlapping particle effects. Post-processing effects also cause overdraw.
The Unity team doesn't provide a lot of information about overdraw in their documentation, and the visualization mode in the Editor does not accurately reflect what happens on the GPU. There are a handful of articles from third parties, but they rely on clumsy real-world analogies and are frustratingly vague on the technical specifics.
Say that we have two partially overlapping sprites that are fully opaque (no alpha channel):
Here, the yellow sprite is partially obscured by the red sprite.
I can think of two possible outcomes: A) Because the yellow sprite is partially visible, the engine draws the whole sprite, then draws the red sprite on top of it. Overdraw occurs where the two sprites overlap. B) The engine is able to determine that some of the yellow square is fully obscured by the red square, and only draws the pixels that aren't obscured. No overdraw occurs.
1.i) Which is the case here? 1.ii) Would the behavior be the same if the two squares were rendered by Mesh Renderer with a fully opaque material? I'm assuming it would, since sprites are internally rendered with polygons just like a regular mesh.
Say we have a partially transparent sprite overlapping another sprite:
Here, the blue sprite has an alpha channel. The edges are feathered and partially transparent, while the pixels in the inner portion are fully opaque (alpha of 1).
I can think of three possible outcomes:
A. Because the green sprite is partially visible, the engine draws the whole green sprite, then draws the blue sprite on top of it. Overdraw occurs where the two sprites overlap. B. Because the blue sprite is partially transparent, the engine must treat the whole sprite as transparent (even the fully opaque pixels). The engine draws the whole yellow sprite, then draws the red blue on top of it. Overdraw occurs where the two sprites overlap. C. The engine is able to determine that some of the pixels of the blue sprite are fully opaque, and not draw the green sprite underneath those pixels. Overdraw occurs, but only where the feathered edges of the blue sprite overlap the green sprite.
Which is the case here?