I'm playing with a camera in Unity where I change it's properties via a script. One of the property change is the Camera.fieldOfView. This property is dependant on the Focal length and the sensor size.
For a fixed focal length, I compute the sensor size for a desired field of view. When I assign the sensor size and focal length, the field of view computed by Unity doesn't match the expected one.
My calculation are similar to these ones and seems correct.
Does Unity use another model for its camera than the Pinholde model? Where could the discrepencies come from?
Had I read the documentation carefully, I would have known that
Camera.fieldOfViewis defined as:My computation were for the horizontal field of view and I didn't realized that I was assigning to the vertical field of view of the camera. The field of view displayed was therefore consistently off by a factor equal to the sensor aspect ratio.
In Unity, you need to adjust both the camera's
fieldOfViewandaspectto adjust the horizontal field of view