Material graph power node doesn't allow negative base?

I’m using the power node and hoping to get alternating values, e.g. f(x)=-1^x.

I’ve found if I enter a negative value as the base for the power node the output is always zero. Here are the results of a few tests using the debug scalar values node:

-1^2 = 0
0^2 = 0
1^2 = 1
2^2 = 4

Is this expected behavior of the power node? If so, is there any other way around this limitation? I really need to be able to do x^n… was not expecting to be stuck on this today, lol.

1 Like

image

It’s to do with the fact that shaders can’t show you negative values:

Well… don’t I feel dumb for not reading the tooltip. Thanks!

1 Like

By the way - is there any particular reason for Power node to clamp negative values in base?
It’s seems counterintuitive and limiting since it’s not allowing us to power negative values.

Is there any alternative?
I guess the only way to workaround around this is to do something like pow(abs(base), exp) and somehow add the correct sign to it.