Add Scalar explained

Started by Hetzen, September 19, 2019, 07:42:15 AM

Previous topic - Next topic

Hetzen

Add Scalar takes the Main Input connection and adds it to the Input 2 connection and passes the result to the Output.

Add Scaler_01.jpg

Notice that the displacement from the Power Fractals has been stripped away and only the grey scalar value has been used in the output. If you want to add displacements together then the Merge Shader would be the node to use.

If Input 2 is disconnected, the Main Input passes through to the Output, again without the displacement, only the scalar grey value.

Add Scaler_02.jpg

If the Main Input is disconnected, nothing passes through.

Add Scaler_03.jpg

If you connect two colour sources, the Add Scalar node will take the luminance of the colour channels of each input to create a grey scale map of the inputs brightness and then add them together, ignoring the colour information. The maths being luminance = 0.2125 * r + 0.7152 * g + 0.0724 * b

Add Scaler_04.jpg

If you connect vector sources to the inputs, the node will look at the length the vector makes from a zero origin to produce a scalar value. The internal maths to do this is the  square_root(x*x + y*y + z*z).

Add Scaler_05.jpg

The preview panel can only show values up to 2 (the Preview Panel is set this way to see overlaid graphics), so the pure white areas have values beyond 2 in this example. There is no restriction to the size of the number being affected.

Add Scaler_06.jpg


If there's any errors, omissions or questions about the above, please leave a comment below.

Wiki link: https://planetside.co.uk/wiki/index.php?title=Add_Scalar

Matt

This is a great introduction.

Two corrections:

When a colour is converted to a scalar, it uses the "luminance" of the colour using the following: luminance = 0.2125 * r + 0.7152 * g + 0.0724 * b

When a vector is converted to a scalar, it uses square_root(x*x + y*y + z*z), which is the length of the vector.

https://planetside.co.uk/wiki/index.php?title=Node_Input_Type_Conversion
Just because milk is white doesn't mean that clouds are made of milk.

Hetzen

Thanks Matt, I'll amend the header post.