My understanding is that one technique for reducing overdraw involves using the z-buffer to early-out of expensive fragment operations. For example, one would draw the skybox after all other opaque geometry, but with z-testing turned on.
Note: we’re using forward rendering because we have to run on low-end mobile devices. My understanding is that in forward rendering, the fragment operations happen before depth testing. Is that true? Does that mean that in forward rendering all fragment operations run even if the pixel will fail the z-test?
If this is true for the depth test, is it also true for stencil tests?
Unity’s Forward Rendering page only talks about lighting.
I don’t believe the fragment shader is ever ran before the depth test except in situations where the depth test early-out is unable to be used. However in forward rendering as you are filling the depth buffer as you render it’s possible that without sorting subsequent draw calls will simply keep rendering closer objects. Thus the fragment will pass depth test and you’ll end up running the fragment shader.
For this reason it’s sometime beneficial to render an initial depth pass of all objects, filling the depth buffer with a simple low cost shader. However I don’t think such a system has been popular for some time now, though maybe that is simply due to the popularity of deferred rendering which obviously does this anyway.
If you are using Unity 5 then you can use the Frame Debugger to see what is going on in terms of rendering your scene and perhaps evaluate whether it’s a problem for you in forward rendering.