GUI nodes can be used as clipping nodes—masks that control how other nodes are rendered. This manual explains how this feature works.
Box, Text and Pie nodes can be used for clipping. To create a clipping node, add a node in your GUI, then set its properties accordingly:
None
renders the node without any clipping taking place.Stencil
makes the node writing to the current stencil mask.Then add the node(s) you want to be clipped as children to the clipping node.
Clipping works by having nodes writing to a stencil buffer. This buffer contains clipping masks: information that that tells the graphics card whether a pixel should be rendered or not.
Stencil
will write its shape (or its inverse shape) to an new clipping mask stored in the stencil buffer.Here, three nodes are set up in a hierarchy:
Four combinations of normal and inverted clippers are possible for this hierarchy. The green area marks the part of the circle that is rendered. The rest is masked:
Layers can be used to control rendering order (and batching) of nodes. When using layers and clipping nodes the usual layering order is overridden. Layer order always take precedence over the clipping order—if layer assignments are combined with clipping nodes, clipping could happen out-of-order if a parent node with clipping enabled belongs to a higher layer than its children. The children with no layer assigned will still respect the hierarchy and subsequently be drawn and clipped after the parent.
A clipping node and its hierarchy will be drawn first if it has a layer assigned and in the regular order if no layer is assigned.
In this example, both the clipper nodes “Donut BG” and “BG” are using the same layer 1. The render order between them will be according to the same order in the hierarchy where “Donut BG” is rendered before “BG”. However, the child node “Donut Shadow” is assigned to the layer 2 which has a higher layer order and thus will be rendered after the both clipping nodes. In this case, the render order will be:
Here you can see that the “Donut Shadow” object will be clipped by both clipping nodes due to the layering, even though it is only a child to one of them.
Did you spot an error or do you have a suggestion? Please let us know on GitHub!
GITHUB