7
$\begingroup$

I was wondering what happens when a vector is fed into a Math -> Add node. Notice that I'm asking about the Math -> Add node, not the Vector Math -> Add node.

My guess was that the node automatically works with the vector module, but I noticed that with different normal vectors the output is different.

Can somebody explain the behavior of the node in this case?

$\endgroup$

2 Answers 2

11
$\begingroup$

🟣 Vector values convert to ⚫ scalar values by averaging all three components, therefore the following material should be white:

(both branches compare as equal)

⚠ At very big values the $Ρ = 0$ starts to fail due to floating point inaccuracies:

(383 m cube)

Crantisz'es answer is incorrect, if it worked by converting 🟣 vector through 🟑 color to ⚫ scalar, then this material wouldn't be black (I even increased Ρpsilon to 0.1):

🟣 Vector is Converted to color (and vice-versa) by simply treating XYZ as RGB (I think it's fair to say it's reinterpretation, not conversion, the values in memory don't change), however, 🟣 vector and 🟑 color convert differently to ⚫ scalars:

  • 🟣 vector to ⚫ scalar: $v = {1\over3} x + {1\over3} y + {1\over3} z = {x+y+z\over3}$
  • 🟑 color to ⚫ scalar: $v = 0.2126r + 0.7152g + 0.0722b = $ luminance(rgb)

For completeness, ⚫ scalar converts both to 🟣 vector and 🟑 color by triplicating (repeating) its value on all 3 components, which maintains luminance, and so is a reverse operation for both $🟣➑⚫$ and 🟑➑⚫.

Geometry Nodes

In gnoodles the same rules apply, but additionally:

  • ⚫ Float (Scalar) values convert to 🌸 Boolean as True if they are positive ($> 0$)
  • 🟣 Vectors convert to 🌸 boolean as False if all the components are zero, otherwise to True. You can reason about it as the length of vector being used in the logic of scalar to Boolean conversion (the length is never negative but can be $0$).
  • 🟑 Color is first converted to ⚫ Float (using its luminance), and then converted to 🌸 Boolean.
  • ⚫ Float converts to 🟒 integers by truncating, which is discarding the fractional part (rounding towards zero; flooring positive values and ceiling negative values).
$\endgroup$
1
  • $\begingroup$ Thank you. I tried it out with many different vectors and, indeed, the Compare returns always true. $\endgroup$
    – FDC
    Jun 22, 2022 at 9:27
-2
$\begingroup$

Vector converts to color, and the color data is converted to its gray scale equivalent

From Blender Wiki:

Some socket types can be converted to other socket types either implicitly or explicitly. Implicit conversion can happen automatically without the need of a conversion node.

For example, color and float sockets can both be placed into one another. Once a socket conversion is made data may be lost and cannot be retrieved later down the node tree. Implicit socket conversion can sometimes change the data units as well. When plugging a Value input node into an angle socket will default to use radians regardless of the scene Units. This happens because the Value node has no unit while the angle input does.

Valid conversions:

Between color and vector – in this case the using individual color channels to store the vector.

Between color and float – the color data is converted to its gray scale equivalent.

Color/float/vector to Shader – implicitly converts to color and gives the result of using an Emission node.

Explicit conversion requires the use of a conversion node for example the Shader To RGB node or the RGB to BW Node node. The Math Node node also contains some functions to convert between degrees and radians.

$\endgroup$
1
  • 4
    $\begingroup$ This answer doesn't mention vector to scalar conversion, unless I understood correctly that you claim when converting 🟣 to ⚫, since it's not listed in "valid conversions", the actual conversion becomes 🟣 ➑ 🟑 ➑ ⚫ (which is incorrect as I argue in my answer) $\endgroup$ Jun 22, 2022 at 9:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .