- Home /
Incorrect Unity Camera Horizontal/Vertical FOV conversions
Using Version 2020.1.4f1, Camera.HorizontalToVerticalFieldOfView and Camera.VerticalToHorizontalFieldOfView seem to be returning incorrect values, and I am seeing matching incorrect values when changing the camera 'FOV Axis' option in the editor between Horizontal and Vertical. Attempting to accurately set FOV through scripts is broken by this.
Is there something I'm missing or a way to correct for this behaviour?
In the watch frame attached, at a 16:9 aspect ratio a Horizontal FOV of 50 should convert to a Vertical FOV of 28.125, however the Camera helper function doesn't match the result.
Answer by Namey5 · Sep 10, 2020 at 10:28 PM
Simply scaling the FOV angle by the aspect ratio isn't correct; you need to use tan() to find the ratio of the screen lengths, scale that, then convert back into an angle;
float VerticalToHorizontalFOV (float a_VerticalFOV, float a_Aspect)
{
return Mathf.Atan (Mathf.Tan (a_VerticalFOV * 0.5f) * a_Aspect) * 2f;
}
Your answer
Follow this Question
Related Questions
How to render part of FOV? 1 Answer
Zooming camera using move z position. 0 Answers
3D. How to get 1 pixel to equal 1 degree camera FOV 0 Answers
Fov affect performance in an unexpected way 0 Answers
FOV bugged, i think 0 Answers