Attention
Unity has discontinued selling and supporting Deep Compositing effective February 7, 2024.
How does it work?
Here are examples of how deep alpha maps solve clipping problems that z-buffers have with "confused" pixels, and how you can use deep alpha maps to generate holdouts while compositing.
Example: depth clipping with deep alpha maps (compared to z-buffers)
For a render with trees and leaves, the following example show the differences between using z-buffers and deep alpha maps to remove distant trees (clipping data past a certain depth). For the confused pixels, those with tree-trunk behind leaves, depth clipping works with deep alpha maps but not z-buffers. Z-buffers lose information about the transparency of leaves. Because deep alpha maps store the transparency and distance of each object separately, it's easy to discard the alpha of a distant object (the trunk), and accurately recover alpha for nearer objects (the leaves).
Before clipping
Clipping using z-buffers
Clipping using deep alpha maps
You can merge two deep alpha maps by a simple merge-sort — where the output has all the samples from both input maps, sorted by depth (terminating when =1, since those samples occlude everything behind them).
Example: compositing holdouts using deep alpha maps
This example illustrates using deep alpha maps to generate a holdout matte, to composite independently layered objects — in this case, a render of a creature interleaved with a render of foliage. Compositing the creature over or under the foliage won't work, because the creature's feet should be in contact with the foliage, not behind or in front of it. Traditionally, this is solved using a holdout matte, and deep alpha maps let you compute one during composite time (so, in this case, you can render the creature without considering any information about the foliage).
Composite without holdout
Holdout matte
Composite with holdout
Deep alpha compositing generates the holdout by adding another channel to the passes for both elements, setting the alpha of the holdout element to 0 and keeping the alpha of the other element unchanged, and then merging them.