So, I'm using PerspectiveOffCenterLH (in SharpDX, but that should not matter) to project perspective correct stuff into screen space. Up until last night, it was working well. I could translate on all axes, and I can rotate on the Z axis just fine.
So I added y-axis rotation for giggles and that's when things went all weird. Every time I rotated about the Y-axis, my geometry (a simple quad) gets distorted. Now, I have to admit to being a dumbass when it comes to linear algebra, and it's been a very long time since I've had to deal with a projection matrix directly, so it could be that I'm using the wrong tool for the job due to my ignorance.
Basically it looks like the vertices on each side stretch off into the distance (more and more as I rotate):
I'd like to note that I have another app, where I'm using PerspectiveFovLH, and that's working just fine. So again, this very well could be a case of "the wrong tool for the job".
Here's the code I'm using to build up my stuff:
// Matrix construction code. Anchor is 0, 0 for now, so we can ignore it.
// ViewDimensions is the width and height of the render target.
var anchor = DX.Vector2.Zero;
DX.Matrix.PerspectiveOffCenterLH(-anchor.X,
ViewDimensions.Width - anchor.X,
ViewDimensions.Height - anchor.Y,
-anchor.Y,
MinimumDepth,
MaximumDepth,
out ProjectionMatrix);
// This is my code for combining my view + projection
DX.Matrix.Multiply(ref ViewMatrix, ref ProjectionMatrix, out ViewProjectionMatrix);
// And this is my code for building the view.
DX.Matrix translation = DX.Matrix.Identity;
DX.Matrix.RotationYawPitchRoll(_yaw.ToRadians(), 0, _roll.ToRadians(), out DX.Matrix rotation);
// NOTE: This doesn't work either.
//DX.Matrix.RotateY(_yaw.ToRadians());
DX.Matrix.Multiply(ref rotation, ref translation, out ViewMatrix);
// My code in the vertex shader is pretty simple:
Vertex output = input;
output.position = mul(ViewProjection, output.position);
return output;
The order of operations is indeed correct. It works just fine when I don't rotate on the Y (or X - but that's not important for today) axis.
So, yeah, can someone tell me if I'm dumb and using the wrong projection matrix type? And if I can, an explanation for it would be much appreciated to so I don't make this mistake again (don't go too math crazy, I'm old and my math skills are worse than ever - talk to me like I'm 5).