Difference between revisions of "Add Scalar"

From Terragen Documentation from Planetside Software
Jump to: navigation, search
(Correction to previous edit)
m (Disabled table of contents for now, until Fun With section has some examples.)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[File:AddScalar_00_GUI.png|none|470px|Add Scalar]]
+
[[File:AddScalar_00a_GUI.png|none|470px|Add Scalar]]
  
  
__TOC__
+
<!-- __TOC__ -->
  
 
== Overview ==
 
== Overview ==
The Add family of nodes allow you to add the colour/scalar/vector coming into the Main Input by the color/scalar/vector coming into Input 2.
+
The Add family of nodes allow you to add the colour/scalar/vector coming into the Main Input with the colour/scalar/vector coming into Input 2.
  
The Add scalar node wants the incoming data to be scalars, but it will convert colours and vectors to scalars if necessary.
+
The Add Scalar node adds two scalars together. It wants the incoming data to be scalars, but it will convert colours and vectors to scalars if necessary.
  
When the source of the incoming data is colour data, the Add scalar node converts the data to scalar based on the component's luminance values.  The math for this is: 0.2125 * r + 0.7152 *g + 0.0724 * b.
+
* When the source of the incoming data is colour data, the Add Scalar node converts the data to scalar based on the luminance of the colour.  The math for this is: 0.2125 * r + 0.7152 *g + 0.0724 * b.
  
When the source of the incoming data is vector data, the Add scalar node converts the data to scalar based on the length of the vector from the zero origin.  The math for this is: square_root(x*x + y*y + z*z).
+
* When the source of the incoming data is vector data, the Add Scalar node converts the data to scalar based on the length of the vector.  The math for this is: square_root(x*x + y*y + z*z).
 
All nodes in this family have just one setting, which lets you assign a shader or function nodes to Input 2.
 
  
  
'''Settings:'''
+
In the example image below, the Add Scalar node simply adds the scalar values from the nodes assigned to it.
 +
<ul>
 +
[[File:AddScalar_10_Scalar.JPG|none|800px|The Add Scalar node adds together the scalar data from the Main Input and Input 2.]]
 +
</ul>
  
*'''Name:''' This setting allows you to apply a descriptive name to the node, which can be helpful when using multiple Add Scalar nodes in a project.
 
*'''Enable:''' When checked, the node is active and the Main Input value is added with the Input 2 value.  When unchecked, only the Main Input value is passed through the node.
 
*'''Input 2:''' The values from the shader or function nodes assigned to this setting are added to the values of the Main Input.
 
  
== Fun with Add Scalar ==
+
The Add Scalar node requires scalar data.  One way to convert colour data to scalar data is shown below, where the Luminance to scalar node is used to convert the colour output of the Power fractal node.
 +
<ul>
 +
[[File:AddScalar_11_ColourInputsPF3.JPG|none|800px|The Add scalar node requires scalar data.  One way to convert colour data to scalar data is by using a Luminous to scalar node.]]
 +
</ul>
  
[[File:AddScalar_01_MainInputAndInput2.JPG|none|800px| Add scalar combines the Main Input and Input 2 component values, discarding displacement data, and outputting scalar data.]]
 
  
 +
The Add Scalar node will automatically convert non-scalar data to scalar before adding them together as described above.  Only scalar data is recognized and any displacement data a shader provides is ignored and not passed through. In the example below, the colour values from both Power fractal shaders are converted to scalar data and the displacement data discarded.  Only scalar values are output by the Add Scalar node.
 +
<ul>
 +
[[File:AddScalar_12_PF3DisplaceIgnored.JPG|none|800px|The Add Scalar node will convert non-scalar values to scalar and ignores any displacement data.]]
 +
</ul>
  
[[File:AddScalar_02_MainInputOnly.JPG|none|800px|When Input 2 is unassigned, data from the Main Input is passed through as scalar data.]]
 
  
 +
When Input 2 is unassigned, the Main Input’s component values are passed through, first converting them to scalar if necessary.
 +
<ul>
 +
[[File:AddScalar_13_MainInputOnly.JPG|none|800px|When Input 2 is unassigned, data from the Main Input is passed through as scalar data.]]
 +
</ul>
  
[[File:AddScalar_03_Input2Only.JPG|none|800px|When the Main Input is unassigned, nothing is passed through.]]
 
  
 +
When the Main Input is unassigned, the value zero (black) is passed through.
 +
<ul>
 +
[[File:AddScalar_14_Input2Only.JPG|none|800px|When the Main Input is unassigned, the value zero (black) is passed through.]]
 +
</ul>
  
[[File:AddScalar_04_ColourInputs.JPG|none|800px|When colour values are used as the source for the Main Input and Input 2, their component’s luminance values are used.]]
 
  
 +
When colour sources are assigned to the Main Input or Input 2, the colour’s luminance value is used as described above.  Only scalar data is output.
 +
<ul>
 +
[[File:AddScalar_15_ColourInputs.JPG|none|800px|Colour sources are converted to scalar by using the colour’s luminance value.]]
 +
</ul>
  
[[File:AddScalar_05_VectorInputs.JPG|none|800px|When vector values are used as the source, the scalar values are based on the length of the vector from a zero origin.]]
 
  
 +
When vector sources are assigned to the Main Input or Input 2, the node produces a scalar value based on the length of the vector as described above.  Only scalar data is output.
 +
<ul>
 +
[[File:AddScalar_16_VectorInputs.JPG|none|800px|Vector sources are converted to scalar based on the length of the vector.  The math is square_root(x*x + y*y + z*z).]]
 +
</ul>
  
 +
<!-- [[File:AddScalar_17_VectorAndColourInputs.JPG|400px]] -->
  
[[File:AddScalar_06_VectorAndColourInputs.JPG|none|800px|Vector and colour values can be used simultaneously as inputs to the Add Scalar node.  Their component values are converted as necessary and output as scalar data.]]
 
  
 +
'''Settings:'''
  
 +
*'''Name:''' This setting allows you to apply a descriptive name to the node, which can be helpful when using multiple Add Scalar nodes in a project.
 +
*'''Enable:''' When checked, the node is active and the Main Input value is added with the Input 2 value.  When unchecked, only the Main Input value is passed through the node.
 +
*'''Input 2:''' The values from the shader or function nodes assigned to this setting are added to the values of the Main Input.
  
[[File:AddScalar_07_VDMAndColourInputs.JPG|none|800px|No matter the type of source data, the output of the Add Scalar node is scalar data.]]
+
<!-- == Fun with Add Scalar ==  -->
 
 
  
  

Latest revision as of 22:31, 28 January 2022

Add Scalar


Overview[edit]

The Add family of nodes allow you to add the colour/scalar/vector coming into the Main Input with the colour/scalar/vector coming into Input 2.

The Add Scalar node adds two scalars together. It wants the incoming data to be scalars, but it will convert colours and vectors to scalars if necessary.

  • When the source of the incoming data is colour data, the Add Scalar node converts the data to scalar based on the luminance of the colour. The math for this is: 0.2125 * r + 0.7152 *g + 0.0724 * b.
  • When the source of the incoming data is vector data, the Add Scalar node converts the data to scalar based on the length of the vector. The math for this is: square_root(x*x + y*y + z*z).


In the example image below, the Add Scalar node simply adds the scalar values from the nodes assigned to it.

    The Add Scalar node adds together the scalar data from the Main Input and Input 2.


The Add Scalar node requires scalar data. One way to convert colour data to scalar data is shown below, where the Luminance to scalar node is used to convert the colour output of the Power fractal node.

    The Add scalar node requires scalar data.  One way to convert colour data to scalar data is by using a Luminous to scalar node.


The Add Scalar node will automatically convert non-scalar data to scalar before adding them together as described above. Only scalar data is recognized and any displacement data a shader provides is ignored and not passed through. In the example below, the colour values from both Power fractal shaders are converted to scalar data and the displacement data discarded. Only scalar values are output by the Add Scalar node.

    The Add Scalar node will convert non-scalar values to scalar and ignores any displacement data.


When Input 2 is unassigned, the Main Input’s component values are passed through, first converting them to scalar if necessary.

    When Input 2 is unassigned, data from the Main Input is passed through as scalar data.


When the Main Input is unassigned, the value zero (black) is passed through.

    When the Main Input is unassigned, the value zero (black) is passed through.


When colour sources are assigned to the Main Input or Input 2, the colour’s luminance value is used as described above. Only scalar data is output.

    Colour sources are converted to scalar by using the colour’s luminance value.


When vector sources are assigned to the Main Input or Input 2, the node produces a scalar value based on the length of the vector as described above. Only scalar data is output.

    Vector sources are converted to scalar based on the length of the vector.  The math is square_root(x*x + y*y + z*z).


Settings:

  • Name: This setting allows you to apply a descriptive name to the node, which can be helpful when using multiple Add Scalar nodes in a project.
  • Enable: When checked, the node is active and the Main Input value is added with the Input 2 value. When unchecked, only the Main Input value is passed through the node.
  • Input 2: The values from the shader or function nodes assigned to this setting are added to the values of the Main Input.



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

A vector is a set of three scalars, normally representing X, Y and Z coordinates. It also commonly represents rotation, where the values are pitch, heading and bank.

This is essentially the brightness of the colour. Terragen converts RGB colours to greyscale by taking the luminance of the colour.

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.

Literally, to change the position of something. In graphics terminology to displace a surface is to modify its geometric (3D) structure using reference data of some kind. For example, a grayscale image might be taken as input, with black areas indicating no displacement of the surface, and white indicating maximum displacement. In Terragen 2 displacement is used to create all terrain by taking heightfield or procedural data as input and using it to displace the normally flat sphere of the planet.

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.