Author Topic: How to rotate shapes in rectangular images w/o stretching?  (Read 133 times)

I have a pattern I am trying to rotate that is for a rectangular image. Whenever I try to rotate using the Transform 2D node, there is stretching. I try to fix this using the various parameters (pixel size, output size, etc.) but nothing has any effect. How can I make the pattern rotate correctly?  Images provided. I need to rotate this cross 22.5, 45, and 67.5 degrees (first image) so that it cuts up this window pattern into 16 segments per ring (second image). Driving me kind of nuts. Stretching during a 45 degree rotation is shown in the last image.

EDIT: The image is 1:2 ratio in order to reduce file size. The desired pattern from all this work is the low-poly UV template shown in the third image (this is only the top portion of the UV reference; the entire map is rectangular, not square).
Last Edit: April 07, 2019, 02:12:10 pm

Solution seems to be as follows:

Suppose your image dimensions are 1:2 and you want to do a rotation without distortion.

The 2D transformation matrix for clockwise rotation is

[cos(theta), sin(theta);
-sin(theta), cos(theta)]

However, in Substance Designer, the matrix elements appear transposed (the upper-diagonal elements are swapped).

You can correct the distortion by editing the transformation matrix to have the following values for an arbitrary rotation, theta:

[cos(theta), -0.5*sin(theta);
2*sin(theta), cos(theta)]


In general, for an image in ratio [a:b], note that this is same as [1:b/a] ratio. Then the required clockwise rotation matrix is:

[cos(theta), (b/a)*sin(theta);
-(a/b)*sin(theta), cos(theta)]

... which is the following for Substance Designer's transposed "2D Transform" node matrix:

[cos(theta), -(a/b)*sin(theta);
(b/a)*sin(theta), cos(theta)]

 ;D
Last Edit: April 07, 2019, 04:42:14 pm

I adjusted my own little transform tool to work correctly for non-square images. (The matrix math was pretty helpful for this :) )
I originally made it for ease of use of skewing and scaling with rotation, so the controls are a bit different from the default transform node, but it should still be understandable.

I attached the sbs, use it however / wherever you want
Last Edit: April 08, 2019, 03:08:14 pm
Esger van der Post.
Game design student and texturing addict.