.. index:: Compositor Nodes; Cryptomatte
.. _bpy.types.CompositorNodeCryptomatteV2:

****************
Cryptomatte Node
****************

.. figure:: /images/node-types_CompositorNodeCryptomatteV2.webp
   :align: right
   :alt: Cryptomatte Node.

The Cryptomatte node uses a `Cryptomatte image <https://en.wikipedia.org/wiki/Cryptomatte>`__
to create a mask for one or more objects or materials. The input matte is typically generated by
Blender itself (see the :ref:`Cryptomatte render pass <render_layers_passes_cryptomatte>`),
but can also come from other software that supports the standard.


Inputs
======

Image
   A color render of the scene. Only required for the *Image* output to work;
   if only the grayscale mask is needed, this input can be left unconnected.

Properties
==========

Source
   The source of the Cryptomatte image.

   :Render:
      Use the Cryptomatte render passes of a certain View Layer.
   :Image:
      Use a Cryptomatte image from multilayered OpenEXR file.

Scene
   Scene from which to take the Cryptomatte.
   Only available when Source is set to *Render*.

Image
   Image to use for the Cryptomatte.
   Only available when Source is set to *Image*.

Cryptomatte Layer
   The image layer to use. This is typically a combination of a View Layer and a Cryptomatte
   type (Object/Material/Asset).

Matte ID
   The comma-separated names of the objects or materials for which to create a mask.
   While these can be typed manually, it's easier to use the `+` and `-` buttons
   next to the textbox; see `Typical Usage`_ below.


Outputs
=======

Image
   The color image from the *Image* input with the mask applied so that only the selected
   objects/materials remain. Everything else is made transparent.
Matte
   A grayscale mask of the selected objects or materials.
Pick
   A colored representation of the Cryptomatte which can be used for picking objects or materials.


Typical Usage
=============

#. Enable the *Cryptomatte Object* render pass in
   :menuselection:`Properties --> View Layer --> Passes` and render the image.
#. In the Compositor, create a Cryptomatte Node and a :doc:`/compositing/types/output/viewer`.
#. Connect the *Image* output of the :doc:`/compositing/types/input/scene/render_layers`
   (or the *Pick* output of the Cryptomatte node) to the *Image* input of the Viewer node.
#. At this point, the rendered scene (or the Cryptomatte) appears in the Compositor background.
   If it doesn't, make sure the *Backdrop* option in the header is enabled.
#. Click the :bl-icon:`add` button in the Cryptomatte node, then click the object you want to include
   in the mask. Repeat for any other objects.
#. Use the *Matte* output of the Cryptomatte node to retrieve a mask for the selected object(s).
   Alternatively, connect the *Image* output of the Render Layers node to the *Image* input
   of the Cryptomatte node, then use the *Image* output of the Cryptomatte node to retrieve
   a masked version of the render.


Example
=======

The example below extracts the white Suzanne monkey head from the render, colors it red, and
composites it back onto the render at an offset. Notice that the motion-blurred edges
get handled correctly (when rendering with Cycles).
Also notice that the *CryptoObject* render passes are not connected to Cryptomatte node;
this was needed with the :doc:`/compositing/types/mask/cryptomatte_legacy`,
but not any longer.

.. figure:: /images/compositing_types_matte_cryptomatte_example.png


Limitations
===========

- Cryptomatte sidecars (metadata files) are not supported.
- The Cryptomatte node cannot be used in node groups.
- :doc:`Volume Objects </modeling/volumes/introduction>` are not supported.
