ZSort | This node sorts subordinate objects for rendering in a sequence depending on their Z order. |
When rendering transparent objects using alpha blending, objects must be rendered back to front to achieve a correct result. The ZSort node can be used to dynamically change the render order of objects based on their position in the current view.
By using the Custom Section at the bottom of the Properties Editor or in the nodes context menu, output connections can be added to or removed from this hierarchy node. During rendering, the center of each child subtrees bounding box is calculated and then projected into clip space (the coordinate system a point is mapped to after passing world, view and projection). This space is screen-aligned with the positive Z-axis going "into" the render window. The order of rendering for each of the subtrees will be chosen such that they are rendered by descending Z-value (i.e. largest positive Z value first).
The Z-Sort node still only determines depth by the center point of the bounding box of each object. Since the bounding box center is only an approximation of the objects surface, and potentially says little about the actual depth of the surface itself, it can be necessary to split subtrees/meshes into multiple independent parts for correct transparency rendering.