I need the formula to create a orthographic projection matrix. I am using GLM math libary and DirectX11. The reason I cannot use GLM to create it is because the NDC spaces are different between DX11 and OpenGL, thus I need to manually create one.
I am however using right-handed coordinate system and column-major matrices, just like GLM.
This is my attempt, but I get wrongly images when rendering with it, so it is probably wrong. I am using it for cascading shadow maps, and from the graphics debugger, I probably need to mirror it, but it is just a guess. Any ideas?
Mat4 OrthographicMatrix(const float left, const float right, const float top, const float bottom, const float zNear, const float zFar)
{
Mat4 ret(1.0f);
ret[0][0] = 2.0f / (right - left);
ret[1][1] = 2.0f / (top - bottom);
ret[2][2] = 1.0f / (zNear - zFar);
ret[3][0] = (left + right) / (left - right);
ret[3][1] = (top + bottom) / (bottom - top);
ret[3][2] = (zNear) / (zNear - zFar);
return ret;
}