Implemeting shadow mapping with percentage closer filtering (PCF)
The shadow mapping algorithm, though simple to implement, suffers from aliasing artefacts, which are due to the
shadowmap resolution. In addition, the shadows produced using this approach are hard. These can be minimized either by increasing the
shadowmap resolution or taking more samples. The latter approach is called percentage closer filtering (PCF), where more samples are taken for the
shadowmap lookup and the percentage of the samples is used to estimate if a fragment is in shadow. Thus, in PCF, instead of a single lookup, we sample an n×n neighborhood of
shadowmap and then average the values.
The code for this recipe is contained in the