I want to draw a cube. This is what i currently have:
As you can see, the perspective is VERY wrong. The the size in the z-direction is too small and the difference between the front and back size is wrong.
My code:
worldprojMatrix = Matrix.Identity;
worldprojMatrix *= Matrix.Translation(0, 0, 10);
//float ratio = ScreenWidth/ScreenHeight;
worldprojMatrix *= Matrix.PerspectiveFovLH(1f, ratio, 1f, 100f);
//worldprojMatrix *= Matrix.RotationY(1.3f);
worldprojMatrix.Transpose();
//update the matrix with a constant buffer
DeviceContext.UpdateSubresource(ref worldprojMatrix, worldprojBuffer);
Vertex Shader:
struct VOut
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
cbuffer meshBuffer : register(b1)
{
float4x4 worldprojMatrix;
}
VOut VShader(float4 position : POSITION, float4 color : COLOR)
{
VOut output;
output.position = mul(position, worldprojMatrix);
output.color = color;
return output;
}
I tried an ortho perspective, but there is the same problem: the z dimension is too small.
How can i fix that?