This time I'm trying to learn the core of matrix transformations. I dont like the idea to using a Math library and dont understand what is hapening on background, because this I'm having some dificulties with Projection Matrix. I've read many tutorials that explain how Projection Matrices show be and what they do. But at this moment I got two different Projection Matrices and I dont know which should I use.
Look at this, frist from this tutorial:
private float near = 0.1f;
private float far = 100.0f;
private float fov = (float)Math.toRadians(45.0);
private float aspect = (float) 400 / (float) 300;
private float f = (float)Math.tan(fov / 2.0f) * near;
private float Sx = (2.0f * near) / (f * aspect + f * aspect);
private float Sy = near / f;
private float Sz = -(far + near) / (far - near);
private float Pz = -(2.0f * far * near) / (far - near);
projection = new Matrix4f(new float[]{
Sx, 0.0f, 0.0f, 0.0f,
0.0f, Sy, 0.0f, 0.0f,
0.0f, 0.0f, Sz, -1.0f,
0.0f, 0.f, Pz, 0.0f,
});
Now look this second, from this tutorial:
private float near = 0.1f;
private float far = 100.0f;
private float fov = (float)Math.toRadians(45.0);
private float aspect = (float) 400 / (float) 300;
private float f = 1.0f / (float)Math.tan(fov / 2.0f);
private float Sx = f / aspect;
private float Sy = f;
private float Sz = -(far+near) / (far-near);
private float Pz = -(2.0f * near * far) / (far – near);
projection = new Matrix4f(new float[]{
Sx, 0.0f, 0.0f, 0.0f,
0.0f, Sy, 0.0f, 0.0f,
0.0f, 0.0f, Sz, -1.0f,
0.0f, 0.f, Pz, 0.0f,
});
So, which is correct? Or if both are correct, there is some recommendations? I think the second one is more easy to read.
P.S.: In my code i'm using Right Handed System and Column-Major Matrices.
Thanks for your attention!