Page 1 of 2

In search of a depth of field plugin

Posted: Mon May 13, 2019 5:08 pm
by garuda
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.

Re: In search of a depth of field plugin

Posted: Mon May 13, 2019 11:09 pm
by JPDoc

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.


Re: In search of a depth of field plugin

Posted: Mon May 13, 2019 11:12 pm
by SecondMan

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.


Re: In search of a depth of field plugin

Posted: Tue May 14, 2019 2:13 am
by yannis

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


Re: In search of a depth of field plugin

Posted: Tue May 14, 2019 9:45 am
by garuda

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.


Re: In search of a depth of field plugin

Posted: Tue May 14, 2019 10:25 am
by SecondMan

Another solution is to introduce Fusion at your workplace :)


Re: In search of a depth of field plugin

Posted: Tue May 14, 2019 11:07 am
by bowserlm

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.


Re: In search of a depth of field plugin

Posted: Tue May 14, 2019 9:40 pm
by garuda

@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.


Re: In search of a depth of field plugin

Posted: Wed May 15, 2019 12:05 am
by garuda

I'm doing some more testing.
First off, the DepthDeFocus looks much better than initially thought, which only prove that I'm still learning :D
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.


Re: In search of a depth of field plugin

Posted: Wed May 15, 2019 12:57 am
by bowserlm

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.


Re: In search of a depth of field plugin

Posted: Wed May 15, 2019 4:45 am
by JUNE

@garuda Can you provide test pictures?


Re: In search of a depth of field plugin

Posted: Wed May 15, 2019 8:02 am
by garuda
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


Re: In search of a depth of field plugin

Posted: Wed May 15, 2019 7:38 pm
by JUNE
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

Thanks your sourceimage.

my dof's test

QQ截图20190516103558.jpg

NormalZ

CGS_NormalZ_EN1.2.setting

Re: In search of a depth of field plugin

Posted: Wed May 15, 2019 9:47 pm
by garuda

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.


Re: In search of a depth of field plugin

Posted: Thu May 16, 2019 1:54 am
by theotheo

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 {
					SourceOp = "Loader1",
					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 {
					SourceOp = "Loader1",
					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 } },
		},
		Loader1 = Loader {
			Clips = {
				Clip {
					ID = "Clip1",
					Filename = "/Users/theo/Downloads/DIANA_RS.exr",
					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