1
\$\begingroup\$

Preamble:

I noticed the FOV in Unity is only correct when the screen resolution is square, in other words when the width of the screen is the same as the height.

When you add more width to the screen, the camera shows a greater FOV sideways. (The FOV remains the same up and down.)

To see this is true, set the resolution to be square, set the FOV to be 90, and go into a corner and look out and compare the positions of both walls: They will match the sides of the screen.

So even 4:3 screens show more FOV. 16:9 shows way more. I am not sure of the math to determine how much.

Question:

I wonder what aspect ratio shows a FOV of 90 (sideways) when it is set to the default 60? Does anyone know the math?

\$\endgroup\$
  • 2
    \$\begingroup\$ "Only correct when the screen resolution is square" is a funny way to say it's measured vertically. ;) The number is always correct, it's just not the number you were expecting. You can check these assumptions by consulting the documentation, which specifies that it's a vertical field of view. \$\endgroup\$ – DMGregory Feb 7 '17 at 4:29
  • \$\begingroup\$ Yeah, I changed my point of view half way through writing that! Haha \$\endgroup\$ – Xonatron Feb 8 '17 at 2:30
3
\$\begingroup\$

Assuming Unity3D does not add further scaling on your platform (TV safe zone) 16:9 gives a little bit above 90 degrees wide (91.49284452 degrees) when set to 60 vertical.

The formula is:

float f = Mathf.Tan(Mathf.Deg2Rad(fov_y / 2.0f));

fov_x = Mathf.Rad2Deg(Mathf.Atan(f * aspect_ratio)) * 2.0f;

To find the exact ratio that will give you 90 degrees horizontal with 60 degrees vertical:

float ratio = Mathf.Tan(Mathf.Deg2Rad(90/2.0f)) / Mathf.Tan(Mathf.Deg2Rad(60/2.0f));

or 1.732050808:1 or 15.588457268:9

\$\endgroup\$
  • \$\begingroup\$ Wow, thanks. Very well done. I did not verify your work but I am trusting it for now. \$\endgroup\$ – Xonatron Feb 8 '17 at 2:31
  • 1
    \$\begingroup\$ If it helps, I verified the work. ;) It's solid, you can trust it. If you want to check it yourself though, imagine a cross-section through the view frustum 1 unit away from the camera. The half-height of this rectangle above the camera's center ray is tan(fov.y/2) (opposite over adjacent). The rectangle extends to the right of this point by an amount equal to the aspect ratio times this half-height. Which means it forms a triangle in the camera's horizontal plane with an angle at the camera of atan(aspect * tan(fov.y/2)), which is half the horizontal fov, so we double it for the final answer. \$\endgroup\$ – DMGregory Feb 8 '17 at 2:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.