Sub topic 3
Sensor Size and Sensor Fit
This chapter assumes you can add a camera and view through it, and that you know the Properties editor. It also assumes you have met the field-of-view formula from the earlier chapter on camera data. The Python examples are optional reading.
A Blender camera simulates a real one. Light passes through a lens and lands on a rectangular sensor. Two numbers describe that rectangle: its physical size in millimeters, and the rule Blender uses to match it to your render's aspect ratio. This chapter covers both, because they decide how much of the scene fits in the frame before you touch the focal length.
Why the sensor matters
Field of view depends on two inputs: focal length and the sensor dimension it is measured against. For a sensor dimension s and focal length f:
FOV = 2 * atan(s / (2 * f))If you double s, you get the same view as halving f. The sensor size therefore acts as a calibration for the lens. A 50 mm lens on a large sensor looks wide, and the same 50 mm lens on a small sensor looks tighter.
Blender's defaults are a sensor 36 mm wide and 24 mm tall. This matches a full-frame 35 mm still camera, which is why 50 mm reads as a "normal" lens in Blender.
Blender stores the sensor on the camera data, not on the object:
sensor_width: sensor width in mm (default 36).sensor_height: sensor height in mm (default 24).sensor_fit: which dimension the sensor size is applied to ('AUTO','HORIZONTAL', or'VERTICAL').
Matching a real camera
When you match footage from a real camera, set the sensor to that camera's physical size. Then the real lens's focal length gives the same field of view in Blender. These sizes are approximate and vary by manufacturer:
| Sensor format | Width (mm) | Height (mm) |
|---|---|---|
| Full frame (Blender default) | 36 | 24 |
| APS-C (typical) | 23.5 | 15.6 |
| Micro Four Thirds | 17.3 | 13 |
Look up the exact dimensions in the camera's specification sheet. If you match footage for tracking, a wrong sensor width gives a wrong field of view for the same focal length, and the CG will not line up with the plate.
What sensor fit does
A render is rarely the same shape as a 36 × 24 sensor. A 1920 × 1080 frame has a 16:9 ratio, and the sensor has 3:2. Blender must decide how the sensor rectangle maps onto your image. That decision is the sensor fit.
| Fit | Dimension used | Behavior |
|---|---|---|
| Auto | `sensor_width` | The value is applied to the larger side of the image. Landscape images use it horizontally. Portrait images use it vertically. |
| Horizontal | `sensor_width` | The value is always the image width. |
| Vertical | `sensor_height` | The value is always the image height. |
In the Properties editor, the Camera tab shows a single Size field in Auto mode, Width in Horizontal mode, and Height in Vertical mode. The field you see is the one Blender is using.
The key point is that only one sensor dimension is active at a time. The other dimension is derived from your resolution. For a 1920 × 1080 render in Auto or Horizontal fit, the effective sensor is 36 mm wide and 36 * 1080 / 1920 = 20.25 mm tall. The sensor_height property is ignored.
Worked example: landscape versus portrait
Take a 50 mm lens and the default 36 mm sensor width, in Auto fit.
- Landscape 1920 × 1080: the 36 mm spans the width. Horizontal FOV is
2 * atan(36 / 100), about 39.6°. The effective sensor height is 20.25 mm, so vertical FOV is2 * atan(20.25 / 100), about 22.9°. - Portrait 1080 × 1920: the 36 mm now spans the height. Vertical FOV is 39.6° and horizontal FOV is 22.9°.
So in Auto fit, rotating the frame from landscape to portrait rotates the view with it. The long side of the image always gets the 39.6° span. The focal length did not change, and neither did the framing relative to the long side.
Computing the effective field of view in a script
The angle property on camera data gives the field of view along the fitted dimension only. For a full picture, compute both directions from the scene's resolution. This script runs inside Blender, for example in the Scripting workspace. It assumes the scene has an active camera.
import math
import bpy
def effective_fov(cam, scene):
"""Return (horizontal, vertical) field of view in degrees."""
render = scene.render
w, h = render.resolution_x, render.resolution_y
if cam.sensor_fit == 'AUTO':
size = cam.sensor_width
fitted_pixels = max(w, h)
elif cam.sensor_fit == 'HORIZONTAL':
size = cam.sensor_width
fitted_pixels = w
else: # 'VERTICAL'
size = cam.sensor_height
fitted_pixels = h
mm_per_pixel = size / fitted_pixels
fov_x = 2 * math.atan(w * mm_per_pixel / (2 * cam.lens))
fov_y = 2 * math.atan(h * mm_per_pixel / (2 * cam.lens))
return math.degrees(fov_x), math.degrees(fov_y)
scene = bpy.context.scene
cam_obj = scene.camera
if cam_obj is None:
raise RuntimeError("The scene has no active camera.")
cam = cam_obj.data
fx, fy = effective_fov(cam, scene)
print(f"fit={cam.sensor_fit} lens={cam.lens} mm")
print(f"horizontal {fx:.1f} deg, vertical {fy:.1f} deg")
print(f"cam.angle (fitted dimension) {math.degrees(cam.angle):.1f} deg")Run it, change the resolution to 1080 × 1920, and run it again. The two FOV values swap and cam.angle stays the same.
To change the sensor from a script:
import bpy
cam = bpy.context.scene.camera.data
cam.sensor_fit = 'HORIZONTAL'
cam.sensor_width = 23.5 # APS-C style sensor
cam.lens = 35Setting cam.sensor_height here would have no visible effect, because Horizontal fit ignores it.
Choosing a fit mode
Auto is the default and works for most scenes. Pick another mode only when you have a reason.
- Auto: good for general work. Be aware that the sensor value attaches to the long side, so switching orientation changes which angle matches your lens.
- Horizontal: use it when you match a camera whose lens is specified by horizontal field of view, or when you will change the aspect ratio and want the horizontal view to stay fixed. A 16:9 shot and a 2.39:1 crop will have the same width, and the taller frame simply shows more or less vertically.
- Vertical: use it when the vertical view must stay constant, as in a pipeline that animates the aspect ratio of a vertical-fit shot, or when the sensor spec you have gives the height.
You can also set the lens by angle instead of millimeters. Set cam.lens_unit = 'FOV' and edit cam.angle. The angle is still measured along the fitted dimension, so the sensor fit applies here too.
Common errors
- Editing the wrong field. You set
sensor_heightand nothing changes. In Auto and Horizontal fit, onlysensor_widthis used. - Assuming
cam.angleis the horizontal FOV. It is the FOV along the fitted dimension. In a portrait render with Auto fit, it is the vertical one. - Mismatched footage. You use the right focal length from the camera's metadata but leave the sensor at 36 mm. The CG view is too wide or too narrow. Set the real sensor size first.
- Surprise reframing on a resolution change. Switching a shot from 16:9 to 1:1 with Auto fit keeps the width at the same angle, so the image loses height at top and bottom. Check the camera view after every resolution change.
- Judging lenses across sensors by number alone. A 35 mm lens means different views on different sensors. Compare field of view, not millimeters.
Exercise
A scene uses a 50 mm lens, Auto sensor fit, and the default 36 mm sensor width. The render resolution is 1080 × 1920 (portrait). What are the horizontal and vertical fields of view, to one decimal place? Then you switch the sensor fit to Horizontal without changing anything else. What is the new horizontal field of view?
Show answer
In Auto fit with a portrait image, the 36 mm spans the height. Vertical FOV = 2 atan(36 / 100) = 39.6°. The effective sensor width is 36 1080 / 1920 = 20.25 mm, so horizontal FOV = 2 atan(20.25 / 100) = 22.9°. After switching to Horizontal fit, the 36 mm spans the width, so horizontal FOV = 39.6°. The vertical FOV then becomes 2 atan((36 1920 / 1080) / 100) = 2 atan(0.64), about 65.9°.
Exercise
You set cam.sensor_fit = 'AUTO' on a 1920 × 1080 shot and change cam.sensor_height from 24 to 12 in a script. The view in the camera does not change. Why, and which property would you change to make the framing tighter without touching the lens?
Show answer
In Auto fit only sensor_width is used, applied to the larger image side, so sensor_height has no effect. To tighten the framing without changing the lens, reduce sensor_width (for example from 36 to 24), which narrows the field of view. Alternatively, switch to Vertical fit, where sensor_height is the active value.