New answers tagged matrix
This question already has been answered. See the second link here: http://stackoverflow.com/questions/12794428/calculating-world-space-coordinates-in-the-pixel-shader
Okay so, finally achieved my goal. view = Matrix.CreateScale(new Vector3(1, 0.75f, 1)) * Matrix.CreateTranslation(-playerpos.X, -playerpos.Y, 1); world = Matrix.Invert(view); projection = Matrix.CreateOrthographicOffCenter(0, view.Width, view.Height, 0, -1, 1); Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0); projection = halfPixelOffset ...
If your transformation matrix is a rotation matrix then you can simplify the problem by taking advantage of the fact that the inverse of a rotation matrix is the transpose of that matrix. If your transformation matrix represents a rotation followed by a translation, then treat the components separately. The inverse is equivalent to subtracting the ...
So long as the matrix M is invertible (which it generally will be, unless you're doing something very unusual), then computing the matrix inverse of M will give you a matrix that does what you want. That is, if M performs some transformation, inverse(M) performs the "opposite" transformation. Most matrix/vector libraries provide a means for computing the ...
In your matrix lib there is probably a function called inverse. That is probably what you are looking for.
The transformation Matrix to transform from the space on the left to the space on the right is [1 0 0 1 ] [0 1 0 -1.5] [0 0 1 0 ] [0 0 0 1 ] Well this is not correct, the matrix you have shown is actually to transform any point from the space on the right to the space on the left. The correct matrix to transform from the ...
Is it because the eye-at = (0,2,0) and therefore the cross product of up x (eye-at) = (0,0,0) and that means, that no real transformation matrix can be constructed? Exactly, the actual values in the resulting matrix is just the coordinates of the view direction (at-eye), up and right vectors next to each other; result = [[right.x up.x view.x] ...
World position is vertex position multiplied by world matrix, not view matrix. So it should be like this in the vertex shader: output.WorldPos = mul(input.Pos,World); Unless you want View position to work with. I haven't checked the code for bugs if you want to use that.
So, it seems that the light vector wasn't in the camera space.... so, be sure to transform lights into the camera space prior to sending to the shader
Top 50 recent answers are included