Fence Posts and Pylons
(March 18, 2008) »
News, Hints and Events
Mini Bio
My PhD research was in computer science and complexity science, although I also published in web-technologies (and even paleontology!) I have founded, run and sold a high-tech business based on my research and written two technical text-books published by Elsevier.
Movie Cameras
February 25, 2008
Last year I worked on some calculations for movie-style cameras in a game engine, combining DoF, HDR, Motion Blur and regular FoV calculations.
With permission from the client, I've put together some of the charts I calculated, in case they might be of use to you.
The Camera
The game camera is a metaphor. Originally it was a grandiose metaphor for the projection transformation that converts locations in the game world’s coordinate system into locations on the screen. The projection transformation has 16 degrees of freedom (it has 16 values in the matrix), but they are not independent. The camera metaphor is useful because it breaks down the transform into easy to understand independent quantities: the position and orientation of the camera, its angle of view, and its aspect ratio. Typically the camera’s angle of view and aspect ratio don’t change, but its position and orientation do, so the two sets of data are separated into a ‘Projection’ matrix, and a ‘View’ matrix. Even though this has been enshrined in OpenGL and Direct3D, it is only a convenience, not a necessary distinction.
Until recently these parameters are all that were used. Lens-flair, the overused graphical gimmick of the late 1990s, is modelled after an effect seen in real cameras, but is normally implemented independently in code (by which I mean that the parameters of the camera normally do not affect the rendering of the flair). With the advent of full-screen post-processing effects we've added the ability to generate depth-of-field, representing the limits on focus that real-world lenses all display. And finally the emergence of HDR rendering has given us a way to represent a lens’s aperture.
In a real camera depth-of-field, HDR tone-mapping and field-of-view are not independent. They result from the choice of lens, in particular its focal length and aperture. Almost always the aperture is adjustable on each lens, and in the case of ‘zoom’ lenses, so is the focal length.
Field of View
The longer the focal length of the lens, the higher its magnification and the smaller its field of view. Field of view is related to focal length by the formula:

where D is the dimension of the film in the camera and f is the focal length of the lens. For standard (academy) 35mm movie film, D is 16mm in the vertical direction. The table shows the equivalent vertical field of view for a selection of common movie-making lenses.
| Lens | Vertical field of view | |
|---|---|---|
| Wide Angle | 10mm | 77.3° |
| 15mm | 56.1° | |
| Standard | 25mm | 35.5° |
| 35mm | 25.8° | |
| 50mm | 18.2° | |
| Telephoto | 85mm | 9.14° |
| 100mm | 6.78° | |
| 300mm | 3.06° |
The field of view may seem smaller than you are used to. Most games have fields of view in the 45°-75° range, equivalent to wide-angle movie lenses. Games use fields of view this wide to simulate the eye rather than the camera: the eye has a field of view around 140 degrees, but only about 60° of comfortable viewing angle (beyond 60° people tend to turn their heads).
Long focal length lenses seem to ‘compress’ distance: so there is less difference in size between closer and more distant things. In fact this is an optical illusion due to the fact that a long-focal length lens tends to be pointed at more distant objects, but it useful rule of thumb.
Depth of Field
The depth-of-field is the range of depths that are in focus. It depends on both the focal length of the lens, and the aperture, although the variable aperture on most lenses means that photographers rarely choose the focal length of the lens for its depth-of-field effect: they rely on changing the aperture. A small aperture (in photo-speak a high f/stop number) keeps a large range of distances in focus, while a wide aperture (a low f/stop) tends to show more blur. A small aperture, however, lets in only a small amount of light, while a large aperture captures more. A realistic HDR renderer, therefore, would show more depth-of-field blurring in low-light conditions (when the lens would have to be opened wide to gather enough light) and less in bright-light.
The connection between light, aperture and depth-of-field is too mathematically complex to present here. Instead the table below shows some calculations based on real-world figures to act as a guide. I have prepared the calculations based on a 35mm frame being displayed at 1200 pixel wide on screen (with lots of assumptions about the film-stock and other equipment used). The final figures are very different from those found in movie-making references which assume that you’ll be projecting the result onto a movie-screen.
| Subject Distance (m) | Max DOF | ||||
|---|---|---|---|---|---|
| FoV | Conditions | 2 | 5 | 10 | Near / Subject |
| 55 | Bright Daylight | 0.4 - Infinity | 0.5 - Infinity | 0.5 - Infinity | 0.3 / 0.6 |
| Overcast Daylight | 0.7 - Infinity | 0.9 - Infinity | 1.0 - Infinity | 0.6 / 1.1 | |
| Bright Indoors | 0.9 - Infinity | 1.2 - Infinity | 1.4 - Infinity | 0.8 / 1.6 | |
| Dim Indoors | 1.4 - 3.6 | 2.4 - Infinity | 3.1 - Infinity | 2.2 / 4.5 | |
| 20 | Bright Daylight | 1.5 - 2.9 | 2.8 - 24.0 | 3.9 - Infinity | 3.2 / 6.3 |
| Overcast Daylight | 1.7 - 2.4 | 3.6 - 8.3 | 5.6 - 48.1 | 6.3 / 12.6 | |
| Bright Indoors | 1.8 - 2.3 | 3.9 - 7.0 | 6.3 - 23.6 | 8.7 / 17.4 | |
| Dim Indoors | 1.9 - 2.1 | 4.5 - 5.6 | 8.3 - 12.5 | 24.8 / 49.6 | |
| 10 | Bright Daylight | 1.8 - 2.2 | 3.9 - 6.9 | 6.5 - 22.1 | 9.1 / 18.2 |
| Overcast Daylight | 1.9 - 2.1 | 4.4 - 5.8 | 7.8 - 13.8 | 18.2 / 36.5 | |
| Bright Indoors | 1.9 - 2.1 | 4.5 - 5.6 | 8.3 - 12.5 | 25.1 / 50.2 | |
| Dim Indoors | 2.0 - 2.0 | 4.8 - 5.2 | 9.3 - 10.7 | 71.7 / 143.4 | |
The data in the table gives the distance of the near and far ‘in-focus’ planes from the camera: i.e. where the depth-of-field blur should begin. If the subject is far enough from the camera then the far plane will be at infinity. The final column shows where the subject would be when this first occurs (the second number) and the position of the near in-focus plane at that time (the first number).
Notice that in dim conditions, for high magnification, the depth of field is very small (only an inch or so). Wide angle lenses in bright daylight, on the other hand, effectively have infinite depth of field.