Difference between revisions of "Modulo Scalar"

From Terragen Documentation from Planetside Software
Jump to: navigation, search
(Updated descriptions and added example images.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
[[Image:drex_module_80_image_0.png|485pxpx|Modulo Scalar]]
+
<div style="float:right; border-style:solid; padding:20px"><categorytree mode=pages hideroot=off>Divide</categorytree></div>
  
'''Node Description & Purpose: '''<br /> The Modulo scalar node is a function which does modulo division, also known as remainder division. The calculation it does is very simple and looks like this :<br /><br /> Input '''modulo''' Input 2<br /><br /> The output is the remainder of Input divided by Input 2. For example :<br /><br /> 5 '''modulo''' 4 = 1<br /><br /> because the remainder of 5 divided by 4 is 1. As another example :<br /><br /> 5 '''modulo''' 5 = 0<br /><br /> because 5 divided by 5 has no remainder. Similarly :<br /><br /> 6 '''modulo''' 3 = 0<br /><br /> because 6 divided by 3 has no remainder.<br /><br /> 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 :<br /><br /><tt>X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20</tt><br /><tt>Output : 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0</tt><br /><br /> 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 :<br /><br /><tt>X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20</tt><br /><tt>Output : 0 0 1 2 1 0 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5</tt><br /><br /> As you can see this does not give the same repeating sequence of numbers.<br /><br /> Let's go back to the original example. Imagine you wanted to make every place you get a zero from output as a white dot, and every place you got a number greater than zero as a black dot. You could make a pattern like this (where "o" is a white dot and "m" is a black dot) :<br /><br /><tt>X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20</tt><br /><tt>Output : 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0</tt><br /><tt>Pattern: o m m m m o m m m m o m m m m o m m m m o</tt><br /><br /> That is a pretty simplistic example, but hopefully you see what is meant. Using modulo division is the basis for creating repeating patterns.<br /><br />'''Node Type: '''Function<br /><br />'''Settings: '''<br />
+
[[File:ModuloScalar_00_GUI.png|none|470px|Modulo Scalar]]
  
* '''Input 2: '''The value corresponding to Input 2 in the description above.
 
  
<!-- imported from file: module_80.html-->
+
== Overview ==
  
[[Category:Divide| ]]
+
 
 +
<!-- [[Image:drex_module_80_image_0.png|485pxpx|Modulo Scalar]]
 +
 
 +
'''Node Description & Purpose: '''<br />  -->
 +
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 :
 +
<br /><br /> Main input '''modulo''' Input 2<br /><br /> The output is the remainder of Input divided by Input 2. For example :<br /><br /> 5 '''modulo''' 4 = 1<br /><br /> because the remainder of 5 divided by 4 is 1. As another example :<br /><br /> 5 '''modulo''' 5 = 0<br /><br /> because 5 divided by 5 has no remainder. Similarly :<br /><br /> 6 '''modulo''' 3 = 0<br /><br /> because 6 divided by 3 has no remainder.<br /><br /> 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 :<br /><br /><tt>X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20</tt><br /><tt>Output : 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0</tt><br /><br /> 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 :<br /><br /><tt>X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20</tt><br /><tt>Output : 0 0 1 2 1 0 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5</tt><br /><br /> As you can see this does not give the same repeating sequence of numbers.<br /><br />
 +
 
 +
<!--Let's go back to the original example. Imagine you wanted to make every place you get a zero from output as a white dot, and every place you got a number greater than zero as a black dot. You could make a pattern like this (where "o" is a white dot and "m" is a black dot) :<br /><br /><tt>X value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20</tt><br /><tt>Output : 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0</tt><br /><tt>Pattern: o m m m m o m m m m o m m m m o m m m m o</tt><br /><br /> That is a pretty simplistic example, but hopefully you see what is meant. Using modulo division is the basis for creating repeating patterns.<br /><br />'''Node Type: '''Function<br /><br />'''Settings: '''<br />  -->
 +
<ul>
 +
{|
 +
|-
 +
| [[File:ModuloScalar_03_Chart.JPG|none|800px|A comparison of the Modulo Scalar node’s output to that of the Main Input, as the value of Input 2 is changed.]]
 +
|-
 +
| [[File:ModuloScalar_02_Terrain.jpg|none|800px|Modular scalar node used to displace a terrain along the X axis position, as the value of Input 2 is changed.]]
 +
|-
 +
| [[File:ModuloScalar_01_NodeNetwork.jpg|none|800px|Node network view of the Modular scalar node receiving the X axis position values via its Main Input and performing the division operation based on the Constant scalar node assigned to its Input 2 setting.]]
 +
|}
 +
</ul>
 +
 
 +
 
 +
'''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.
 +
 
 +
 
 +
<br /n>
 +
 
 +
[[Category:Divide]]

Latest revision as of 23:55, 16 February 2022

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.

    A comparison of the Modulo Scalar node’s output to that of the Main Input, as the value of Input 2 is changed.
    Modular scalar node used to displace a terrain along the X axis position, as the value of Input 2 is changed.
    Node network view of the Modular scalar node receiving the X axis position values via its Main Input and performing the division operation based on the Constant scalar node assigned to its Input 2 setting.


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.