twn_camera: fix aspect of ortho projection

This commit is contained in:
veclavtalica
2025-03-07 11:07:05 +03:00
parent 67feb5974a
commit a03e1d885d
3 changed files with 11 additions and 14 deletions

View File

@ -59,15 +59,15 @@ Matrix4 camera_orthographic(const Camera *const camera) {
Matrix4 result = {0};
const float rl = 1.0f / (camera->viewbox[0].y - camera->viewbox[0].x);
const float tb = 1.0f / (camera->viewbox[1].x - camera->viewbox[1].y);
const float rl = 1.0f / (camera->viewbox.y - camera->viewbox.x);
const float tb = 1.0f / (camera->viewbox.z - camera->viewbox.w);
const float fn = -1.0f / (camera->far_z - -camera->far_z);
result.row[0].x = 2.0f * rl;
result.row[1].y = 2.0f * tb;
result.row[2].z = 2.0f * fn;
result.row[3].x = -(camera->viewbox[0].y + camera->viewbox[0].x) * rl;
result.row[3].y = -(camera->viewbox[1].x + camera->viewbox[1].y) * tb;
result.row[3].x = -(camera->viewbox.y + camera->viewbox.x) * rl;
result.row[3].y = -(camera->viewbox.z + camera->viewbox.w) * tb;
result.row[3].z = (camera->far_z + -camera->far_z) * fn;
result.row[3].w = 1.0f;