Difference between revisions of "Node Input Type Conversion"

From Terragen Documentation from Planetside Software
Jump to: navigation, search
(Created page with '==Node Input Type Conversion== Terragen 2 is pretty flexible about what can be used for input to nodes. Particularly in the case of function nodes, nodes are designed to handle ...')
 
Line 1: Line 1:
==Node Input Type Conversion==
 
 
 
Terragen 2 is pretty flexible about what can be used for input to nodes. Particularly in the case of function nodes, nodes are designed to handle a particular type. For example the "Multiply scalar" node is designed to work with scalars, and the "Multiply colour" node is designed to work with colours. You can however use a node for input which is sending a different type for its output, i.e. you can connect a "Multiply scalar" node to an input of the "Multiply colour" node and you will still get a result.
 
Terragen 2 is pretty flexible about what can be used for input to nodes. Particularly in the case of function nodes, nodes are designed to handle a particular type. For example the "Multiply scalar" node is designed to work with scalars, and the "Multiply colour" node is designed to work with colours. You can however use a node for input which is sending a different type for its output, i.e. you can connect a "Multiply scalar" node to an input of the "Multiply colour" node and you will still get a result.
  
 
Terragen 2 does this through a process known as type conversion, also known as type casting. Type conversion can convert a vector into a scalar, or a scalar into a colour and so on. If you input a colour into a node expecting a scalar, the input colour will be converted to a scalar. Here is a list of the type conversion rules Terragen 2 uses :
 
Terragen 2 does this through a process known as type conversion, also known as type casting. Type conversion can convert a vector into a scalar, or a scalar into a colour and so on. If you input a colour into a node expecting a scalar, the input colour will be converted to a scalar. Here is a list of the type conversion rules Terragen 2 uses :
  
'''Vector to colour'''<br /> When converting a vector to a colour, a piecewise component copy is done :
 
  
colour.red '''becomes''' vector.x<br /> colour.green '''becomes''' vector.y<br /> colour.blue '''becomes''' vector.z
+
'''Vector to colour'''<br />
 +
When converting a vector to a colour, a piecewise component copy is done :<br />
 +
 
 +
colour.red ''becomes'' vector.x<br />
 +
colour.green ''becomes'' vector.y<br />
 +
colour.blue ''becomes'' vector.z<br />
 +
 
 +
 
 +
'''Colour to vector'''<br />
 +
When converting a colour to a vector, a piecewise componenet copy is done :<br />
 +
 
 +
vector.x ''becomes'' colour.red<br />
 +
vector.y ''becomes'' colour.green<br />
 +
vector.z ''becomes'' colour.blue<br />
 +
 
 +
 
 +
'''Vector to scalar'''<br />
 +
When converting a vector to a scalar, the scalar is set to the magnitude of the vector using the following formula:<br />
 +
 
 +
scalar ''becomes'' <u>square root of</u> ( vector.x x vector.x + vector.y x vector.y + vector.z x vector.z )<br />
 +
 
  
'''Colour to vector'''<br /> When converting a colour to a vector, a piecewise componenet copy is done :
+
'''Scalar to vector'''<br />
 +
When converting a scalar to a vector, each component of the vector is simply set to the value of the scalar :<br />
  
vector.x '''becomes''' colour.red<br /> vector.y '''becomes''' colour.green<br /> vector.z '''becomes''' colour.blue
+
vector.x ''becomes'' scalar<br />
 +
vector.y ''becomes'' scalar<br />
 +
vector.z ''becomes'' scalar<br />
  
'''Vector to scalar'''<br /> When converting a vector to a scalar, the scalar is set to the magnitude of the vector using the following formula:
 
  
scalar '''becomes''' <u>square root of</u>( vector.x x vector.x + vector.y x vector.y + vector.z x vector.z )
+
'''Scalar to colour'''<br />
 +
When converting a scalar to a colour, each component of the colour is simply set to the value of the scalar :<br />
  
'''Scalar to vector'''<br /> When converting a scalar to a vector, each component of the vector is simply set to the value of the scalar :
+
colour.red ''becomes'' scalar<br />
 +
colour.green ''becomes'' scalar<br />
 +
colour.blue ''becomes'' scalar<br />
  
vector.x '''becomes''' scalar<br /> vector.y '''becomes''' scalar<br /> vector.z '''becomes''' scalar
 
  
'''Scalar to colour'''<br /> When converting a scalar to a colour, each component of the colour is simply set to the value of the scalar :
+
'''Colour to scalar'''<br />
 +
When converting a colour to a scalar, the scalar is set to the luminance value of the colour :<br />
  
colour.red '''becomes''' scalar<br /> colour.green '''becomes''' scalar<br /> colour.blue '''becomes''' scalar
+
scalar ''becomes'' luminance of colour<br />
  
'''Colour to scalar'''<br /> When converting a colour to a scalar, the scalar is set to the luminance value of the colour :
 
  
scalar '''becomes''' luminance of colour
+
[[Terragen 2 Network View Guide|Back to Network View Guide]]

Revision as of 04:44, 29 March 2012

Terragen 2 is pretty flexible about what can be used for input to nodes. Particularly in the case of function nodes, nodes are designed to handle a particular type. For example the "Multiply scalar" node is designed to work with scalars, and the "Multiply colour" node is designed to work with colours. You can however use a node for input which is sending a different type for its output, i.e. you can connect a "Multiply scalar" node to an input of the "Multiply colour" node and you will still get a result.

Terragen 2 does this through a process known as type conversion, also known as type casting. Type conversion can convert a vector into a scalar, or a scalar into a colour and so on. If you input a colour into a node expecting a scalar, the input colour will be converted to a scalar. Here is a list of the type conversion rules Terragen 2 uses :


Vector to colour
When converting a vector to a colour, a piecewise component copy is done :

colour.red becomes vector.x
colour.green becomes vector.y
colour.blue becomes vector.z


Colour to vector
When converting a colour to a vector, a piecewise componenet copy is done :

vector.x becomes colour.red
vector.y becomes colour.green
vector.z becomes colour.blue


Vector to scalar
When converting a vector to a scalar, the scalar is set to the magnitude of the vector using the following formula:

scalar becomes square root of ( vector.x x vector.x + vector.y x vector.y + vector.z x vector.z )


Scalar to vector
When converting a scalar to a vector, each component of the vector is simply set to the value of the scalar :

vector.x becomes scalar
vector.y becomes scalar
vector.z becomes scalar


Scalar to colour
When converting a scalar to a colour, each component of the colour is simply set to the value of the scalar :

colour.red becomes scalar
colour.green becomes scalar
colour.blue becomes scalar


Colour to scalar
When converting a colour to a scalar, the scalar is set to the luminance value of the colour :

scalar becomes luminance of colour


Back to Network View Guide

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.