Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mat4 Projection(float fov, float aspect, float zNear, float zFar) {
- // https://msdn.microsoft.com/en-us/library/windows/desktop/bb205350(v=vs.85).aspx
- float tanHalfFov = tanf(DEG2RAD((fov * 0.5f)));
- float fovY = 1.0f / tanHalfFov; // cot(fov/2)
- float fovX = fovY / aspect; // cot(fov/2) / aspect
- mat4 result; // Creates identity matrix
- result._11 = fovX;
- result._22 = fovY;
- result._33 = zFar / (zFar - zNear); // far / range
- result._34 = 1.0f;
- result._43 = -zNear * result._33; // - near * (far / range)
- result._44 = 0.0f;
- return result;
- }
Add Comment
Please, Sign In to add comment