[DX11]Shader multiplications

Started by
3 comments, last by Jason Z 12 years, 8 months ago
Hello!

I resently "developed" a problem, no idea how or how to solve it.

The thing is, when i rotate a model in the X axis, it rotates the Y axis,and the Y rotates the X axis.
To solve the problem i started to mess around with the vertex shader to find a solution.. with out any Luck!

My question is now, is this correct? (psudo code)

1 : Set my ViewProjection to the shader as a TRANPOSED matrix.
2 : calculate World * ViewProjection
3 : calculate VertexPos * (World*Viewprojection)


That is the way i have been doing it befor and it workt perfect by then.
any helps would be nice! cheers!
"There will be major features. none to be thought of yet"
Advertisement
Give the ObjectTransformationMatrix, ViewMatrix and ProjectionMatrix to the shader.
Multiply from object space to screen space in the vertex shader and give all 4 types of vertex position to the pixel shader.
ObjectSpace -> WorldSpace -> CameraSpace -> ScreenSpace

If you try to optimize by making one matrix on the CPU, you will sooner or later have to split it to support more advanced materials.

Each object should store:
Normalized orthogonal 3x3 matrix for fast rotation.
X,Y,Z scaling vector for setting the size.
X,Y,Z translation vector for moving.

Multiply the object's normalized orthogonal 3x3 matrix with a rotation matrix, orthogonalize to remove rounding errors and let the compiler optimize the multiplications with 0 and 1.
http://en.wikipedia....Rotation_matrix

Scale object's normalized orthogonal 3x3 matrix with the scaling vector and insert it to a 4x4 matrix together with the translation vector to create the final ObjectTransformationMatrix that you can give to your shader.
well, most of the stuff you said i do understand.

what i dont understand isent why my matrix calulation wont work :

(World * View * Projection) * localpos;
"There will be major features. none to be thought of yet"
If you are applying the multiplication in screen space, it will rotate in screen space. Only apply rotations to the matrix that convert object space to world space.
How are you calculating your world transformation? If you think about it, the world matrix is simply a mapping from one space to another, so if it is being done incorrectly then there are really only two possible reasons why - 1. the mapping calculated is wrong or 2. the two spaces are related in the way that you think they are.

I'm pretty sure that it is either the calculation is incorrect, or possibly that the arguments on your matrix multiplication should be flipped - i.e. mul(vector, matrix) should be mul(matrix, vector) or vice versa. Are you able to post the relevant code snippets?

This topic is closed to new replies.

Advertisement