This mask relies on the depth-buffer which contains depth information associated to each pixel. Each 
                    Compo
                    Composite 2D Layer, Shape layer and 3D Layer together. [Ctrl] + [Shift] + [N] to create a new composition after opening Smode
                    Read More
                     using 3D elements have such a depth-buffer.
                    Either the 
Depth Map is set to "Current", which means that the used depth will be of the current compo, or this parameter can be customized
				to point to external 
                    Compo
                    Composite 2D Layer, Shape layer and 3D Layer together. [Ctrl] + [Shift] + [N] to create a new composition after opening Smode
                    Read More
                     such as compos inside 
                    Shared Element
                    A shared element that can be reused at several places like an After Effects precomposition
                    Read More
                    .
                    Here is the "Mask - Depth.compo" example that applies a 
                     Mask
                    TextureMask a part of your image
                    Read More
Mask
                    TextureMask a part of your image
                    Read More
                     with a depth mask as a post-fx of a 3d compo:
                    
 
                    
                    
                    Do not forget inside the depth mask parameters to choose the depth buffer it will be based on. In the next picture the depth mask depth map has been chosen from a compostion having a 3D object and so, a depth buffer :
 
                    
                    Also remember than to actually generate a depth buffer you must write your 3D objects inside of it. To do so, go check the 3D objects 
                    3D Renderer
                    Displays a 3D geometry
                    Read More
                     parameters and change the 
                    Renderer Depth Settings
                    Settings that affect how a renderer uses the depth-buffer
                    Read More
                     as on the image below (it is like that by default):
                    
