Page 1 of 1

Texture rotation

PostPosted: Tue Oct 10, 2017 12:23 am
by mdaday
Hi,

I am a new Amplify Shader Editor user. I am trying to use the rotator node but I don't want it to animate at all and I want to use it to rotate a texture to an arbitrary value. Is this possible?

Thanks
mdaday

Re: Texture rotation

PostPosted: Tue Oct 10, 2017 8:51 am
by Amplify_Borba
Hello,

Welcome to our community and thank you for your support, it means alot to us!

It is possible to rotate a texture to an arbitrary value true the rotator node, since if a connection is made on the Time input port then it will assume that value as the final one and do not use any kind of timer internally.

So, in order to rotate the texture without animating it, you need to connect a Float through a Radians node to the Rotator's time input, and then use the Float node to set the angle of rotation.

I'm attaching an example of this node configuration for your convenience.

Rotate.jpg
Rotate.jpg (174.72 KiB) Viewed 10008 times


Please let me know if this was helpful, and if you have any further questions don't hesitate to get back in touch, thanks!

Re: Texture rotation

PostPosted: Tue Jan 30, 2018 9:28 am
by BDub
Thanks for the tip! I am trying to rotate a texture but at the same time keeping the tiling/offset because it is used as a grid for a plane. Is there a way to do this? The rotator passes in a UV and according to the documentation for Texture Sample, this overrides the texture tiling and offset parameters. :?:

Re: Texture rotation

PostPosted: Tue Jan 30, 2018 10:23 am
by Amplify_Borba
BDub wrote:Thanks for the tip! I am trying to rotate a texture but at the same time keeping the tiling/offset because it is used as a grid for a plane. Is there a way to do this? The rotator passes in a UV and according to the documentation for Texture Sample, this overrides the texture tiling and offset parameters. :?:


Hello BDub, thank you for getting in touch!

Although the Texture Sample node's UV input overrides the texture tiling and offset parameters, you may still set your intended values in the Texture Coordinates node's Tilling and Offset inputs, otherwise they'll simply pass the default values of (1,1) Tiling and (0,0) Offset to the texture, as the Rotator node will simply rotate the UV taking into account the Tiling and Offset parameters it receives. The following screenshot exemplifies a node setup similar to the previous one, but passing custom Tiling and Offset values to the Rotator node.

TCN.jpg
TCN.jpg (105.19 KiB) Viewed 9779 times


Please let me know if this helps, thanks!

Re: Texture rotation

PostPosted: Tue Jan 30, 2018 11:35 am
by BDub
That worked brilliantly!! Thanks for the quick reply (and the awesome asset!). :D

Re: Texture rotation

PostPosted: Tue Jan 30, 2018 11:51 am
by Amplify_Borba
BDub wrote:That worked brilliantly!! Thanks for the quick reply (and the awesome asset!). :D


Glad we could be of assistance, thank you for your support and kind words!

Please don't hesitate to get back in touch if you have any further questions, thanks!

Re: Texture rotation

PostPosted: Tue Jan 30, 2018 1:46 pm
by BDub
Just a quick note for anyone trying this. Adding tiling affects Anchor of Rotator so the anchor should be adjusted accordingly (ex. 0.5*tiling.x, 0.5*tiling.y, 0f, 0f). If you are using offsets, add offset to the anchor as well.

Example:
Code: Select all
Vector4 newRotatorAnchor = new Vector4(
   newTextureScale.x/2 + newTextureOffset.x,
   newTextureScale.y/2 + newTextureOffset.y,
   0f,
   0f
);
mat.SetVector("_RotatorAnchor", newRotatorAnchor);   

Re: Texture rotation

PostPosted: Tue Jan 30, 2018 2:13 pm
by BDub
oh and also add offset to anchor if you are using offset ;)

edit: added code example in my last post above.

Re: Texture rotation

PostPosted: Tue Jan 30, 2018 3:08 pm
by Amplify_Borba
Good point, apologies for not mentioning that in my reply.

Thank you for taking the time to share this information with the community!