## In search of a depth of field plugin

Moderator: SecondMan

garuda
Posts: 10
Joined: Sun Dec 10, 2017 10:55 pm
Location: Los Angeles
Been thanked: 1 time
Contact:

### In search of a depth of field plugin

Hi,

An After Effects user here getting more and more interested in Fusion.
I tried Fusion a few times over the past few years always feeling it could be great to use it but never had the time or the chance to fully work with it. What I always struggled with is a solid solution for a depth of field plugin. The one Fusion cones with doesn't feel rich enough (compared for instance to Frischluft).
But then lately I tried again and I realized there's a defocus filter which is actually pretty good. Then I wonder why when I ask around what people suggest as a good depth of field solution in Fusion they never mention defocus. Am I missing something? Some limits on using defocus I have yet to find out maybe?
Just curious to hear your thoughts. Maybe you as experienced users have different workflow or solutions.
The dof I use often deals with zdepth pass from C4D.

P.S. I know there's a Frischluft version for Fusion but I'm curious to see if I can find everything I need in the free version.

JPDoc
Fusioneer
Posts: 179
Joined: Tue Sep 02, 2014 8:26 am
Been thanked: 1 time

### Re: In search of a depth of field plugin

You can use "proper" depth of field in both the software and hardware renderers, but it is very slow, even with openCL in use. The Frischluft plugin doesn't use openCL as far a I know, but it is still much faster and produces results that are far superior to anything I've managed to come up with using various combinations of Fusion's normal filter nodes. I've use it in production many times with good results. You can get a depth of field effect using defocus and it's sort of passable, but the Frischluft one is far closer to actual lens results.

SecondMan
Posts: 3267
Joined: Thu Jul 31, 2014 5:31 pm
Been thanked: 53 times
Contact:

### Re: In search of a depth of field plugin

Welcome, After Effects user. You've come to the right place

Fusion's Defocus is capable of producing nice results with varying bokeh shapes, but it's strictly a "flat" 2D effect. Meaning that the same level of defocus will be applied across the image and it won't take into account any depth information. A tool like Frishluft does take ZDepth information as an input and will apply defocus variably and accordingly.

There is the Variblur node, which allows for varying levels of blur across an image based on an input map, so you can cook your own DoF node, to a point, but unfortunately the blur algorithms it offers aren't as sophisticated looking as those of the Defocus node.

There are ways of faking it, of course, and lots of them, but the results are very variable. As an out-of-the-box solution Frishluft is tried and tested and highly regarded.

yannis
Posts: 18
Joined: Wed Aug 02, 2017 2:53 pm
Location: Paris (France)
Contact:

### Re: In search of a depth of field plugin

Here is also Simon Ubsdell's custom depth blur tutorial, if it can help...

garuda
Posts: 10
Joined: Sun Dec 10, 2017 10:55 pm
Location: Los Angeles
Been thanked: 1 time
Contact:

### Re: In search of a depth of field plugin

Thank you all for your insights.
Then it's true, there isn't a proper solution right out of the box. Too bad as this is the only thing at the moment that's holding me back from adopting Fusion.
I use Frischluft a lot with AE at work and the results are great indeed. For Fusion the situation is different as it's for personal use. I could potentially buy the Studio version as it's not too expensive but adding a Frischluft license means almost paying twice the price.
Bummer. I really like what I'm seeing in Fusion but depth of field is the number one thing I deal with in my work. Strange that Blackmagic hasn't improved the defocus node. They already have variblur, it would be great if they would merge (no pun intended) the two filters.

SecondMan
Posts: 3267
Joined: Thu Jul 31, 2014 5:31 pm
Been thanked: 53 times
Contact:

### Re: In search of a depth of field plugin

Another solution is to introduce Fusion at your workplace

bowserlm
Fusionista
Posts: 299
Joined: Sat Apr 28, 2018 3:44 pm
Been thanked: 4 times

### Re: In search of a depth of field plugin

Isn't there a decent depth of field node in Reactor that can use a Depth image?

I personally can never get it to work properly, but I've seen others get good results.

garuda
Posts: 10
Joined: Sun Dec 10, 2017 10:55 pm
Location: Los Angeles
Been thanked: 1 time
Contact:

### Re: In search of a depth of field plugin

@SecondMan Well is not so easy. I'm a freelancer

@Yannis: thanks for reminding me of that tutorial. I noticed it a while back.

@bowserlm: I installed Reactor among with some of the nice tools provided in its repository. I've found DepthDefocus, perhaps that's the one you're referring to.
I tried it, although rather quickly I have to admit. It seems a nice setup, even though for some reason the Invert Depth Map wasn't working. But other than that, at first glance, I didn't notice any particular improvement over the other mentioned ways to use the depth of field. Perhaps its usefulness it's because it combines a few things into one tool. But I'll test it further. I'm a total newbie with Fusion, so I'm only getting superficial impressions for now. I'm sure I'm missing a lot of things!

That said, I wonder if it would make sense to post a request on the BM forum hoping that some dev will read it. Perhaps they could combine the defocus and the variblur or come up with something new.

garuda
Posts: 10
Joined: Sun Dec 10, 2017 10:55 pm
Location: Los Angeles
Been thanked: 1 time
Contact:

### Re: In search of a depth of field plugin

I'm doing some more testing.
First off, the DepthDeFocus looks much better than initially thought, which only prove that I'm still learning
The invert depth map is still not working for me, I might be missing something.

I struggled with the depth distance and I ended up adding a CC to crush the levels, which helped quite a bit.
I actually like the bokeh with the DepthDeFocus a lot. It kind of reminds me of the creamy bokeh of the Russian lenses (the Helios).
One thing I can't seem to figure out is how to get rid of the edge artifacts (for instance near the head and the shoulders of the statue in the FG).

Defocus

Diana_DeFocus_000.jpg

DepthDeFocus

Diana_DepthDeFocus_000.jpg

AE + Frischluft

DIANA_RS_frischluft.jpg

Of course, this test is not a true comparison attempt by any means.
The gamma is not consistent between AE and Fusion and so aren't the depth of field parameters (more extreme anamorphic in Fusion).
But at this point it really comes down to whether is possible to fix that edge artifact or not. If there's a fix, I think I could easily go with Fusion.

You do not have the required permissions to view the files attached to this post.

bowserlm
Fusionista
Posts: 299
Joined: Sat Apr 28, 2018 3:44 pm
Been thanked: 4 times

### Re: In search of a depth of field plugin

Use an Erode/Dilate on your depth image to tweak exactly where that intersection is. Use masks to localize the Erode/Dilate effect if you need to do it only around certain areas.

JUNE
Fusioneer
Posts: 217
Joined: Wed Aug 06, 2014 5:45 am
Been thanked: 9 times
Contact:

### Re: In search of a depth of field plugin

@garuda Can you provide test pictures?

garuda
Posts: 10
Joined: Sun Dec 10, 2017 10:55 pm
Location: Los Angeles
Been thanked: 1 time
Contact:

### Re: In search of a depth of field plugin

JUNE wrote:
Wed May 15, 2019 4:45 am

@garuda Can you provide test pictures?

Sure, here it is:
http://phoenixart.com/temp/Fusion/DIANA_RS.zip

JUNE
Fusioneer
Posts: 217
Joined: Wed Aug 06, 2014 5:45 am
Been thanked: 9 times
Contact:

### Re: In search of a depth of field plugin

garuda wrote:
Wed May 15, 2019 8:02 am
JUNE wrote:
Wed May 15, 2019 4:45 am

@garuda Can you provide test pictures?

Sure, here it is:
http://phoenixart.com/temp/Fusion/DIANA_RS.zip

my dof's test

QQ截图20190516103558.jpg

NormalZ

CGS_NormalZ_EN1.2.setting
You do not have the required permissions to view the files attached to this post.
Last edited by JUNE on Thu May 16, 2019 3:05 am, edited 1 time in total.

garuda
Posts: 10
Joined: Sun Dec 10, 2017 10:55 pm
Location: Los Angeles
Been thanked: 1 time
Contact:

### Re: In search of a depth of field plugin

Thanks for trying, June.
I guess that something is happening in that CGS_NormalZ node, which I suppose is a proprietary plugin (and maybe the DepthofField too?).
I'm not quite sure whether is a tool that can be installed on the free version or if I need the Studio version.

Any tips you could share in case there's a way to fix the edges artifacts using the standard built-in tools or the ones available through Reactor?
I would appreciate it.

Best,
Piero

Added in 10 minutes 42 seconds:

bowserlm wrote:
Wed May 15, 2019 12:57 am

Use an Erode/Dilate on your depth image to tweak exactly where that intersection is. Use masks to localize the Erode/Dilate effect if you need to do it only around certain areas.

Thank you, bowserlm

That would help but is not very practical. It sure helps for a still image, but when it comes to animations the workflow becomes cumbersome and time-consuming.
Also, in this case, the image I prepared is pretty basic. With overlapping geometry it can be a true pain.

theotheo
Fusionista
Posts: 296
Joined: Thu Aug 07, 2014 8:35 am
Been thanked: 9 times

### Re: In search of a depth of field plugin

If you're going for very shallow depth of field, there's no tricks to solving the edge artefacts completely. Its because there just isn't enough information available to correctly segment edges in a single flat depth image. You can tweak yourself to death fixing the issues in comp. Its doable but its very much on a per image/shot/pixel tweaking level.

Two options (with varying results)

• Split the image based on depth, and use the color dilate to fill in BG holes (and same for FG) and blur them separately and then over them. This works if you have a clear-is fg and bg separation in your image anyway.

• Map the image to a image plane 3d and do a fairly high res geo displacement and render it out with dof in the Renderer3D's accumulation effects. This is also a hit and miss scenario.

The only two ways to correctly get shallow depth of field without (too much) edge artefacts is to :

• Render and comp using deep and pgBokeh (Nuke only)
• Render with depth of field from your CG software.

Showcasing displacement method

Code: Select all

{
Tools = ordered() {
ChannelBooleans1 = ChannelBoolean {
Inputs = {
ToRed = Input { Value = 18, },
ToGreen = Input { Value = 18, },
ToBlue = Input { Value = 18, },
ToAlpha = Input { Value = 18, },
EnableExtraChannels = Input { Value = 1, },
Background = Input {
Source = "Output",
},
},
ViewInfo = OperatorInfo { Pos = { 562, 253 } },
},
CustomTool1 = Custom {
Inputs = {
LUTIn1 = Input {
SourceOp = "CustomTool1LUTIn1",
Source = "Value",
},
LUTIn2 = Input {
SourceOp = "CustomTool1LUTIn2",
Source = "Value",
},
LUTIn3 = Input {
SourceOp = "CustomTool1LUTIn3",
Source = "Value",
},
LUTIn4 = Input {
SourceOp = "CustomTool1LUTIn4",
Source = "Value",
},
RedExpression = Input { Value = "(1/r1)", },
Image1 = Input {
SourceOp = "ChannelBooleans1",
Source = "Output",
},
},
ViewInfo = OperatorInfo { Pos = { 562, 283 } },
},
CustomTool1LUTIn1 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 204, Green = 0, Blue = 0 },
NameSet = true,
},
CustomTool1LUTIn2 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 0, Green = 204, Blue = 0 },
NameSet = true,
},
CustomTool1LUTIn3 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 0, Green = 0, Blue = 204 },
NameSet = true,
},
CustomTool1LUTIn4 = LUTBezier {
KeyColorSplines = {
[0] = {
[0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
[1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
}
},
SplineColor = { Red = 204, Green = 204, Blue = 204 },
NameSet = true,
},
Camera3D1 = Camera3D {
Inputs = {
AoV = Input { Value = 17.17, },
FLength = Input { Value = 39.3460854930352, },
PlaneOfFocus = Input { Value = 2.205, },
["Stereo.Mode"] = Input { Value = FuID { "OffAxis" }, },
FilmGate = Input { Value = FuID { "BMD_URSA_4K_16x9" }, },
ApertureW = Input { Value = 0.728, },
ApertureH = Input { Value = 0.467716535433071, },
ViewingVolumeSize = Input { Value = 1.253, },
IDepth = Input { Value = 3.1, },
["SurfacePlaneInputs.SubdivisionWidth"] = Input { Value = 313, },
["SurfacePlaneInputs.ObjectID.ObjectID"] = Input { Value = 1, },
ImageInput = Input {
Source = "Output",
},
["MtlStdInputs.MaterialID"] = Input { Value = 1, },
},
ViewInfo = OperatorInfo { Pos = { 703, 296 } },
},
ErodeDilate1 = ErodeDilate {
Inputs = {
Green = Input { Value = 0, },
Blue = Input { Value = 0, },
Alpha = Input { Value = 0, },
XAmount = Input { Value = 0.00632, },
Input = Input {
SourceOp = "CustomTool1",
Source = "Output",
},
},
ViewInfo = OperatorInfo { Pos = { 562, 316 } },
},
Clips = {
Clip {
ID = "Clip1",
FormatID = "OpenEXRFormat",
StartFrame = -1,
LengthSetManually = true,
TrimIn = 0,
TrimOut = 0,
ExtendFirst = 0,
ExtendLast = 0,
Loop = 0,
AspectMode = 0,
Depth = 0,
TimeCode = 0,
GlobalStart = 1001,
GlobalEnd = 1001
}
},
Inputs = {
["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
["Clip1.OpenEXRFormat.Channels"] = Input { Value = 1, },
["Clip1.OpenEXRFormat.RedName"] = Input { Value = FuID { "R" }, },
["Clip1.OpenEXRFormat.GreenName"] = Input { Value = FuID { "G" }, },
["Clip1.OpenEXRFormat.BlueName"] = Input { Value = FuID { "B" }, },
["Clip1.OpenEXRFormat.AlphaName"] = Input { Value = FuID { "A" }, },
["Clip1.OpenEXRFormat.ZName"] = Input { Value = FuID { "Depth.alpha" }, },
},
ViewInfo = OperatorInfo { Pos = { 703, 169 } },
},
Displace3D1 = Displace3D {
Inputs = {
SceneInput = Input {
SourceOp = "Camera3D1",
Source = "Output",
},
Channel = Input { Value = 1, },
Scale = Input { Value = 0.188, },
CameraDisplacement = Input { Value = 1, },
PointCamera = Input { Value = 1, },
CameraSelector = Input { Value = FuID { "Camera3D1" }, },
Input = Input {
SourceOp = "BrightnessContrast1",
Source = "Output",
},
},
ViewInfo = OperatorInfo { Pos = { 703, 354 } },
},
BrightnessContrast1 = BrightnessContrast {
Inputs = {
Gamma = Input { Value = 1.342, },
Input = Input {
SourceOp = "ErodeDilate1",
Source = "Output",
},
},
ViewInfo = OperatorInfo { Pos = { 562, 354 } },
},
Renderer3D1 = Renderer3D {
CustomData = {
ToolVersion = 1,
},
Inputs = {
GlobalIn = Input { Value = 1001, },
GlobalOut = Input { Value = 1100, },
Width = Input { Value = 1280, },
Height = Input { Value = 720, },
Depth = Input { Value = 3, },
["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
SceneInput = Input {
SourceOp = "Displace3D1",
Source = "Output",
},
RendererType = Input { Value = FuID { "RendererOpenGL" }, },
["RendererOpenGL.AccumulationEffects"] = Input { Value = 1, },
["RendererOpenGL.EnableAccumEffects"] = Input { Value = 1, },
["RendererOpenGL.AccumQuality"] = Input { Value = 512, },
["RendererOpenGL.DoFBlur"] = Input { Value = 0.173, },
["RendererOpenGL.Lighting"] = Input { Value = 0, },
["RendererOpenGL.TextureDepth"] = Input { Value = 3, },
["RendererOpenGL.WireframeAntialiasing"] = Input { Value = 0, },
},
ViewInfo = OperatorInfo { Pos = { 703, 431 } },
}
}
}

Ive dilated the depth matte a bit out, so it should allow for somewhat more blurriness without eating into the edges of the fg object.

dof2.jpg

Extreme example:

dof3.jpg
You do not have the required permissions to view the files attached to this post.