float4 VertexShader_Tutorial_1(float4 inPos : POSITION ) : POSITION
{
return mul(inPos, WorldViewProj );
};
float4 VertexShader_Tutorial_1(float4 inPos : POSITION ) : POSITION
{
return mul(inPos, WorldViewProj );
};
Do they not follow the row / column rules of the dot product and in effect transpose the vector or matrix?
In HLSL the transfromation of a vector, when you multiply a matrix and a vector, the vector itself si not disinguised wheather it is a column vector 1xn or nx1. Technicaly when you multiply a vector and matrix, the switched order between them algebraisticly relates to A*b=A*b and b*A=AT*b. By switching order you transpose the transfrormation.
If i understand correctly, the transpose is a result of treating the vector as a column vector; hence the matrix is never actually transposed. Is that correct?I have one more question regarding pre / post multiplication. I always assumed that the whole row v column order was what determined if pre or post multiplication is used (Due largely to my understanding of linear algebra being based on the differences in OpenGL & Direct X).Now that i'm trying to build some more solid mathematical foundations i find my old understanding very chalenged.If we have Matrix T (a translation matrix that translates by 10, 20 and 30)and matrix S (A scale matrix that is a uniform scale of two)And we want to concatinate the transformation so that the matrix translates first, and scales second we must calculate it as S x T.This is assuming the same multiplication method as in the first post. I think because we scaled first then translated this is using post multiplication?If correct, how come post multiplying two row major matrices works in math but Direct 3D uses pre-multiplication? Is this due to some implicit like the vector X matrix multiplication? Am i missing something trivial in my mental model of how this works?Or perhaps is my pre / post terminology wrong when it comes to multiplying matrices?
Yes, that's correct that matrix itself does not transform, only the resulting vector is transformed as by transponed matrix. The multipliction of matricies itself does reflect the actual multiply order as for the resulting transformation that is A(B(v))=B*A*v but HLSL and GLSL, though having the same technical multiply operator, can differ on picking wheather row-up way or colum-up way to pick columns to multiply the pre/post vector with. If they differ, what I do not know becouse I haven't used HLSL for ages, then in GLSL you might have (A(B(v)))=B*A*v and in HLSL (A(B(v)))=v*B*A.
That's very helpful.
If i understand what you said correctly, if two matrices (A and B) together; to find element 2,3 of the resulting matrix
Row major multiplication: take the dot product row 2 of matrix A and column 3 of matrix B
Column major multiplication: take the dot product of column 2 of matrix A, and row 3 of matrix B
----------------------------------------
So, last question (i hope). Does the above mean that the formula for matrix product (For matrices F & G):
This will always take dot product the i-th row and j-th column of the two matrices, the only difference being that row major = FG, while column major = GF
OR, do the subscripts get a different meaning? Like in row major it's the i-th row and j-th column, where with column major it's the j-th row and i-th column?
matricies multiplication is consistent in algebraic sence, it does not make any big point to think wheather they are row or column multilpied, since the vector transformation can be transpone, so that in case the matrix multiplication is first case, you have row matricies, or column matricies in second, but this affect only transpone character of transformed vectors, so you can decide wheather you use v*M or M*v to synchronize with any of cases of algebraic columns in matricies, what stems from the way you multiply them.
If you have column matricies, meaning you transform a vector by doting rows with the vector (adding columns multiplied by scalar from vector), you should use column dot row when multiiplying the matricies. If you use the row-dot-column, just transform the vector by adding rows then, to keep in tact the algebraic intent.