illustrated in Algorithm \[alg:facial\_embedding\]), we can select a distance measure $d:{\mathcal{X}}_n\times{\mathcal{X}}_n\rightarrow {\mathbb{R}}^+$ to compare facial samples and estimate whether they have a high likelihood of belonging to the same subject or not. It is worth noticing that faces are embedded into a space in which the first half of the dimensions are associated to information extracted from the RGB representation while the other half codes depth information. These two sources of information may have associated different confidence levels (depending on the conditions at deployment). We address this in detail in Section \[sec:distanceDesign\] and propose an anisotropic distance adapted to our solution, and capable of leveraging the good performance of 2D solutions in certain conditions, while improving robustness and handling spoofing attacks in a continuous and unified fashion.

Decompose the input image into texture and depth gradient information. $\left\{ I_{rgb}, I_{\nabla z}\right\} = g(I)$ Extract facial information from each component. $x_{rgb} = f_{rgb}(I_{rgb})$ $x_{\nabla z} = f_{\nabla z}\left(I_{\nabla z}\right)$ Combine texture and depth information. $x = $ Concatenate$(x_{rgb}, x_{\nabla z})$ **return** $x$

Pattern design. {#sec:pattern design}
---------------

When a pattern of light $p(x,y)$ is projected over a surface with a height map $z(x,y)$, it is perceived by a camera located along 