"It is better to have a permanent income than to be fascinating."
- Oscar Wilde

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.

Name

Comment

Enter the code below



Seth
Wednesday, December 17, 2008

I think blog entries are a great addition to the site. Keep up the good work!

sqrt[-1]
Sunday, January 4, 2009

This is a bit late of a post (don't check this site often) But I find the blue on yellow a bit hard to read for lots of text (as other people has said an RSS feed would be great as then I could use whatever color I liked)