# Modulo Scalar

## Overview[edit]

The Modulo scalar node is a function which does modulo division, also known as remainder division. Using modulo division is the basis for creating repeating patterns. The calculation it performs is very simple and looks like this :

Main input **modulo** Input 2

The output is the remainder of Input divided by Input 2. For example :

5 **modulo** 4 = 1

because the remainder of 5 divided by 4 is 1. As another example :

5 **modulo** 5 = 0

because 5 divided by 5 has no remainder. Similarly :

6 **modulo** 3 = 0

because 6 divided by 3 has no remainder.

One of the situations that modulo division is most useful in is for making repeating patterns. Imagine that you wanted to divide the X axis into blocks 5 units long. You would set up a Modulo scalar node so that the Input was the X position and Input 2 was a Constant scalar node with a value of 5. This will output values which look like this :`X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``Output : 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0`

As you can see you now get a repeating series of numbers from the output. Note that for this to work you need to make the Input value the varying number (in this case the X axis position) and the Input 2 value the constant value you are comparing with (5 in this case). If you did it the other way around you would get a output like this :`X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``Output : 0 0 1 2 1 0 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5`

As you can see this does not give the same repeating sequence of numbers.

**Settings:**

**Name:**This setting allows you to apply a descriptive name to the node, which can be helpful when using multiple Modulo Scalar nodes in a project.**Enable:**When checked, the node is active and the division operation will take place. When unchecked the values assigned to its Main Input, if any, are passed through, otherwise a value of 0 is passed through.**Input 2:**The values from the shader or function nodes assigned to this setting are used as the divisor to the Main Input to determine the Modulo scalar output, which is the remainder from the division operation, or zero.

A scalar is a single number. 1, 200.45, -45, -0.2 are all examples of scalar values.

A single object or device in the node network which generates or modifies data and may accept input data or create output data or both, depending on its function. Nodes usually have their own settings which control the data they create or how they modify data passing through them. Nodes are connected together in a network to perform work in a network-based user interface. In Terragen 2 nodes are connected together to describe a scene.

A shader is a program or set of instructions used in 3D computer graphics to determine the final surface properties of an object or image. This can include arbitrarily complex descriptions of light absorption and diffusion, texture mapping, reflection and refraction, shadowing, surface displacement and post-processing effects. In Terragen 2 shaders are used to construct and modify almost every element of a scene.