Author Topic: Help with Function linking Directional Warp Intensity to Transform Offset  (Read 1352 times)

Hello.

I am trying to set up a Directional Warp and Transformation 2D node where it automatically applies an offset in the Transform node when I input a value into the Directional warp Intensity divided by 512.

What I've found is if I warp an image with the Directional Warp node by 256 I have to Transform in the opposite direction by -0.5 to get the warp to "stay in place". I am trying to create a custom node that does the math automatically.

Directional Warp Intensity 256/512=Transform Offset 0.5

How do I set up a function in the Transform 2D node to Look for the Directional Warp intensity and do the needed math?
Last Edit: March 30, 2017, 08:54:27 pm

Here is the function as I was expecting it to work. However the Set As Output option is greyed out.


The Intensity of the Directional Warp is a Float 1 but the Transformation 2D offset sliders are Float 2. I'm pretty sure that's why my Set as Output is grayed out as I can't use Float 1 and 2 data together without some proper maths.

Any help on this would be greatly appreciated.

Thanks.

Update:
I have the math working now however I do not know how to link my output of my function graph to the X and Y sliders (Vector2) of the Transform 2D Node.

If the Warp Angle Turns is set to 0 you must transform negatively in X
If the Warp Angle Turns is set to 0.25 you must transform negatively in Y
If the Warp Angle Turns is set to 0.5 you must transform positively in X
If the Warp Angle Turns is set to 0.75 you must transform positively in Y

Any help would be greatly appreciated.

It looks like you are moments away from finding the answer! the Vector2 node builds a vector based on two inputs, whereas the Swizzle2 node isolates components of the vector based on an inputted Vector of whatever number. So in this case, your Swizzle node is trying to extract Y data from a float1, and so getting the X component, and 0.
Set the Vector2 as output and it'll start to work. Is the off-screen portion of the graph an X offset component? That will probably be needed for the Vector2 node as well.

To save you some trouble, too, you'll find it easier to build the graph by having the If statement switch between -1 and 1, and then feed that into one multiplier, rather than have the whole equation doubled.
But, if you think you'll want more than just 90 degree increments, better to use cos and sin for X and Y. No need for if statements at all. Multiply turns by 2pi first (aka Tau, the better constant).

Whoa you just dropped some serious knowledge onto me here. I will take a look at this and try your methods!

How do I factor in the correct Warp Intensity math to get the correct offset? Or does the COS and SIN operations take care of that?

Thank you so much Cory.

Chris.

EDIT: I removed the X and Y swizzles from the Vector2
Last Edit: March 31, 2017, 07:03:10 pm

You're right, the correct offset is a final piece of the puzzle. Since Sin and Cos are simply giving the ratio of X and Y movement in relation to the hypotenuse of the drawn triangle, and the hypotenuse, in this case, is the distance you want to move, you only need to multiply the results of both the sin and cos operations with the results of your divide-by-512 operation, and it should all work properly! (Theoretically. I haven't actually tested it, and I could be wrong, but everything looks right!)

So close!

That didn't work. I'm not entire sure how to approach this anymore. I know it's possible as other artists have set up such a function.

I suspect to get the Sin and Cos to work properly there needs to be more math. I was thinking turnstodegrees node which got me a little closer but still not correct.

Sin and Cos want Radians, I believe. Multiplying turns by 2pi should get those things working.

Edit: I'd forgotten, you did that step already.

I decided that it was probably time to try this myself. I did get it working, but with a few adjustments. One, Cos should be the first term of the vector2, and Sin the second, and two, I found the correct amount of movement came by dividing the strength by 256, not 512.  Hope this helps!
Last Edit: April 05, 2017, 05:56:27 am

Hey Cory.

It works perfect now. Now trying to figure out how you knew to assign Cos and Sin to the right X Y channel of the vector2!


Thanks so much.

Well, that was just old-fasioned SohCahToa, with a glance at how the directional warp counts turns. I'm glad it all worked out!