Multiply vs. Power node

Node-based Shader Editor

Multiply vs. Power node

Postby Desoxi » Wed Nov 15, 2017 3:36 pm

Hey again,
i was just writing/noding (however its called in node systems :D ) a shader which rounds corners on images.
So i wanted to control the "roundness" of the corners and have written the following code to test with 2 multiply nodes:
Image

https://ibb.co/c5w58R

That works fine, but i dont have any control over the roundness. So i decided to change that to a power node to control the exponent via the inspector:

Image

https://ibb.co/iChdTR

However the power nodes did not work. While the multiply nodes work just fine and round all 4 corners:

Image

https://ibb.co/n2i2oR

the power nodes just round the top right corner and ignores all other corners:

Image

https://ibb.co/kaRmhm

That is weird because mathematically it should be the same!
So i tried a few things and played around and randomly changed the scalar value which is the input to the both "exp" inputs of the power nodes from "property" to "constant" and voila! It works!
This really is really weird and i think that it is a bug.
Do you know if there is a workaround for me to still be able to expose that scalar to the inspector? Or do i have to wait for a patch? :)

EDIT: even on constant scalar nodes it doesnt work on real numbers like x.y with y!= 0
And values like 7, 9, 10 or 11 doesnt work either. Cant see a pattern there atm. Maybe im missing something obvious.
Desoxi
 
Posts: 9
Joined: Sat Nov 11, 2017 10:35 pm

Re: Multiply vs. Power node

Postby Amplify_RnD_Rick » Thu Nov 16, 2017 2:06 pm

Hey Desoxi,

That's quite the interesting issue and it's not completely obvious why this happen.

The Power node is using the Cg/HLSL pow function to calculate the result. This function internally is not implemented as you would think, it used an optimized expression exp(x * log(y)) which has its flaws.

This function does not take into account possible signal changes. In your case there's a simple solution to make sure it gives you correct results, which is passing the remapped values through an Abs node before connecting them into the Base port of the Power node.

Something like this:
PowFix.PNG
PowFix.PNG (235.51 KiB) Viewed 1149 times


Please let us know if this solution works for you and don't hesitate on reaching us if you have further questions or stumble into any other issues.
Amplify_RnD_Rick
 
Posts: 40
Joined: Wed Mar 01, 2017 6:33 pm


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 75 guests