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
11.0, 10.5, 10.0, 9.0, 7.1, 7.0 or later
Linux, Mac, Windows
06 May 2018
6567
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
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.
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
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
besides that great Gizmo!!
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.
GOOO MATH!!!!
I won't mention how long it took me to solve the equation for coc size
I've already used this awesome gizmo.
What is different from the previous version v1.0?
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.
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.
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!
In case anyone has this issue the sharpness was fixed for me by switching the filter type to "disc" or "image", I had it set to bladed which didn't look like anything was in focus.
Just one issue for me - it doesn't seem to defocus the alpha, even with all settings as you'd expect. has anyone come across this / any troubleshooting tips ?
Cheers!
Ben
Just one issue for me - it doesn't seem to defocus the alpha, even with all settings as you'd expect. has anyone come across this / any troubleshooting tips ?
Cheers!
Ben
Thnaks in advance"
Thnaks in advance"
The fix you did looks great!
Possbile you could provide the expressions you adjusted to get this to work? I'm not clear on what you edited.
Thanks!
I can't get it to work properly.
Screenshot:
https://www.dropbox.com/s/ppxqum94rig5clj/Screenshot%202023-05-07%20at%2019.24.27.png?dl=0
RSS feed for comments to this post