After Z-Buffer Testing does the fragment shader run on the discarded fragments? Does the Z-Test happen after the fragment shader runs?
Please, tell me the step by step events that occur in the Z-Test.
Also what is early Z-Test and how to achieve it?
After Z-Buffer Testing does the fragment shader run on the discarded fragments? Does the Z-Test happen after the fragment shader runs?
Please, tell me the step by step events that occur in the Z-Test.
Also what is early Z-Test and how to achieve it?
When depth testing is enabled, the testing occurs after the fragment shader executes. The procedure is relatively simple (and spelled out pretty well here):
Early-z discard is when a rasterizer discards a fragment before a fragment shader runs because it's clear early on that it won't pass the depth test. However, the rasterizer can't safely do this if certain things happen (such as calling discard() or modifying the fragment depth in a fragment shader). This is a hardware optimization and isn't required to occur unless you force it with OpenGL 4.2 or with an extension.
There are things that can prevent early-z discard from occurring. To achieve it:
discard() in a fragment shader