hi guys I am kind new to material system, just start to learn a bit about the textCoord calculation. In the engine default node “Custom rotator”, in the node it gives this:
so…what I understand is, texcoord put every UV point like(0,0), (0,0.1)… those point into the calculation to change the texture sample, but how they use dot product from UV point and a (sine, cosine) vector to obtain the rotating result of each X axis point? I tried to find the relationship between trignometry and dot product but still no clue, maybe I miss something. So can anyone explain that for me please?
Part 1 is essentially taking the pivot point and measuring the distance between each pixel ( UV coord ) and that pivot point. This in itself is a vector or direction.
Part 2 is taking the angle of rotation and producing a constant X. It’s basic trig, you’ve given an angle, and we know the distance from the rotation origin. A crucial point is that the stuff in part 1 is different for every pixel. Two constants are developed here, because we are dealing with U and V.
Part 3 Dot product tells you how ‘different’ directions are. 1 for the same, 0 for right angles, -1 for opposing. So this part3 is looking at how far away the rotation of the pixel is from the required angle and correcting it. The append is putting the X,Y ( U,V ) back together and then adding the pivot point offset.
thanks man, I think I got the 1 and 2 part but for the 3rd part, dose the dot prodcut give the project length of one vector to another? so…all the U and V will get their length when they dot (sine, cos)?
since we can get rotating results from multiple(sine, cos), (-sine, cos), is there any geometry meaning if we multiple UV and a vector as a X-axis?
Where (x_new, y_new) is the new vector from the center of the rotation and (x, y) is the vector pointing from the center of the rotation to the point you want to rotate. And lets call the center of the rotation (c_x, c_y).
You get (x, y) in part 1
[HR][/HR]
Now in part 2 you get two vectors (you got one from the upper append and one from the lower append)
Then in the last step you again add the origin (center of rotation) to it.
So (x_new, y_new) + (c_x, c_y)
[HR][/HR]
The dot product of two vectors (x, y, z) dot (x_1, y_1, z_1) is just xx_1 + yy_1 + z*z_1 if you use the algebraic definition.
Its a pain to read math formulas in this style here, but I’m too lazy to do it in latex and put the images in =)
yes I think I got that they are equal algebraically but I just wanna know if the method can be explained geometrically, like what is the purpose of a point vector * (sin(phi), cos(phi)) and get x axis
Rotation is just a linear map. That means you have a function T and you input one vector v and want to get the rotated vector u out. So you just do
u = T(v) since T is linear you can write = A*v
If you think back to school there you maybe had a function you called f that maps from X to Y, so y = f(x). And normally X and Y were R, so real numbers in one dimension. Here you have R^2, so two dimensional vector whose entries are real numbers. And here you have a function in two dimensions. And further the function is linear. So in terms of f(x), f(x) = 5 is linear, f(x) = 3x is linear, f(x) = ax is linear, f(x) = x^2 is not linear.
Since this is a linear map you can write Av (or if you like it better you could just name it f(x) = ax instead of T(v) = A*v, just might to lead to some confusion cause then you would use x as vector but you already think of x as the x-coordinate of the vector and you think of “a” as a one dimensional scalar) The * means matrix multiplication. So
AFAIK UE does not have any custom matrices in the material editor, therefore you can do this multiplication manually via dot product but this is just matrix multiplication so just a computation, the sense is in the rotation matrix A that does the mapping.
So v is the vector you put in, you get that one in part 1.
In this case the matrix A is
(cos(phi), -sin(phi)
sin(phi), cos(phi))
And then you just need to do matrix multiplication between those two, so A*v and they’ve done that by making use of dot product.
If you want to know how to get this matrix, that is described here