"The wise make proverbs, and fools repeat them."
- Isaac Disraeli

On depth of field
Tuesday, December 16, 2008 | Permalink

For my first entry in my new blogging effort I'm going to talk about depth of field, which is a particularly interesting subject given both my graphics programming and photography interests. My former boss Andreas ThorsÚn sent me this interesting blog post on the subject.

First thing first, I agree with Vincent that "current depth of field effects in games fall short of delivering the same cinematic emotion as movies and TV", or as I would put it: they generally suck. My pet peeve with depth of field as typically implemented is that there's no smooth transition between sharp and out of focus areas. Many games implement depth of field by taking the framebuffer and blurring it. Then the sharpness is controlled by linearly interpolating between the sharp and blurry image. This is generally cheap, especially since you probably already have a blurred version of the framebuffer around anyway for other posteffects such as bloom. However, except in the fully sharp and fully blurry areas the quality leaves a lot of be desired. Object edges aren't going to be smoothly blurred, but instead you'll see a sharp edge with some sort of halo blended on top of it. Not exactly what you want. What you really want is a blur kernel with an adjustable radius. Unfortunately, that's also a lot more expensive.

Now that wasn't what Vincent complained about in his post on the subject. He is complaining that the bokeh (that's "out of focus blur" for you non-photographers) in games isn't anywhere close to what you see in movies or on TV. Instead of the gaussian blur that's commonly applied by games he's suggesting a filter similar to "lens blur" in Photoshop with disc shaped blobs of out of focus light sources. Personally I'm not convinced this is better though. Even though this is the result you'll see in most photos it's not exactly "the gold standard" either. Many photographers (including myself) considers this an artifact, just like for instance lens-flares. Not that that has ever stopped game developers from adding it to their games. The shape of the blobs depends on the aperture of the lens. Lenses with adjustable aperture generally are created by a bunch blades. The higher the number of blades the closer to a circle the aperture will be. On a cheap lens you might see something like an octagon shape whereas with more expensive lenses it will look almost circular. The reason you're seeing a blob rather that something softer like a gaussian falloff is because the aperture has hard eges. The question is if that's desirable. Producers of highend lenses tend to not agree. Hence there are some highend lenses that contain special elements in order to produce softer bokeh and remove the blob effect, like for instance this one. If you compare the 80-200@F4.5 and 135 STF@F4.5 example images on that site I'm sure most will agree with me that the latter is the better looking image.

With that said, what's best is of course highly subjective. I'm sure there are people that prefer blobbier bokeh, and other lens artifacts such as flares, vignetting, scratches etc. has been used for artistic reasons before. Since people are used to seeing blobby bokeh I'm sure that effect has its place too.

[ 2 comments | Last comment by sqrt[-1] (2009-01-04 11:28:28) ]