Wasted pixels


Overdraw is when a fragment is drawn multiple times but the final pixel only depends on the result of one of these fragment. One example would be a closed door with four angry police officers behind it. If the camera view is from the perspective of a drug fueled criminal a pixel on the closed door might have been drawn five times. Less if the AI of the officers was written by someone competent so they are not standing in a line. A common way to visualize overdraw is to use a special display mode where the pixel color brighter for each time something draws to it.

Front to back

Rendering hardware has the ability to do the z-test to discard a fragment before the fragment shaders is run. So one way to decrease the overdraw is to draw the world front to back. If the door is drawn first the pixel shaders for the police officers will not be run as they will be skipped by early z.

Depth only pass / Z pre-pass

For meshes without any transparency it is possible to do a depth only pass. Using only a vertex shaders and a minimal fragment shader it fills in the depth buffer only and write no color. After the depth only pass a normal rendering pass can be done with depth writing off. The fragment shaders will now only run on the areas where depth test pass, only on the visible fragments. All this makes one have to run the vertex shaders twice but the first run should be faster when there is no color writing (ShaderX7). It should also improve over all as there is less fragment shaders that need to run in the second pass.