MagicDefocus v1.1

This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: Gilles Vink
2d and depth defocus with optical lens effects
13.1, 12.2, 12.1, 12.0, 11.3, 11.2, 11.1, 11.0, 10 or later
Linux, Mac, Windows
02 May 2021

MagicDefocus logo

What is it?

MagicDefocus is an upgraded all-in-one version of the (Z)Defocus node with built in:

  • Catseye
  • Barndoors (cropped bokeh in edges of image)
  • Lens breathing based on the bokeh created (spherical/anamorphic lens)
  • 2D defocus and depth based defocus
  • Easy to use bokeh creation tool, with a default beautiful bokeh
  • And many more


Short demonstration video:

MagicDefocus vimeo thumbnail

Watch the video here


How to install

Copy/move the MagicTools folder into your .nuke installation. Then merge the contents of the file with your file (if you do not have one copy the file provided in the zip). Or add the following line to the existing file:




Lens breathing

Left spherical, right anamorphic (also barndoors)

MagicDefocus lens breathing


MagicDefocus catseye


MagicDefocus barndoors


How to use

It looks very similar to the default Defocus/ZDefocus node, but it has a lot of extra options. All the knobs have a help text when hovering over the knob.

MagicDefocus knobs


User interface

  1. The first tab contains all the main controls for the defocus. The size slider controls the main size of the defocus, as well as the max size when using depth defocus.
    To change to depth defocus, change the method knob to depth.

  2. The second tab is the bokeh creation tool. If you click the preview filter knob, it will give a preview of the bokeh created with the settings. You can also use your own bokeh kernel. To use your own image: set the filter type to image. Lens breathing is linked to the aspect ratio knob in this tab. When using for example 0.5, the breathing will be anamorphic. A value of 1 will make the breathing spherical.
  3. The third tab controls the non-uniform bokeh. Ticking the enable non-uniform checkbox will enable the other options. Hover over the knobs to see what everything exactly does!



Thanks for all the awesome responses!

v1.1 - Includes multiple small fixes;

  • Pixel aspect other than 1 (anamorphic footage) will now output correctly
  • Fix for rendering depth mode on farm (focal plane now set correctly)
  • Fix for image artifacts when using high non-uniform values

v1.0 - Release



If you have any feature requests, questions, feedback or other ideas, feel free to contact me or leave a comment!



Special thanks to Chris Fryer who inspired me with his blogpost about cropping the image into slices, and for his excellent explanation of the amazing timeblur node.

Also thanks to everyone who took the time to look at the node, and gave me feedback!

Please login in order to download these files.


0 # Matthew Thomas 2021-04-29 11:10
Hey, this is a great! One thing I have found is that it is not picking up the pixel aspect of the plate/ project. Currently, if you feed it an anamorphic plate (with the pixel aspect of 2), it spits it out as 1.
0 # Gilles Vink 2021-04-30 08:41
Hi, great to hear that you like it! Thank you for feedback. I am definitely going to take a look at it!
+1 # Gilles Vink 2021-05-02 20:33
Hi again! I just released version 1.1, it should work now!
+2 # Florian Dehmel 2021-04-30 10:05
Nice one! I was looking for a zDefocus with non-uniform bokehs and breathing for quite some time. A nice addition would be a camera-input like pgbokeh or OpticalZDefocus by Jed Smith to incorporate aperture/filmba ck into the correct defocus size.
+1 # Gilles Vink 2021-05-02 20:29
Thank you for your comment! That is a great idea. I will work on an implementation of that feature.
0 # Nicola Borsari 2021-05-01 18:44
A really and interesting tool! If you are patching things up you might wanna find a way to hide the knobs rather than disabling them when toggling between 2d and depth. I've seen a couple of people thinking that this was nukex only because of the greyed out knobs. Furthermore, if you only disable the focal_point knob you can still see the viewer overlay and moving it re-enables the knob.
0 # Gilles Vink 2021-05-02 20:30
Hi! Thank you very much for your feedback! Interesting to hear, I will think about a way to make it easier!
0 # Peter Timberlake 2021-05-08 00:22
Nice work Gilles!
0 # Andrey Sokolov 2021-05-21 17:22
Gj Gilles!
0 # Nandu Dinesan 2022-08-29 06:24
getting kernal error on 12.1v1, the depth is from blender any work around on this?, amazing tool btw
0 # baltazar gnomonich 2023-02-01 10:22
Hi Gilles, this is great tool!!!, using it all the time.
Thanks for sharing!! )))
And found a weird bug on magic defocus, in combination with Oflow retime. When non-uniform bokeh was enabled, somehow magic Defocus was giving incorrect output frames when viewed from retime.
0 # Alex Wood 2023-11-20 17:53
This is an awesome tool Gilles! I ran in to one issue that I wanted to flag with you. Nuke would crash whenever I tried to animate the focal plane. Probably something about the way focal point and focal plane are linked. So as a workaround I just removed the focal point knob and any of the links, and now it's all working. But yeah, maybe there's a way to get animation working with the current setup and tweaking the linking method.

You have no rights to post comments

We have 3232 guests and 155 members online