# Depth of field in EEVEE not focusing on selected object, works fine in cycles

I can't wrap my head around this. For some reason, no matter how much I try, I can't get the depth of field setting to do anything but make my entire shot blurry. My goal here is to have the F/C in focus and everything behind out of focus. When I switch to cycles, it works perfectly!

Here are some screenshots:

Cycles, works as wanted:

Eevee, not working:

I currently have it just clicked to focus on the F through the camera menu, but I did also earlier set up an empty and connect it to my camera as explained in this video:https://cgboost.com/blender-2-8-eevee-autofocus-fun/ for autofocus based off what the empty's point was projected at. That also wasn't working though. It does work perfectly for him though, so I'm thinking it's a user error but I can't figure out where I went wrong ha.

Here is the .blend file:

Any ideas?

• I can not access that file from google drive. Can you please upload it to blend-exchange.giantcowfilms.com ? That would be the recommended platform anyways. – aliasguru Aug 24 '19 at 15:38
• Good to know, thanks! – Jboogsthethug Aug 24 '19 at 18:28
• Played with the file using dof-utils. I guess it's the Max Size property under Properties > Render > Depth of Field. Default is 100px: i.stack.imgur.com/4MiP1.jpg However, I'm not exactly sure what this parameter is actual doing. Changing the quality of the bokeh...? – p2or Aug 24 '19 at 20:30
• Interesting, I did mess with that to test it but I could only change the overall blur or the lack thereof. I could never get it to just focus on the object. So if I play with that it should at some point work correctly? – Jboogsthethug Aug 24 '19 at 21:20

This is a mix of unwanted settings and a precision issue. First, as p2or already pointed out in the comments, there is a max size setting in the Depth Of Field area of the render settings in Eevee:

This size defines the maximum size of the bokeh shape. Effectively that means it can limit the amount of blur that is added to the rendering in Eevee. Your setting was around 4.3, which was a bit on the low side. Raising it to 10 already gives more visible DOF blur. The default is even 100.

Second, when setting a Focus object, keep in mind that the Origin of that object is used for calculating the DOF distance. On your letter F, the origin is somewhat inside the geometry:

Now, Cycles is very precise when tracing the scene, while Eevee takes its shortcuts. As a result, in Cycles the F looks ok (when in fact it is also a little blurry), while in Eevee it quickly drops out of focus. For your scene to keep the letter F in focus, it is necessary to set the focal point exactly on the front face of the F. I did this here using an empty:

The resulting image will then be like this:

Move the empty slightly forward and backwards, and you will see the blurred region flicker and jump. The result will still not be the latest and greatest, as there is that light wrap effect on the now in focus letter. Testing further, I noticed that this might be an inaccuracy of the blur calculation again. It kind of wraps into the edge area of the Alpha channel. If you turn on Transparent in the film settings and render, the image looks like this:

But in the Alpha channel, now we see that strange post processing blur. Look at the edges of the F:

That edge blur is what makes the F look blurry, even though it is in focus. So unfortunately, I believe for the scene you're working on, Eevee might not be sufficient for a final render in the end. One thing you could consider is rendering without blur in Eevee, and applying the DOF in post using the Z-Depth pass.

This would be the node setup required (remember to turn off Depth of Field in the Camera before rendering):

And this is the resulting image:

This gives you post-pro DOF adjustment ability as a bonus.

• OK that is exactly what I was wondering, whether it is some strange built-in thing happening or if I had messed it up. Is the edge blur a glitch in the programming of Eevee, or is it supposed to be that way? Regardless, I'm going to look more into the Z-Pass stuff as that is a concept I hadn't heard yet! Thank you for the in-depth explanation! – Jboogsthethug Aug 25 '19 at 18:35