15

I'm creating my own merge functions in the compositor, but I've run into a bit of a wall. How do you calculate the square root with nodes? Would one have to write a python node to do this? If so, what would that look like?

H Petrus
  • 341
  • 3
  • 8

1 Answers1

16

The square root of x equals x^.5, so use a math node set to Power and put the value whose square root you want in the upper socket, and set the lower value to .5.

enter image description here

  • 1
    Thanks for this, Duane. I just discovered this myself minutes ago and was about to answer my own question. You beat me to it. Helps a lot. – H Petrus Dec 18 '16 at 20:46
  • 3
    To generalize a bit, the nth root is equal to the inverse power, i.e. root(x, n) == x^(1/n). So if you wanted, you could construct a node group which divides 1 by the root before feeding it to a power node, and then you'd have a root node. – gandalf3 Dec 18 '16 at 20:47
  • 1
    @gandalf3 an Absolute node, or similar, too to make sure input is >= 0 ? – batFINGER Dec 19 '16 at 12:47