This tutorial discusses the Bokeh phenomena, and several methods of
recreating it in cg.
What is Bokeh?
Bokeh refers to the phenomenon that occurs when parts of a
photographic
image goes out of focus. The most obvious of these effects is the small
circular
artifacts that appear when very bright points of light are now no
longer
in focus. Instead of just getting blurry (like you'd get if you applied
photoshop's gaussian blur filter to the photo), these points expand
into
little rings of light, much larger than the original points. Different
lenses and lighting conditions produce
different effects.
Here's a pepper shaker underneath a set of bright lights. Notice how
the tiny reflections of the lights bloom into large circles of light
when I put the camera out of focus.

A few websites dealing with bokeh for your amusement. You may wish to read up on the subject a bit before continuing...
Daniel Wexler
Peter
Zimmerman
Lens Gallery
And Bokeh isn't a phenomena specific to a camera. It occurs anytime
you focus bright light through a "lens". A lens can really be anything.
For example, here's a set of blinds in my house, notice the
bright sunlight traveling through the tiny vertical slits.

And here's the light pattern from the blinds on the floor. Notice
how it took the light from the long rectangular slits and focused them
into large round circles.

Simulating this in 3d can be done a number of ways. Several of the new raytrace renderers like Brazil can simulate these effects automatically when doing DOF, however, accurately simulating this can be very computationally intensive, which means long rendertimes in extreme situations. Faking it however is not an easy task, but the following are a few techniques that you may wish to consider.
Faking It Manually (The Really Hard Way)
First, some images I took of a christmas tree light over the holidays.
These images were taken with a Nikon Coolpix 990 digital camera, with a shutter speed of 1/15th of a sec, Exposure compensation at 0.0, and and Aperture of f3.6. Subject was approx. 1 foot from the camera.

Original image, focus at 0.35 m, or 14 inches.

focus at 0.09 m, or 3.5 inches.

focus at 0.05 m, or 2 inches.
Notice how the bright part of the light bulb (the filament) instead of just blurring creates small circular light effects. This in in contrast to what happens if you were to just apply a gaussian blur to the image in photoshop, which is the standard way people try and simulate DOF post process.

Gaussian amount of 40.
Anyways, for this technique, I'm using Digital Fusion from Eyeon and the Lensflare plugin that's part of POS from Cebas. You can also use photoshop instead of these two pieces of software if you're working on a still instead of an animation. My goal is to transform the first in focus image to the image taken at a focal distance of 0.09m. I'll start with the original image, and bring it into max as a background. Then I start placing lensflares at the places in the image that I see the blurred light points exist in the second image. For my flare, I turn everything off except secondary flares (lens reflections), and have only a single reflection with the following parameters.

What I'm basically trying to do is create a single circle of light. Again, if you're doing a still, you can paint these circles in photoshop, place each circle on a separate layer, and play with the transfer modes (try screen, lighten, etc) and transparency of the layers till you get the effect you want. Note that in POS the different circles are being "additively" composited together (additive is the standard mode, you don't have to change anything to get this to happen), and there is no additive mode in photoshop (although "Linear Dodge" comes pretty close, see my Photoshop Tips lesson for more details.), so you won't get exactly the same results. Anyways, back in POS, I created a bunch of these flares and played with it's intensity, color, size, etc., till getting my lens reflection image seen below.

Now I bring both my original infocus photographed image and my simulated lens reflection image into digital fusion. This is the flow I used.

Basically, I take the original image and blur it a whole lot, then
increase
the contrast while reducing it's brightness to get the shape of the
blurred
light bulb itself. Then I take the lens reflection image, blur it
slightly,
and mix it (screen mode) with a copy of itself that is far more
blurred,
and tinted red. I then adjust the brightness and saturation of that
image,
blur it a bit more, and then mix it to my original image (screen
again),
producing my final image.
|
![]() Simulated Image |
Instead of using fusion, you can do the same sort of thing in photoshop, just make your lowest layer a heavily blurred copy of your original image, the next layer a blurred copy of your lens reflection image (say by about a blur of 10-20), tint that layer red, and one last top layer which is a much less blurred copy of your lights that's tinted yellow slightly. Obviously in fusion it's easier to go back and tweak any of your modifications.
This technique can be used on any image or animation, any true photograph or cg simulated image, perhaps you have a scene with some characters talking to each other in the foreground, and you want a blurry background. Adding a simulated bokeh effect to the background will help give the piece realism. You don't realize how much we actually see this effect till we start looking, hell, just watch any soap opera on TV, the backgrounds are full of bokeh effects.
Notice my final image is not as chaotic as the original, you may wish to try adding a little noise to the lens reflections to give them more variety, or possibly play with the anamorphic quality of the flare to stretch and squash the lens reflections. And of course, do lots of research, watch bokeh effects in all kinds of lighting situations, you may have to modify your "circles" to be pentagons or even rectangles, get a lot of reference and start seeing what different types of bright objects produce what types of artifacts.
Here's a zip file containing the original max file, a digital fusion flow, and required bitmaps.
The Digital Fusion Defocus Filter
Here's a more automatic method, there's a defocus filter in Digital Fusion, the filter has two modes, gaussian and lens, the lens filter will blur a 2d image and in doing so enhance the bright parts of the image to produce an effect similar to bokeh. It's not perfect, and doesn't have every option under the sun, but still useful. Note that this filter is quite slow, and gets slower with more crazy blurs, but not as slow as doing it manually :) Thanks to Grant Adam for that info.

The Original Image

Defocus Setting of 2.5

Defocus Setting of 5.0
POS DOF
Also POS has a bokeh filter built into their DOF module. Create a
DOF
helper in your scene, and go to the lens artifacts section, you can
create
and control bokeh effects with much more precision than with the
digital
fusion filter. Check out these two test images...
|
![]() POS Bokeh |
Here's a zip file containing the
original
max file. Thanks to Dave Stewart for this information.
The Photoshop Lens Blur Filter
Recently Photoshop got a Lens Blur filter, which behaves in a similar fashion to the digital fusion filter. See the controls below. Thanks to Markus Schille for the info.
The only big problem with these last three methods is because
they're
post filters, they tend to produce bad aliasing artifacts at join
between
really blurry objects and really infocus objects. If you want to
defocus
an entire background plate, and then composite infocus characters on
top,
they work great, but they don't work all that well for say looking at a
floor, where you need a smooth transition between an infocus area and
an
out of focus area. Those are the situations where the slower raytraced
DOF works best. Many options, obviously use the one that works best for
whatever situation the shots demand.