Blender Bokeh Overview / Tutorial

Covering both internal (node based) and the new Cycles version built into the camera settings.

On the left we have the node and on the right the Cycles camera panel. I’ll come back to that after some photographer’s physics:

Inside a camera lens is a diaphragm made up of an iris, which is a number of blades that can open and close to varying degrees allowing various amounts of light into the film / sensor. Fortunately in the digital world we don’t have to deal with things like exposure and shutter speed, so we can focus on making the aperture hole whatever we want purely with intention for depth of field (DoF).

As the aperture hole gets bigger, the F/stop number gets smaller, and DoF becomes more pronounced (bokeh gets bigger):

Confusingly, there are two numbers that both photographers and Blender programmers use. One refers to the F/stop of the aperture and one to the size of the hole it makes. They’re referring to the same measurement in reality, but for some reason the standard isn’t really upheld to use one or the other. F/stop (denoted f2, f4 etc.) is for all intents and practical purposes arbitrary (they were set holes for the old old film cameras – each hole (each Fstop) is exactly twice the amount of blur as the last). All you really need to know is that typical camera lenses are between f1.4 and f22 but most commonly around f5-f10 when taking into account the film’s exposure and whatnot. Conveniently, the Blender node simply uses this directly. Plug in some value around 5 and you’ll get a decent result.

But. You’ll notice this F-value gets smaller as the hole gets bigger. A pain. Cycles interface uses this number directly. The bigger the number, the bigger the hole, the bigger the bokeh. It makes sense and I applaud them for taking the straightforward approach for strictly digital users, but a lot of us are photographers and more comfortable with the old notation. Personal preference, I guess. Anyway, values between 0.1 and 1.0 seem to work well, based on focal point (more on that later).

There is a conversion ratio, apparently, but I tried it in a few experiment renders and it didn’t seem to be very accurate for me, so I’m not sure I’ll both posting it. Mostly, do it by test and eventually, feel.

I’ve been lurking various forums and subreddits and there have been a few comments on bokeh, what it is and how to get it. The node system sort of did it, but unreliably, and the Cycles system does do it much better. You can download my test .blend HERE to play along. It’s just an array of cubes and a few other cubes that have an emission material.


150 samples :: 23.79 s :: Cycles: 0 | 0 | 0 (appearing in order of interface: size, blades, rotation)


300 samples :: 48.04 s :: Cycles: 0.1 | 0 | 0

You’ll notice the more blur the more samples you’ll need to keep it smooth. Mine aren’t quite done yet (still a bit grainy) but I’m still in the low range of samples (150-500)

Bokeh is the word they use to describe the shape of the out of focus parts. Because of the lens focus and physics of optics and so on it takes the shape of the diaphragm the light is focused through. So, if the lens has a lot of  blades in the iris it’ll be more circular (common) and sometimes the aperture only has 5 or six blades, creating penta and hexagon bokeh respectively. You will see in movies triangle and diamond bokeh for stylistic effects and if you put a cutout in front of the lens you can make it whatever shape you want. Typically, circles are the smoothest and hexagons are used for science fiction movies. Subtle differences, but those angles can really change the feel of a scene.


500 samples :: 1.21.23 :: Cycles: 0.3 | 0 | 0


500 samples :: 1.21.60 :: Cycles: 0.3 | 6 | 0

The difference between 0 (circle) and 6 (hexagon) bokeh. Notice the best looking bokeh comes from the smaller cubes in the back (to the left) – the large ones just blow it all out.

Both the node and Cycles has this easily built in, simple select the number of sides you want from 0 (perfect circle) to octagon. After that, polygons tend to look like circles anyway, so there isn’t any need to go higher. Or, in Cycles, simple type in a number for # of blades. (0, 3-9). Both have an angle / rotation as well. This is the rotation (in degrees) that that polygon gets rotated. Say if you’re using a pentagon and you wanted the point up or down, you could angle it as you’d like. If you’re trying to simulate a specific lens just find a source image and look at how it’s diaphragm is rotated to rotate your bokeh accordingly. Note this does not effect the size at all.


500 samples :: 1.21.24 :: Cycles: 0.3 | 6 | 30

So we can rotate the hexagon bokeh 30 degrees to make the flat edge down. 360 / 6 / 2 = 30


1000 samples :: 2.51.62 :: Cycles: 0.6 | 6 | 30


1000 samples :: 2.51.29 :: Cycles: 0.6 | 9 | 0

Taking it to the extreme: 0.6 creates a lot of blur and needs a lot more samples. Almost 3 minutes vs. 23 seconds for the 0 DoF control render.

Since bokeh is the effect of light’s focus on the film / sensor, the amount of light defines a lot about the resulting effect. Light sources are often the cause of the prevalent bokeh in the background of scenes – makes sense, they’re putting out light. Specular reflections on geometry can also make bokeh, but the effect will typically be diminished because the material is absorbing some of the energy in the bounce. Likewise, glossy materials are better than matte materials for this; rarely will you get any real effect from a matte material since it absorbs and scatters most of the light.

The size of the bokeh, as mentioned briefly above, is directly linked to the aperture size – the amount of DoF blur. If you aren’t getting the desired effect it’s because either there isn’t enough light power to create it or that the ‘lens’ is too in focus, meaning there isn’t enough blur to get anything good. Typically, it’ll be the former. This is where the node DoF struggles, the threshold for creating bokeh seems a little off and it takes a really intense light value in the scene to get results. It’s a tradeoff, though, because you can easily make things too blurred and start moving into tiltshift area.

Now, there is another reason the camera might be too in focus and it has to do with the focus distance. The closer the focus is to the camera, the more DoF blur you’ll get, even at the same aperture size. If the focus is extremely far away, you’ll have to compensate with an irrationally large iris to maintain the same amount of blurring effect.

It seems, in my informal tests so far, that the node based one is much faster but Cycles is much more accurate, especially when reflections are concerned (node isn’t smart enough – will reflect perfect focus instead of realistic reflected bokeh). The more blur you have, the more samples you’ll need to make it smooth. There seems to be a curve to this, where minor blur increases = major extra samples. Just keep it in mind. You can use nodes compositing on top of a Cycles render, so it isn’t limited just to internal.

Let’s review:
-F/stop between ~2-10 (2 being lots, 10 being less)
-Cycles size between ~0.2-1.0 (0.2 being less, 1.0 being lots)
-Shape defines the appearance of the bokeh
-Rotation rotates that shape
-Distance to camera and lighting power do effect bokeh intensity / size
-Nodes are faster, Cycles and more accurate

Credits to everyone who’s image I googled; all link through.

You can download my demo scene HERE to play with.

Look! More awesome posts:

  1. Tron Sensor Spikes – Blender glare tutorial
  2. Abrams Anamorphic Blender Blur
  3. Blender for Architecture Tutorial: Sunshine

(c) 2013 ACRYLO | powered by WordPress