For my 2D framework im using ortho matrices in the vertex shader to project my coordinates. Now when im using OrthOffCenterLH something is not really going as it should.
Method 1:
void VertexMain(in VertexShaderInput vsInput, out PixelShaderInput output)
{
output = (PixelShaderInput)0;
float4 posTransformed = mul(float4(vsInput.position, 1), transformMatrix);
float xbase = -viewportSize.x / 2.0f;
float ybase = viewportSize.y / 2.0f;
posTransformed.x += xbase;
posTransformed.y = ybase - posTransformed.y;
output.position = mul(posTransformed, orthoProjMatrix);
output.texCoord = vsInput.texCoord;
output.color = vsInput.color;
}
And:
mScreenMatrix = Matrix.OrthoLH(mViewport.Width, mViewport.Height, 0, 1);
Everything is fine, the UI is at its correct place (except if transformMatrix is not Matrix.Identity, then its not on the screen...)
Method 2:
void VertexMain(in VertexShaderInput vsInput, out PixelShaderInput output)
{
output = (PixelShaderInput)0;
float4 posTransformed = mul(float4(vsInput.position, 1), transformMatrix);
output.position = mul(posTransformed, orthoProjMatrix);
output.texCoord = vsInput.texCoord;
output.color = vsInput.color;
}
And:
mScreenMatrix = Matrix.OrthoOffCenterLH(0, mViewport.Width, mViewport.Height, 0, 0, 1);
Well, i cannot describe it, so ill post a picture:
What is going on there? Isnt that supposed to be an offseted version of OrthoLH? Somehow it looks like a very weird perspectivic transformation...
Thank you for your advise!
Cromon