And so we arrive at the point of this tutorial - how to create your own Pixelate Node. I will present this in several stages, with each stage adding more customization to the node.
Step 1: Create a Node Group, with a single vector input and a single vector output. Connect the input to a SeparateXYZ Node, to generate separate channels for each coordinate. Connect the ouput to a CombineXYZ Node, so that the final result will be a vector again.
Step 2: Now we need to divide each component of the vector in to unit length sections. Connect the X output of the SeparateXYZ Node to a Math:Round node. This will remove the fractional part of the component, and output only an integer value. Connect this output to the CombineXYZ Node, and then repeat this step for the Y and Z components. (It is worth mentioning here that for some odd reason the Round node includes a second input that is ignored by the node. Just ignore it)
This is the basic Pixelate Node, but it is far too basic to be of any use. So now we will add the next level of control.
Step 3: In the Input Node, add four new inputs labelled Scale, ScaleX, ScaleY,ScaleZ and give them each a default value of 1.00. Into each connection from the SeparateXYZ Node to the Math:Round nodes, add two Math:Multiply nodes. Connect the Scale input to the first Multiply node of each connection. Connect the ScaleX input to the second Multiply node in the X connection, and do the same for ScaleY and ScaleZ in the Y and Z connections.
This will allow us to change the size of the pixels, and to provide separate scaling for each direction. In the city example above, the Scale parameter is used to make the windows smaller, and the ScaleZ parameter changed them from stretched vertical windows to (rough) squares.
Step 4: Another customization that I added is to add three extra Outputs to the Output node, and connect the outputs of the three Multiply Nodes to them. I also added three Math:Add Nodes to generate a slight offset that moves the boundary. This is not usually needed, but it does allow us to access the three components of the vector without the rounding factor. In my city lights example, I used these outputs together with Math:Modulus and Math:GreaterThan nodes to produce a frame around the windows. This helps to divide different lit windows and create a more clear outline of each square.