OpticalZDefocus v1.1


 
This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: Jed Smith
OpticalZDefocus is a physically accurate ZDefocus, which controls circle of confusion (coc) size based on lens geometry using the depth of field equation. Set your lens and film-back characteristics, your focus distance, and adjust the size of your bokeh with the aperture size, just like a real lens.
Requirements:
11.0, 10.5, 10.0, 9.0, 7.1, 7.0 or later
Linux, Mac, Windows
06 May 2018
1295

OpticalZDefocus screenshot

 

OpticalZDefocus is a physically accurate ZDefocus, which controls circle of confusion (coc) size based on lens geometry using the depth of field equation.

Set your lens and film-back characteristics, your focus distance, and adjust the size of your bokeh with the aperture size, just like a real lens.

Features

  • Unpremultiply your depth channel by the selected alpha
  • Sample the z-depth value at a given x/y coordinate
  • Supports multiple depth units: mm, cm, m, dm, inches, feet
  • Automatically snarf lens geometry data from a selected camera node
  • Min z-depth value to avoid long processing times on cg with transparent alphas
  • Fast constant defocus mode which will not calculate depth of field

The latest version will always be here: https://gist.github.com/jedypod/50a3b68f9b5bbe487e1a

There is also a video about depth of field which includes a section about how to use the tool here, for those that are curious: Simulating Physically Accurate Depth of Field

Please login in order to download these files.

Comments   

 
# Warrachat Khamfun 2017-05-28 05:41
Very Nice script :-)
 
 
# Jorge M 2017-06-07 21:49
thanks man ! it's really impressive!
 
 
# Jorge M 2017-06-07 21:59
Do you know if it would be a difference if I use the depth from the deep data and plugin it into your OpticalZdefocus instead of a regular depth ?
 
 
# Jed Smith 2017-08-31 01:36
Sorry for the late reply.

Normally the deep.front and deep.back channels that are output from a DeepToImage or DeepHoldout will work as a depth channel. The distance values will be the same as an unfiltered depth.Z from a lighting render of the same objects, though the edges might vary since these channels represent the front and back samples of the edges of your fg objects.

The OpticalZDefocus tool expects distance in front of camera style z-depth (the "depth" type in the zdefocus node), there is currently no option for 1/z z-depth, though this would be easy to add.

In short it should work! Just need to point the tool to the right channel to use.
 
 
# Rich Bobo 2017-06-21 00:12
Jed,

Holy cow!! I can't even begin to say how *awesome* this is! I have been suffering with Nuke's ZDefocus for so long - and now there's a ZDepth tool that actually works the way it should! Thank you, thank you, thank you! If I ever see you, remind me that I owe you several drinks. I'm serious.

Already added it to our facility's toolset and I've been experimenting with it on a bunch of previous comps of all kinds. Our Head Creative Director even said we should go back and re-render one of our jobs, just so it looks better on our reel!

Thanks a ton,

Rich
 
 
# Jed Smith 2017-08-31 01:39
Thanks Rich, glad it's working well for you :)
 
 
# Rich Bobo 2017-12-04 19:36
Quoting Jed Smith:
Thanks Rich, glad it's working well for you :)


I have a question...

I have noticed that I am getting errors in the Nuke console like this:
ERROR: OpticalZDefocus .Generate_Direc t_Z.scale: Nothing is named "parent.scale"

I see the error inside the Group, I'm just wondering what knob the scale value is supposed to be linked to...? It looks like it is supposed to be linked to a multiplier for the depth values, so you can more easily switch units for the depth range?

Thanks,
Rich
 
 
# Jed Smith 2018-05-25 18:28
Thanks for the bug report, this should be fixed now with v1.1
 
 
# Mohamed Selim 2017-09-29 18:12
I was just thinking of attempting this. Thank you! Works great and gives very similar results to the pgBokeh plugin.
 
 
# Marvin Sprengel 2018-03-04 16:37
mhh it seems it doesn't repeat the edges for me. Not around Objects but around the whole Frame. Am i doing something wrong?
besides that great Gizmo!!
 
 
# Jed Smith 2018-03-15 03:12
Hey Marvin,
I would have to see an example to be able to help, but I would start by checking the values in your z-depth. Are they unpremultiplied ? Are there black or inf values? The ZDefocus node can do some weird stuff when driven in direct mode like this tool has to do as well... especially if there are fg objects over distant background objects.
 
 
# Vincent Langer 2018-03-14 15:24
really cool tool - thank you very much

GOOO MATH!!!!
 
 
# Jed Smith 2018-03-15 03:10
Thanks!
I won't mention how long it took me to solve the equation for coc size :P
 
 
# eden an 2018-05-08 09:23
Thank you for your ability!
I've already used this awesome gizmo.

What is different from the previous version v1.0?
 
 
# Jed Smith 2018-05-25 18:27
Hey Eden, thank you. Not much is changed, just some bug fixes and the ability to use a camera input to get focal length and haperture.
 
 
# Caroline Voglaire 2018-05-25 15:24
Seems really a nice one!
Easier and faster (and cheaper ;-)) than PGBokeh!

But I get an error message copying the gizmos :
_ZDEFOCUS_.legacy_resize_mode: no such knob
_ZDEFOCUS_.false: no such knob
_ZDEFOCUS_.show_legacy_resize_mode: no such knob
_ZDEFOCUS_.false: no such knob

In the other hand, I'm facing a concrete issue. After dealing with camera settings, focus distance etc... It seems to work really well (even with deep data rather than zdepth), but my supposed focused area is still a bit blurred. Actually, nothing is completely focused in the frame.
Do you have any idea of what is going on?
Do you thing that could be caused by the fact I am on Nuke 8.5?
That would be awesome if you could find something. That would help me a lot.
 
 
# Jed Smith 2018-05-25 18:26
Hey Caroline,
It looks like the legacy_resize_m ode and show_legacy_resize_m ode knobs were added after Nuke 9, and since this gizmo was created in Nuke 11, that's why they are showing up. Everything should still work as expected if you ignore this error message though.

I would have to see your setup to understand the problem you are describing. I would be happy to take a look if you want to send it over.

The ZDefocus will convolve every pixel in the image, so even if it is in perfect focus the pixel will be softened slightly. This is normal. But if you are seeing something different maybe something else is going on.
 
 
# Caroline Voglaire 2018-05-28 08:40
Thanks!
It's a bit more than just softened. It's really blurred.
I am setting up the pipe for a CG tv Show for kids, and i'm pretty sure the director won't allow too much soften on his characters.
I surely can send you my set up for you to take a look. How can we do that? Since it's a "in progress" production, I can't put images here obviously!
 
 
# Jed Smith 2018-05-29 01:34
I'll send you pm on linkedin.
 

You have no rights to post comments

We have 2339 guests and 70 members online