Making DOF: tutorial

Here is a short and simple tutorial how to make DOF with Blender. I found it out this afternoon. I’ve made this image with it, wich I am really pleased with.
I hope you’l find it handy.

Sander Wit

I thought there was a way to render the complete scene in black/white instead of adding a material or render it first. This is possible by using the Node editor, but I thought it only had a horizontal linear line instead of a more realistic one. But still this is a nice way to do it another way. :slight_smile:

Roger just use the Z output of a Render Result node, like this

Roger just use the Z output of a Render Result node, like this

He can’t, he’s rendering the image with Yafray. (And he doesn’t like Yafray’s DOF implementation)

Yes he can, he can use blender internal for zbuffer and speedvectors and any mask he want and use image nodes for prerendered stuff like I did in this composition using both internal and povray:

I didn’t use my render thingies in the nodes, just used both two images: z-render and normal-render.

But I don’t get this NORMAL Z-rendering to work. What have I done wrong?
See my settings, I think they’re identical to yours:

Just change the offset in your Map Value until you start to see your monkey come up in the viewer. It varies depending on how your scene is set up.

Okay. I try that.

By the way, I find the way of making the grayscale-image (wich defines the amount of blur there will be) in the way I did it, quite good for now you have some more freedom on how you want the focus to be… You can even make an image with two focus points in it. It won’t be convincing though. (I tried it :stuck_out_tongue: it’s like my eyes con’t be fooled that much :P)

Anyway, here is another image I’ve made. Hope you like it. The DoF is created with Yafray… no just kiddin’ with MY technique :P.

Click it for a high-res version.

I played with this a while back and this is how you set up the map values…

set the offset value to the negative number of blender units from the camera where you want your Black point ( focus point…black is no blur)

then play with the size value until you get the gradient that you want- start small, say at about .1

if you have a negative size, it gets lighter as you get closer to the camera;)

This is a simple test scene that I did to see how to the map values worked .
I only spent a couple of minutes on the scene itself and I used extreme blur
so the image is crap but it’s good enough to show you how to set your map values…

I put the cursor at 12 units from the camera in the 3d window so you can see where the focus point is.

Nice screenshot man!, why do you use flat filter, it´s horrible, I like cubic :slight_smile:

heh… I was trying all of them to see what kind of effect I could get…
this is just the last thing I tried before I gave up:o
[edit] I meant to say that this was the .blend that I had saved to experiment with…[/edit]

I was trying combinations to see if I could get the far blur so that it didn’t blur over the focused part and the near blur so that it would… I had also seen somewhere that dof was not a smooth blur. Then I saw purple’s dof post and quit wasting my time :slight_smile:

hey roger,

is the chest scene al done in blender or did u also use yafray?
it looks like a GI rendering when i pay attention to the light set up.

for the DoF I noticed that with this blur effect quite often u lose quite some amount of edge quality. i solution might be to render the scene double size, apply the z depth based blur filter and than scale it down to lose those physical wrong details.


That’s right, it’s not linear. The size of the circles of confusion (blurriness) curves from the out-of-focus region before the focus point down to near 0 at the focus point, then increases again, limiting at the maximum circle size as determined by the aperture. (see: ). I hope purple’s node does this, it’s an important subtlety that’s often forgotten in post-pro DOF tools.

I rendered it with yafray (see the caustics?) with full GI (no lamps, just some light emiting planes as light sources)

and thanks for the tip, I’l try that.

By the way, I see elysiun is changed again, perhaps some moderator can move this topic to tutorials?

i will once there is a consensus that your way is the best way to do it. i want one solid answer for all the noobs.

or if yours is the best way with yafray, then please change the title and i can move it.

One question. I know this is a couple weeks late, but how do you render out the zbuffer? It looks like you have a zbuffer pass which is controlling the DOF. As a pass that is.

to “render out” a zbuffer conect z output (render result) to image input (compositor)

Have a screenshot of that? :smiley:

Womball like this but conecting the Z to the image output if you want to render it, or you could just conect it to a viewer and chose compositor in the UV window and then save what you get there with save image (just like it is now on the screenshot)

do you have a blend of the chess set???