The rest of the day was spent in getting the camera and the projection matrix working.

Something you should look out for when using a vertex shader to transform vertices: When the matrix is stored in the constant registers, by default each register represents a

**column**of the matrix, not a row. This is called "column-major", and makes sense from an optimization point of view; if you are using row vectors, then the columns of the matrices will need to be accessed to perform transformations, and the rows will rarely be directly accessed (one exception would be in matrix multiplication). You can account for this by transposing your matrices before you place them in the registers.

To make the code more readable (and easier to write), I have created four specialized derivations of the generic matrix: RotateX, RotateY, RotateZ, and Translate. The names are pretty self-explanatory; RotateX represents a rotation about the x-axis, etc. and Translate represents a translation. This allows me to create a rotation or translation matrix by providing only a single argument (an angle or a vector, depending on the matrix).

On the subject of matrices, I have decided to use mOut = Transpose(mIn); rather than mOut = mIn.Transpose(); The latter implies that the matrix being transposed is being altered, which isn't the case (a copy of it is created and transposed). I don't much like mOut = Multiply(mL, mR); though, as this is a bit too messy in my opinion. For multiplication and similar operations, I have decided to use this format: mOut = mL*mR;

## No comments:

## Post a Comment