Implementation of the cryptomatte render passes in EEVEECryptomatte is a standard to efficiently create mattes for compositing. Implementation follow design in {T81058}The
and is similar to the implementation in Cycles. Original specification can be found at https://raw.githubusercontent.com/Psyop/Cryptomatte/master/specification/IDmattes_poster.pdf
Cryptomatte is a standard to efficiently create mattes for compositing. The renderer outputs the required render passes, which can then be used in the an compositor to create masks for specified objects. Unlike the Material and Object Index passes,which can then be used in the objects
compositor to isolcreate are selected in compositing,masks for specified objects. and mattes will be anti-aliased.Unlike the Material and Object
{F9049876}
**Hair (Particle + Object)**Index passes, the objects to isolate are selected in compositing, and mattes
{F9133001}will be anti-aliased.
**Asset Layer**Cryptomatte was already available in Cycles this patch adds it to the EEVEE
render engine. Original specification can be found at
{F9133615}https://raw.githubusercontent.com/Psyop/Cryptomatte/master/specification/IDmattes_poster.pdf
**Motion Blur**Accurate mode**
Following Cycles, there are two accuracy modes. The difference between the two
modes is the number of render samples they take into account to create the
render passes. When accurate mode is off the number of levels is used. When
{F9424579}accuracy mode is active, the number of render samples is used.
# Accurate mode**Deviation from standard**
Following Cycles,Cryptomatte specification is based on a path trace approach where samples and
coverage are calculated at the same time. there are two accuracy modesIn EEVEE a sample is an exact match on
top of a prepared depth buffer. The difference between the two modes is the number of render samples they take into account to create the render passesCoverage is at that moment always 1. When accurate mode is off the number of levels is used as the number of cryptomatte samples to evaluate. When accuracy mode is active, the number of render samples is usedBy sampling
multiple times the number of surface hits decides the actual surface coverage
for a matte per pixel.
# Devi**Implementation Overview**
Cryptomatte specification is based on a path trace approach where samples and coverage are calculated at the same timeWhen drawing to the cryptomatte GPU buffer the depth of the fragment is matched
to the active depth buffer. In EEVEE a sample is an exact match on top of a prepared depthThe hashes of each cryptomatte layer is written in
the GPU buffer. Coverage is at that moment always 1 or 0The exact layout depends on the active cryptomatte layers. By sampling multiple times the number of surface hits decides the actual surface coverage for a matte per pixelThe
GPU buffer is downloaded and integrated into an accumulation buffer (stored in
CPU RAM).
# Implementation OverviewThe accumulation buffer stores the hashes + weights for a number of levels,
layers per pixel. When a hash already exists the weight will be increased. When
the hash doesn't exists it will be added to the buffer.
When drawing to the cryptomatte gpu buffer the depth of the fragment is matched to the active depth buffer. The hashes of each cryptomatte layer is stored in the GPU buffer. The exact layout depends on the active cryptomatte layersAfter all the samples have been calculated the accumulation buffer is processed.
During this phase the total pixel weights of each layer is mapped to be in a
range between 0 and 1. After drawing each sample the GPU buffer is downloaded to CPU RAM and integraThe hashes are also sorted into the cryptomatte accumulation buffer(highest weight first).
The cryptomatte accumulation buffer stores the hashes + weights for a number of levels and layers per pixel. When a hash already exists the weight will be increasedBlender Kernel now has a `BKE_cryptomatte` header that access to common
functions for cryptomatte. When the hash doesn't exists it willThis will in the future be added toused by the bufferAPI.
After all the samples have been calculated the accumulation buffer is processed. During this phase the total pixel weights of each layer is mapped to be in a range between 0 and 1. The hashes are also sorted (highest weight first).
# Known Limitations
* Alpha blended materials aren't supported. Alpha blended materials support in
render passes needs research how to implement it in a maintainable way for any
render pass.
# Future work
This is a list of stufftasks that needs to be done for the same release that this
patch lands on (expected Blender 2.92)
* T82571 Add render tests.
* T82572 Documentation.
* T82573 Store hashes + Object names in the render result header.
* T82574 Use threading to increase performance in accumulation and post
processing.
* T82575 Merge the cycles and eeveeEEVEE settings as they are identical.
* T82576 Add RNA to extract the cryptomatte hashes to use in python scripts.