Nuke Ramped Defocus

If I have an image in nuke that I want to control the falloff of the depth of field, ordinarily I would pump a ramp into the mask input of defocus. However, this would only work if I want my defocus to start at 0 and move to some value. If, however, I want the smallest amount of defocus to be something other than 0, say 2, I can’t achieve this effect with a good result, even if I adjust the start value of my mask input (instead of ramping from 0-1, say .2-1). If I input this ramp into the mask input on a defocus, this is the result:

maskedDefocus

Instead of moving from a 2 defocus to a 10 defocus, instead I get the original un-blurred result, with the 10 defocus merged on top of it at 20%, creating a halo.

With a few merges and two defocuses instead, I can get a much better result:

rampedDefocus

So I grouped this little setup and posted it here. Simply add a gradient map into the ramp input, 0-1, and set your minimum blur and maximum blur values, and you’ll get a much smoother result.

Download:

rampedDefocus
tested on Nuke 9.0v4

Leave a Reply

Post Navigation