Sub topic 4
Focal length in millimeters
This chapter assumes you can add a camera, make it the active scene camera and look through it, as covered in the earlier chapters. It also assumes you can open the Properties editor and read short Python snippets. The chapter explains what the Focal Length value in Blender means, how it relates to the sensor, how to set and animate it, and where it commonly goes wrong.
What focal length is
In a real camera, focal length is the distance from the lens to the sensor when the lens is focused at infinity. It is measured in millimeters. A longer focal length magnifies the scene and shows a narrower slice of it. A shorter focal length shows more of the scene, with each object appearing smaller.
Blender has no physical lens, so the number works as a scale factor. It sets how strongly the camera magnifies the scene relative to the size of the sensor. A focal length means nothing on its own. It only describes a view once you know the sensor it is paired with. The default is 50 mm on a 36 mm wide sensor.
Where to set it
Select the camera and open the Object Data tab in the Properties editor. The tab shows a green camera icon. In the Lens panel, the Focal Length field holds the value. In Python, the same value is lens on the camera data, not on the camera object:
import bpy
cam_data = bpy.data.cameras.new("LensDemo")
cam_data.lens = 35 # focal length in mm
print(cam_data.lens)Blender limits the value to a small positive minimum (1 mm). Zero or negative focal lengths are not valid.
The Lens Unit dropdown beside it switches the field between Millimeters and Field of View. Both describe the same lens. If you change the unit, the underlying camera does not change. Only the way the number is displayed changes. The Python property is lens_unit, with the values 'MILLIMETERS' and 'FOV'.
From focal length to field of view
The field of view (FOV) is the angle the camera sees. For a sensor of width w and focal length f, the horizontal FOV is:
FOV = 2 * atan(w / (2 * f))
The next chapter covers this relationship in detail. For now, treat it as a conversion between the number you type and the framing you get.
For a 36 mm sensor, common focal lengths give these horizontal fields of view:
| Focal length | Horizontal FOV | Typical look |
|---|---|---|
| 16 mm | 96.7° | Very wide, strong edge stretching |
| 24 mm | 73.7° | Wide, good for interiors |
| 35 mm | 54.4° | Moderately wide, natural for scenes |
| 50 mm | 39.6° | Normal, close to how people perceive scale |
| 85 mm | 23.9° | Short telephoto, flattering for portraits |
| 135 mm | 15.2° | Telephoto, compressed depth |
| 200 mm | 10.3° | Long telephoto, strong compression |
Doubling the focal length does not halve the angle. The relationship uses an arctangent, so the angle shrinks more slowly at long focal lengths. The change from 16 mm to 24 mm is much larger than the change from 135 mm to 200 mm.
Checking the math in Blender
This script creates a camera data block with a known sensor, then compares your formula with the angle Blender reports. It also sets the angle first and reads back the focal length that results. Run it in Blender's Scripting workspace.
import math
import bpy
cam_data = bpy.data.cameras.new("LensTest")
cam_data.sensor_fit = 'HORIZONTAL' # sensor_width drives the horizontal angle
cam_data.sensor_width = 36 # mm
for focal_length in (24, 50, 85):
cam_data.lens = focal_length
by_formula = math.degrees(2 * math.atan(36 / (2 * focal_length)))
by_blender = math.degrees(cam_data.angle_x)
print(f"{focal_length} mm: formula {by_formula:.1f}, Blender {by_blender:.1f}")
# Work backward: ask for a 60 degree view and read the focal length
cam_data.angle = math.radians(60)
print(f"60 degrees needs {cam_data.lens:.1f} mm")The two columns match. The last line prints about 31.2 mm. Blender stores the focal length and derives the angle from it. Setting angle simply updates lens to the matching value.
How the sensor changes what a focal length means
The same focal length gives different framing on different sensors, because the formula contains the sensor width. A 50 mm lens on a 36 mm sensor sees 39.6° horizontally. On a smaller 24 mm sensor, it sees only 27.0°, a tighter crop.
This is why advice such as "use 85 mm for portraits" assumes a 36 mm wide sensor. If you change sensor_width, the same focal length frames the scene differently. Leave the sensor at 36 mm unless you are matching footage from a specific camera.
The Sensor Fit setting decides which side of the image the sensor width applies to:
- Auto applies the sensor size to the larger side of the render. A landscape render uses it horizontally, and a portrait render uses it vertically.
- Horizontal and Vertical force one direction.
For a 1920 × 1080 render in Auto, the 36 mm applies to the 1920 px side. The vertical field of view then follows from the aspect ratio. In a portrait render such as 1080 × 1920, Auto applies the 36 mm to the 1920 px height, so the horizontal view becomes narrower than you might expect.
Focal length is not distance
Changing focal length changes magnification. It does not move the camera. Moving the camera changes the viewpoint. The two can produce similar sizes for one object but different pictures overall.
Imagine a person standing in front of a building:
- Keep the camera where it is and raise the focal length from 35 mm to 85 mm. The person gets larger in the frame, and the building behind them gets larger by the same factor. The relative sizes stay the same.
- Instead, keep 35 mm and move the camera closer. The person gets larger, but the building behind them grows much less, because it is farther away. The relative sizes change.
So focal length alone does not change perspective, and the camera's position does. In practice the two work together. To keep the person at the same size with a longer lens, you must also move the camera back, and that is what produces the compressed telephoto look. The chapter on wide, normal and telephoto looks follows this up.
Animating focal length
Focal length is a normal animatable property, so you can create a zoom. Hover over the field and press I to insert a keyframe, or use Python:
import bpy
cam_data = bpy.data.cameras.new("ZoomCam")
cam_data.lens = 35
cam_data.keyframe_insert(data_path="lens", frame=1)
cam_data.lens = 85
cam_data.keyframe_insert(data_path="lens", frame=72)The default interpolation is smooth (Bézier), so the zoom eases in and out. Change the F-curve interpolation to linear if you want a constant-speed zoom. A zoom keeps the camera still and changes magnification. A dolly shot moves the camera and changes perspective. They look different on screen, and you should choose the one that matches the shot you want.
Common errors
- Setting
lenson the object. The camera object has nolens. Usecam_obj.data.lens. Writingcam_obj.lensraises anAttributeError. - Changing the focal length of an orthographic camera. An orthographic camera ignores
lens. It usesortho_scaleto control how much it sees. If changing the focal length seems to do nothing, check the camera type. - Scaling the camera object. Scaling the object does not change the field of view. Only the lens and sensor settings do.
- Comparing focal lengths across different sensors. An 85 mm lens on a small sensor does not look like an 85 mm lens on a 36 mm sensor. Compare field of view instead of millimeters.
- Expecting the angle to be vertical. With the default Auto fit, the angle Blender displays in Field of View mode refers to the larger image side. Use
angle_xandangle_yif you need a specific direction. - Ignoring clipping. A very wide lens close to geometry can slice through objects. Check Clip Start and Clip End before assuming the lens is the problem.
Practice
Exercise
A 36 mm wide sensor and a 1920 × 1080 render with Sensor Fit set to Horizontal. You want a horizontal field of view of 60°. What focal length do you set, and what is the formula?
Show answer
Rearrange FOV = 2 atan(w / (2 f)) to f = w / (2 tan(FOV / 2)). With w = 36 and FOV = 60°, f = 36 / (2 tan(30°)) = 36 / 1.1547, which is about 31.2 mm.
Exercise
You change a camera from 50 mm to 100 mm without moving it. Does the horizontal field of view halve from 39.6° to 19.8°? Why or why not?
Show answer
No. The angle comes from an arctangent, so doubling the focal length gives about 20.4° (2 * atan(36 / 200)), a little more than half. The image is magnified by a factor of two at the center, but the angle does not scale linearly.