A Fragment Shader is the Shader stage that will process a Fragment generated by the Rasterization into a set of colors
and a single depth
value.
The output of a fragment shader is a depth value, a possible stencil value (unmodified by the fragment shader), and zero or more color values to be potentially written to the buffers in the current framebuffers.
Fragment shaders take a single fragment as input and produce a single fragment as output.
Fragment shaders are technically an optional shader stage. If no fragment shader is used, then the color values of the output Fragment have undefined values. However, the depth and stencil values for the output fragment have the same values as the inputs.
This is useful for doing rendering where the only useful output is the fragment’s depth, and you want to use the depth computed by the system, rather than some other depth. Such depth-only rendering is used for shadow mapping operations as well as depth pre-pass optimizations.