Fragment shaders can make use of the
discard keyword to "throw away" fragments. Use of this keyword causes the fragment shader to stop execution, without writing anything (including depth) to the output buffer. This provides a way to create holes in polygons without using blending. In fact, since fragments are completely discarded, there is no dependence on the order in which objects are drawn, saving us the trouble of doing any depth sorting that might have been necessary if blending was used.
In this recipe, we'll draw a teapot, and use the
discard keyword to remove fragments selectively, based on texture coordinates. The result will look like the following diagram:
The vertex position, ...