Implementing Depth-Peeling
Depth Peeling was introduced in 2001 by Cass Everitt as a solution to render semi-transparent geometry without the need to sort the geometry from back-to-front. The technique consists of rendering the scene multiple times (passes). At each pass, only the nearest fragments to the camera are rendered and their depth is collected to be used on the next pass. On each pass, except for the first pass, fragments closer than the ones in the depth pass collected in the previous iteration are discarded. This process peels the scene into consecutive layers, from front to back. At the end of the process, all layers are blended into one final image, which is then blended once more with the background.
Getting ready
In the repository mentioned in Technical requirements, the Depth Peeling algorithm is implemented by the DepthPeeling
class, located in source/enginecore/passes/DepthPeeling.hpp
and cpp
files. In this recipe, you will learn how to peel away or progressively...