Sub topic 5
How focal length and sensor size set the field of view
This chapter assumes you can add a camera, make it the active camera, and look through it with Numpad 0. It also assumes you can edit values in the Camera data properties tab. The earlier chapters on the camera object and focal length cover those steps. The scripts need only basic Python.
What the field of view is
The field of view (FOV) is the angle of the scene that the camera records. A large angle shows a lot of the scene, and everything in it looks small. A small angle shows a narrow slice, and everything in it looks large.
Blender gives you two inputs that set this angle:
- Focal length (
lens), in millimeters. It is the distance from the lens to the sensor when the lens is focused at infinity. - Sensor size (
sensor_width,sensor_height), in millimeters. It is the physical size of the imaging area.
Nothing else about the camera object changes the angle. Moving the camera changes the viewpoint. Changing the angle changes how much of the scene fits in the frame from that viewpoint.
The formula
The field of view across one sensor dimension is:
fov = 2 * atan(sensor_size / (2 * focal_length))The angle depends on the ratio of sensor size to focal length. If you double both, the angle stays the same. If you double only the focal length, the angle gets smaller, though not exactly by half, because of the arctangent.
import math
sensor_width = 36 # mm
for focal_length in (24, 50, 85):
fov = 2 * math.atan(sensor_width / (2 * focal_length))
print(f"{focal_length} mm -> {math.degrees(fov):.1f} degrees")This prints 73.7, 39.6 and 23.9 degrees. Going from 24 mm to 85 mm is a factor of about 3.5 in focal length. The angle falls by a factor of about 3.1.
Sensor size and the crop effect
The default Blender camera has a 36 mm wide sensor, which matches a full-frame photographic sensor. The same 50 mm lens on a smaller sensor sees a narrower angle, because the sensor captures only the middle of the image the lens projects.
| Sensor width | Focal length | Horizontal FOV |
|---|---|---|
| 36 mm (full frame) | 50 mm | 39.6 degrees |
| 23.5 mm (APS-C) | 50 mm | 26.4 degrees |
| 23.5 mm (APS-C) | 32.6 mm | 39.6 degrees |
The last row shows why photographers quote an "equivalent focal length". To match the full-frame 50 mm view on a 23.5 mm sensor, scale the focal length by 23.5 / 36, which gives 32.6 mm.
This matters in Blender when you copy a real camera's specification. A focal length alone is meaningless without the sensor width. If you are matching footage, enter both values. If you are not matching anything, leave the sensor at 36 mm. Then your focal lengths mean what photographers expect.
Sensor fit: which dimension the sensor width applies to
A sensor has a width and a height, but the formula uses one dimension at a time. The Sensor Fit setting decides how Blender picks it. Each option is a value of sensor_fit:
- Auto (
'AUTO'):sensor_widthapplies to the larger of the render width and height. The other dimension follows from the aspect ratio. This is the default. - Horizontal (
'HORIZONTAL'):sensor_widthalways applies to the image width. - Vertical (
'VERTICAL'):sensor_heightapplies to the image height.
In Auto, the sensor_height property is ignored. This is a common source of confusion when someone edits the height and nothing changes.
For a 1920 x 1080 render in Auto, the effective sensor is 36 mm wide and 36 x 1080 / 1920 = 20.25 mm tall. With a 50 mm lens, that gives a horizontal angle of 39.6 degrees and a vertical angle of 2 * atan(20.25 / 100), which is 22.9 degrees.
Because the larger dimension gets the sensor width, rotating the frame to portrait (1080 x 1920) keeps the same angle on the long side. The angle then runs vertically, and the horizontal angle becomes 22.9 degrees. The camera does not zoom, but what counts as "wide" changes with the frame shape.
Resolution settings also interact with FOV in a simple way. Changing the resolution from 1920 x 1080 to 1920 x 800 in Auto keeps the horizontal angle at 39.6 degrees. The vertical angle shrinks, so the image gets cropped top and bottom. The overall pixel count does not matter. Only the aspect ratio does. The resolution percentage has no effect on the angle at all.
Checking the numbers with bpy
The camera data exposes the computed angles as read-only properties: angle_x, angle_y, and angle (the angle along the fitted dimension). They are in radians. This script compares them against the formula for a landscape frame:
import bpy
import math
scene = bpy.context.scene
scene.render.resolution_x = 1920
scene.render.resolution_y = 1080
cam = bpy.data.cameras.new("FovTest")
cam.sensor_fit = 'AUTO'
cam.sensor_width = 36
for lens in (24, 50, 85):
cam.lens = lens
expected = 2 * math.atan(cam.sensor_width / (2 * lens))
print(
f"{lens} mm: Blender {math.degrees(cam.angle_x):.1f}, "
f"formula {math.degrees(expected):.1f}, "
f"vertical {math.degrees(cam.angle_y):.1f}"
)
bpy.data.cameras.remove(cam)The first two columns agree. The vertical angle comes from the aspect ratio, as described above.
Setting the angle directly
The Lens panel has a Focal Length field and a Field of View option. In the Lens panel, the unit dropdown switches the field between millimeters and degrees. The Python property for that choice is lens_unit, with values 'MILLIMETERS' and 'FOV'. The two are the same setting shown in different units. Setting cam.angle in a script changes lens to match, using the current sensor width and fit.
import bpy
import math
cam = bpy.data.cameras.new("AngleCam")
cam.sensor_fit = 'HORIZONTAL'
cam.sensor_width = 36
cam.angle = math.radians(60)
print(f"lens is now {cam.lens:.1f} mm")
bpy.data.cameras.remove(cam)A 60 degree horizontal angle on a 36 mm sensor corresponds to about 31.2 mm. Working in degrees is useful when a director or client specifies the view angle, or when you want to match a specific width of the scene from a fixed distance.
Common mistakes
- Changing sensor height in Auto fit. Nothing happens, because Auto uses only the width. Switch to Vertical fit if you want the height to matter.
- Quoting a focal length without a sensor. "A 35 mm lens" gives different views on different sensors. Record both numbers.
- Expecting resolution to change the view. Pixel count changes sharpness and render time. The aspect ratio changes the crop. The angle in the fitted dimension stays put.
- Zooming by moving the camera instead of changing the lens, or the reverse. Changing the focal length changes the angle but not the perspective. Moving the camera changes the perspective. The next chapter covers that difference.
- Reading the angle in the wrong dimension.
anglefollows the sensor fit. Useangle_xandangle_ywhen you need a specific direction.
Summary of the working model
- The lens and the sensor together define a pyramid of visible space.
- The angle at the tip of that pyramid is the field of view. It equals 2 atan(sensor / (2 focal length)).
- Sensor Fit and the render aspect ratio decide which sensor dimension is the horizontal one.
- Blender reports the result as
angle_xandangle_y, and you can set it throughangle.
Exercise
A camera has a 36 mm sensor width, Auto sensor fit, and a render size of 1920 x 1080. What is its horizontal field of view at a focal length of 35 mm, and which focal length would give the same horizontal angle on a 23.5 mm sensor?
Show answer
The horizontal angle is 2 atan(36 / 70) = 2 27.2 degrees, about 54.4 degrees. On a 23.5 mm sensor the same angle needs 35 * 23.5 / 36 = 22.8 mm.
Exercise
You change the render resolution from 1920 x 1080 to 1080 x 1920 with Auto sensor fit, a 36 mm sensor width and a 50 mm lens. What are the horizontal and vertical angles afterward?
Show answer
In Auto fit the sensor width applies to the larger dimension, which is now the vertical one. The vertical angle is 39.6 degrees. The horizontal angle uses a sensor size of 36 1080 / 1920 = 20.25 mm, so it is 2 atan(20.25 / 100), about 22.9 degrees.