# How to get Vector Length in the compositor?

I have a Material node setup that processes color and I want to recreate that node tree for the Compositor.

Unfortunately the setup relies on a Vector Math : Length node to accomplish what it does.

Looking at the Blender Manual's entry for the Vector Math node, we can see that Length is performing the following function:

Can this be replicated using Math nodes in the Compositor?

• Well, even without looking into the Blender Manual, this formula is simply the formula for the Euclidean distance, the length of a line segment between two points in Euclidean space. And since everything is written out there and you have a Math node in the Compositor, I'm a bit confused what is the problem to recreate it... anyway, Robin provided an answer for you. If his multiplying the X, Y and Z values with themselves does not look close enough to the original formula for you, you could instead of Multiply set the nodes to Power and choose 2 as Exponent. Jun 21 at 9:31
• @GordonBrinkmann (Power avoided, for efficiency, but no great shakes) Jun 21 at 9:33
• @RobinBetts I would have done it that way, too... but since not everybody might have great math skills I just mentioned it if something like $A_x \cdot A_x$ looks wrong to him compared to $A_x^2$. Jun 21 at 9:40
• @GordonBrinkmann Bingo! I don't understand mathematical notation, so I wouldn't be certain whether to do (A * A)*x or A*(x*2) and since I don't want to patch something together based on assumptions, I just ask. But the math makes perfect sense to me when I see it in the form of Blender nodes! I realize there would probably be value in studying mathematical notation at some point, but that can be said of many things. Will I ever get around to it? Remains to be seen... :-) And by posting Q&A about it, hopefully others of limited math skills will also find this info helpful. Jun 23 at 1:02
• @Mentalist Yes, I think maths can be challenging sometimes. Especially since working with Blender in many tasks not necessarily requires math skills from the user. Jun 23 at 6:54

## 1 Answer

Yup. Just transcribe the expression, and group it up:

• Worth a check though, that whatever color-processing you're doing, is not already provided by the compositor, internally .. Jun 21 at 7:37
• Thank you! The purpose is to approximate the operation which in Photoshop terminology would be called Select → Color Range... Here is a Material Nodes solution, which is based on previous contributions of yours (see links in that answer). ;-) Jun 23 at 0:43
• @Mentalist Hehe ... I thought it might be :) That's provided by the Distance Key node. Variations are available, whereby you can set separate thresholds for H,S,and V, for example. Jun 23 at 7:21
• Good to know! Thanks for mentioning that. Having inter-compatibility between node types (Materials/Compositor) is satisfying in its own right though - so even if there is overlap with an existing node's functionality, a custom Vector Math: Length node is still welcome, as far as I'm concerned. ;-) But I will definitely play around with Distance Key as well. Cheers. Jun 23 at 8:38
• Here's a .blend of what I've been tinkering with, in case you're curious to see how your answer helped. Matching Compositor/Material node setups for isolating image hue. A bit geeky... maybe not useful to everyone... but I'm pretty happy about it. Jun 23 at 10:46