This patch implements the necessary bits for supporting the Cryptomatte system
(https://github.com/Psyop/Cryptomatte) which is designed to allow efficient generation
of arbitrary ID matte passes.
To do so, the code doesn't just store the Object and Material ID of the first sample as usual,
but instead stores multiple IDs, each with an associated weight. In the code, this is currently
implemented with 16 slots, but more could be added by changing a define.
For the current Object and Material ID passes, the code then uses the ID with the highest weight,
which already avoids the noisy boundaries that currently appear around out-of-focus objects.
The actual Cryptomatte passes contain the first few IDs and their weight, sorted by weight.
Therefore, the first pass contains the same IDs as the classic passes.
A few bits are still missing for full Cryptomatte support:
- Their specification includes generating the IDs by hashing names and storing the name->ID mapping as metadata in the output EXRs. This patch just uses the current Cycles pass IDs.
- For a final version, these passes must be exposed. Right now, however, adding new passes is tricky. Also, if the user is to be able to choose the number of passes, a refactored pass system is required. For now, the first six Object IDs are stored in Diffuse/Glossy Direct/Indirect/Color, while the Material IDs are stored in Transmission/Subsurface D/I/C.
- The official Cryptomatte passes contain two ID/weight sets each, one in the R and G passes and one in B/A. Since the temporary passes used in this patch only have 3 components, each of them just contains one set and B is zero.
Also, if this is to be supported officially, a compositor node to extract a black-white pass for a specific ID would of course
be needed as well.