Jump to: Board index » General » Fusion

Trying to understand howto achieve depth of field

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

Przemek Jeske

  • Posts: 32
  • Joined: Sun Dec 28, 2014 2:58 pm

Trying to understand howto achieve depth of field

PostTue May 23, 2017 12:47 pm

I've been trying to add DOF to some of my renders with Fusion and I can't figure it out.
I've saved the file as an EXR, with an extra Z depth output:
Image
When I assign Z channel to RGB I can see the Z channel looks like it should (I think):
Image
But when I have those assigned to default channels (RGB to RGB, Z to Z) and I switch to Z in the viewer I see a blank white screen:
Image

Not sure it is ok , or not - but I suspect not as when I use DepthBlur node it seems everything gets blurred, I can't see any depth to it.
Any ideas what I'm doing wrong?
Offline

Przemek Jeske

  • Posts: 32
  • Joined: Sun Dec 28, 2014 2:58 pm

Re: Trying to understand howto achieve depth of field

PostTue May 23, 2017 1:30 pm

ok, I think I'm getting hang of it. It seems that if I put some crazy low values in in Z scale field (like 0.05) I'm getting DoF . But that actually makes the whole slider useless as it works on much bigger values and I have to type those by hand (but at least it works :) ). Is there a workaround for it - those sliders are pretty handy :) .
Oh, and just in case - I'm running Fusion on CentOS 7.3 (dual Xeon workstation).
Offline
User avatar

Chad Capeland

  • Posts: 3025
  • Joined: Mon Nov 10, 2014 9:40 pm

Re: Trying to understand howto achieve depth of field

PostTue May 23, 2017 2:20 pm

How would Fusion know what the scale of your render was?
Chad Capeland
Indicated, LLC
www.floweffects.com
Offline
User avatar

Bryan Ray

  • Posts: 2485
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: Trying to understand howto achieve depth of field

PostTue May 23, 2017 3:58 pm

My experience, and a brief experiment, suggests that the Z Scale control works in the opposite direction that the documentation suggests. Fusion assumes that a typical Z buffer will contain values from 0 - 1000, if I recall correctly. If that is true, then leaving Z Scale at 200 causes the tool to operate comfortably. If your range is much smaller than that, say 1 - 10 like my test image, reducing the Z Scale seems to make it work better.

My experiment image has a buffer with actual values from 3 - 8. I attempted to get the same blur quality from that and from a version where I'd gained the Z by 200, resulting in values from 600 - 1600. Here's a screenshot of my results:

Untitled.jpg
Untitled.jpg (251.11 KiB) Viewed 2160 times


The Color Inspector values in each Viewer are drawn from similar locations. As you can see, when the Z values are low, my Z Scale control is set at 0.2. When they are high, it is set at 91.

The Z Scale isn't really something you need to adjust often, though. Since it's a "set it and forget it" control, I don't think there's much problem with having to manually enter numbers there. The Focal Point slider, though, operates on the pre-scaled values, and since its range is -1000 - 1000, a scene with small Z values causes that slider to be too sensitive.

There is, fortunately, a way to reduce that sensitivity. If you right-click a tool and choose "Edit Controls…" you will get an interface where you can adjust the behavior of many controls.

Untitled.png
Untitled.png (41.85 KiB) Viewed 2160 times


You just need to choose the control you wish to edit and change the Range values. Also switch the Page to Controls so it doesn't wind up on a new User tab. You could do the same with the ZScale slider if you wish.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

Przemek Jeske

  • Posts: 32
  • Joined: Sun Dec 28, 2014 2:58 pm

Re: Trying to understand howto achieve depth of field

PostTue May 23, 2017 5:57 pm

thank you Brian - your reply is super helpful! Didn't know there is an option to edit tool sliders.
Is there a way to get some sort of (possibly auto ;) ) measurement that would give me maximum and minimum values of the Z channel (@Chad : how would I know?) ?
As those are numeric values , sorting them out and finding extremes should be extremely ;) easy to code that so thus I hope there is something built in (and that's what initially caught me off guard - I assumed dof node does it) for this task.
Picking out a focal point wasn't a hassle for me as I've used a picker and I've simply chosen desired spot :) .

Of course I'll also investigate how can I set a render in way that would cause less hassle with Z channel :) .
Offline
User avatar

Bryan Ray

  • Posts: 2485
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: Trying to understand howto achieve depth of field

PostWed May 24, 2017 1:11 am

I'm not aware of a way to get it automatically, but there's a fairly simple trick I know with the CustomTool:

if(z1>n1,1,0)

If you put that expression in all three color channels, you can use the NumberIn1 slider to find the brightest pixel. View the CustomTool and raise n1 until the last white pixel disappears. The n1 value is then the maximum value in your Z buffer.

You could do something similar to find the lowest value:

if(z1<n2,1,0)

Again, adjust NumberIn2 until you see pixels, then lower it until the last one disappears. Here's a CustomTool that finds both ends. The bright end shows in the red channel and the low end in green.

Code: Select all
{
   Tools = ordered() {
      CustomTool1 = Custom {
         CtrlWZoom = false,
         CustomData = {
            Settings = {
               [1] = {
                  Tools = ordered() {
                     CustomTool1 = Custom {
                        Inputs = {
                           LUTIn3 = Input {
                              SourceOp = "CustomTool1LUTIn3",
                              Source = "Value",
                           },
                           LUTIn1 = Input {
                              SourceOp = "CustomTool1LUTIn1",
                              Source = "Value",
                           },
                           Image1 = Input {
                              SourceOp = "TimeSpeed1",
                              Source = "Output",
                           },
                           Image2 = Input {
                              SourceOp = "ChangeDepth1_1",
                              Source = "Output",
                           },
                           LUTIn4 = Input {
                              SourceOp = "CustomTool1LUTIn4",
                              Source = "Value",
                           },
                           LUTIn2 = Input {
                              SourceOp = "CustomTool1LUTIn2",
                              Source = "Value",
                           },
                        },
                        Name = "CustomTool1",
                        CtrlWZoom = false,
                        ViewInfo = OperatorInfo { Pos = { 550, 181.5, }, },
                        CustomData = {
                        },
                     },
                     CustomTool1LUTIn1 = LUTBezier {
                        Name = "CustomTool1LUTIn1",
                        NameSet = true,
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        SplineColor = { Green = 0, Blue = 0, Red = 204, },
                     },
                     CustomTool1LUTIn2 = LUTBezier {
                        Name = "CustomTool1LUTIn2",
                        NameSet = true,
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        SplineColor = { Green = 204, Blue = 0, Red = 0, },
                     },
                     CustomTool1LUTIn3 = LUTBezier {
                        Name = "CustomTool1LUTIn3",
                        NameSet = true,
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        SplineColor = { Green = 0, Blue = 204, Red = 0, },
                     },
                     CustomTool1LUTIn4 = LUTBezier {
                        Name = "CustomTool1LUTIn4",
                        NameSet = true,
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        SplineColor = { Green = 204, Blue = 204, Red = 204, },
                     },
                  },
               },
               [2] = {
                  Tools = ordered() {
                     CustomTool1 = Custom {
                        Inputs = {
                           LUTIn3 = Input {
                              SourceOp = "CustomTool1LUTIn3",
                              Source = "Value",
                           },
                           LUTIn4 = Input {
                              SourceOp = "CustomTool1LUTIn4",
                              Source = "Value",
                           },
                           Image2 = Input {
                              SourceOp = "ChangeDepth1_1",
                              Source = "Output",
                           },
                           RedExpression = Input { Value = "c1-c2", },
                           GreenExpression = Input { Value = "c1-c2", },
                           LUTIn1 = Input {
                              SourceOp = "CustomTool1LUTIn1",
                              Source = "Value",
                           },
                           Image1 = Input {
                              SourceOp = "TimeSpeed1",
                              Source = "Output",
                           },
                           BlueExpression = Input { Value = "c1-c2", },
                           LUTIn2 = Input {
                              SourceOp = "CustomTool1LUTIn2",
                              Source = "Value",
                           },
                        },
                        CtrlWZoom = false,
                        ViewInfo = OperatorInfo { Pos = { 550, 181.5, }, },
                        CustomData = {
                        },
                     },
                     CustomTool1LUTIn1 = LUTBezier {
                        SplineColor = { Green = 0, Blue = 0, Red = 204, },
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        NameSet = true,
                     },
                     CustomTool1LUTIn2 = LUTBezier {
                        SplineColor = { Green = 204, Blue = 0, Red = 0, },
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        NameSet = true,
                     },
                     CustomTool1LUTIn3 = LUTBezier {
                        SplineColor = { Green = 0, Blue = 204, Red = 0, },
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        NameSet = true,
                     },
                     CustomTool1LUTIn4 = LUTBezier {
                        SplineColor = { Green = 204, Blue = 204, Red = 204, },
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        NameSet = true,
                     },
                  },
               },
               [3] = {
                  Tools = ordered() {
                     CustomTool1 = Custom {
                        Inputs = {
                           LUTIn3 = Input {
                              SourceOp = "CustomTool1LUTIn3",
                              Source = "Value",
                           },
                           LUTIn4 = Input {
                              SourceOp = "CustomTool1LUTIn4",
                              Source = "Value",
                           },
                           Image2 = Input {
                              SourceOp = "ChangeDepth1_1",
                              Source = "Output",
                           },
                           RedExpression = Input { Value = "c1+c2", },
                           GreenExpression = Input { Value = "c1+c2", },
                           LUTIn1 = Input {
                              SourceOp = "CustomTool1LUTIn1",
                              Source = "Value",
                           },
                           Image1 = Input {
                              SourceOp = "TimeSpeed1",
                              Source = "Output",
                           },
                           BlueExpression = Input { Value = "c1+c2", },
                           LUTIn2 = Input {
                              SourceOp = "CustomTool1LUTIn2",
                              Source = "Value",
                           },
                        },
                        CtrlWZoom = false,
                        ViewInfo = OperatorInfo { Pos = { 550, 181.5, }, },
                        CustomData = {
                        },
                     },
                     CustomTool1LUTIn1 = LUTBezier {
                        SplineColor = { Green = 0, Blue = 0, Red = 204, },
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        NameSet = true,
                     },
                     CustomTool1LUTIn2 = LUTBezier {
                        SplineColor = { Green = 204, Blue = 0, Red = 0, },
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        NameSet = true,
                     },
                     CustomTool1LUTIn3 = LUTBezier {
                        SplineColor = { Green = 0, Blue = 204, Red = 0, },
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        NameSet = true,
                     },
                     CustomTool1LUTIn4 = LUTBezier {
                        SplineColor = { Green = 204, Blue = 204, Red = 204, },
                        KeyColorSplines = {
                           [0] = {
                              [0] = { 0, RH = { 0.333333333333333, 0.333333333333333, }, Flags = { Linear = true, }, },
                              [1] = { 1, LH = { 0.666666666666667, 0.666666666666667, }, Flags = { Linear = true, }, },
                           },
                        },
                        NameSet = true,
                     },
                  },
               },
            },
         },
         Inputs = {
            NumberIn1 = Input { Value = 0.98, },
            NumberIn2 = Input { Value = 0.02, },
            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 = "if(r1>n1,1,0)", },
            GreenExpression = Input { Value = "if(r1<n2,1,0)", },
            BlueExpression = Input { Value = "0", },
         },
         ViewInfo = OperatorInfo { Pos = { 605, 346.5, }, },
      },
      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,
      },
   },
   ActiveTool = "CustomTool1",
}


For data in the RGBA channels, you could run Trails on the footage first; that would let you find the maximum and minimum in the entire sequence. I'm not sure how well Trails works with values outside the 0-1 range, though.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com

Return to Fusion

Who is online

Users browsing this forum: Sam976 and 18 guests