I have a texture, some 2D vertices, and a matrix. The matrix is used to calculate the texture coordinates for each vertex, but the problem is that the matrix comes with absolutely no documentation and I'm having trouble working out how to calculate the texture coords correctly. I have it partially working.
The matrix is in this format:
sx rx tx
ry sy ty
Where s
means "scale", r
means "rotate", and t
means "translate".
If the matrix doesn't contain any rotation (i.e. ry = rx = 0
), I can correctly calculate the texture coordinates u
and v
like this:
u = x/sx - tx
v = y/sy - ty
But I can't figure out how to put rx
and ry
into the equation and get the correct results. Normal matrix multiplication involves multiplying and adding but this one involves dividing and subtracting, so I know I'm missing something but I don't know what it is.
Here is one of the matrices with rotation:
26.191574096679688 7.0180206298828125 1579
-7.0180206298828125 26.191574096679688 1879
Here is one of the matrices without rotation:
27.115478515625 0 1867
0 27.115478515625 800
0, 0, 1
I guess. \$\endgroup\$