# Which perspective projection matrix to use

Computer Graphics Asked by Nixcc on August 27, 2021

I’ve seen two different perspective projection matrices being used but I want to know which one of them is the best. I think that they both output the same but I’m not sure. So if anyone can help me select which one to use I would greatly appreciate it

Even though you can find multiple slightly different formulations for the perspective matrix on the internet, they all do more or less the same thing. They project everything inside a space with the shape of a truncated pyramid (your view frustum) into a space with the shape of a quad and a defined value range (clip space).

Most differences are related to how you define the shape of your frustum. For example, your first matrix uses a height, a width, and an angle together with z-far and z-near value. The second one uses just an x- and y-FOV and the z-far and z-near values to describe the shape of the frustum. This explains the differences in the upper left section.

So what about the lower right section? One big issue here is, that you can choose to use column or row vectors for your vertices/points. Column vectors are multiplied on the right-hand side and row vectors on the left-hand side. The choice you make determines if you have to transpose (switch columns and rows) your matrix or not. The matrices you presented are just targetting different vector representations. I can't tell you without testing/rereading which one is meant for which representation, but if you transpose one of them, they start looking quite similar.

There are still some other minor differences like varying signs, different factors, or a missing addition. The derivation of your second matrix can be found here. I can't tell you exactly where those small differences in the first matrix come from, but you can find some possible explanations in this link (Have a look into the "Are There Different Ways of Building this Matrix?" section). Another good read is this link here.

Which matrix is "correct" depends on how your Graphic API defines its coordinate systems and it's clip space (For OpenGL - you can take the one from the last link I provided). However, there is no "best" choice because they all do more or less the same. Unless you have no special needs for your program (depth precision) or other fancy ideas I can't think of now, just pick the one suited for your API with the inputs (FOV vs width+height+angle) that you like most and start having fun. ;)

Correct answer by wychmaster on August 27, 2021

## Related Questions

### Is there an algorithm to bold an outline font?

2  Asked on December 23, 2021

### alternative to spherical harmonics to model radiance aproximation, optimized for real-time evaluation

0  Asked on December 14, 2021

### Transfer the texture between two different sets of uv

1  Asked on December 9, 2021

### How to retrieve data from Compute Shader to CPU?

0  Asked on November 15, 2021 by ethan-ma

### unwanted patterns in simplex noise

1  Asked on November 13, 2021 by sam-apostel

### Procedural generation of biological models

1  Asked on November 13, 2021 by daniel-cooke

### What method is used for baking grayscale curvature maps

1  Asked on November 10, 2021 by jummit

### Why are texture coordinates often called UVs?

2  Asked on August 27, 2021 by samanthaj

### Dynamic Ray-Triangle Intersection

1  Asked on August 27, 2021 by cemklkn

### Reducing artificial rings in mean curvature of mesh

1  Asked on August 27, 2021

### Fast and exact Geodesics on meshes, Backtracking confusion

1  Asked on August 27, 2021

### How to scale signed distance field fonts properly?

1  Asked on August 27, 2021 by endanke

### The ploygon width parallel to the x axis as a function of the y ordonate?

0  Asked on August 27, 2021 by hafid-boukhoulda

### Find the formulas of the middle point algorithm for drawing the parabola?

0  Asked on August 27, 2021 by mrjab

### Crystal ball rotation – I don’t get why the code works

0  Asked on August 27, 2021 by user13665

### Draw Line on Arbitrary Surface

0  Asked on August 27, 2021 by valentin-molina

### How to raytrace Bezier surfaces?

5  Asked on August 27, 2021 by luser-droog