August 2019

B_deep_toolset: a Deep Comp Survival Kit

tl;dr: a very useful deep compositing toolkit you probably want to use.

Working with Deep is super cool, but can also be very, very slow. Luckily, with the inestimable help of Python,  there are different strategies we can use to leverage the power of Deep Comping without compromising our script responsiveness and our own productivity. Here’s how:
installation guide

So first things first, let´s place the Python script where it can be reached so that we can actually use the tools.

Distribute the code

Download the script from the link below and save it as a Python file called "b_deeptoolset.py" where Nuke can find it. In other words, place it within the Nuke Plugin Path. For more info, read my previous posts or Google it, there are tons of tutorials on how to do this.

code
Download File

Additionally (although very much encouraged) download and install the "dDot" Python module available in Nukepedia. Please note that I have included a few (but not all) unmodified functions from this module inside my "b_deeptoolset.py" so that you can still use the ''Autocomp'' feature even if you don´t have installed "dDot".  Needless to say, All dDot's related functionality credit goes to its creator Daniel Bartha.

Edit the menu.py file

Now we have the "b_deeptoolset.py" Python module where Nuke can find it, we´re gonna import it by adding the following line to our menu.py :

import b_deeptooset


Save the menu.py and restart Nuke.

2 - Try it

You'll notice that there are a couple of new menus on your menu bar, namely: "b_deeptoolset" and "dDot". If this is the case, congratulations, we are ready to start using the Toolkit. Otherwise please make sure the Python script is saved where Nuke can find it, and that is named with exactly the same name you are using to import it from your ''menu.py''.

DEEP HOLDOUTS
One of the coolest things about Deep is that it allows for volumetric out-holding between our CG elements, as we all know. The problem is that the amount of data needed to achieve this oftentimes is massive, rendering our scripts very sluggish.
The solution is to create and pre-comp a set of mattes to holdout the CG elements with each other in 2d, thus allowing for regular 2d merge as though they were combined in Deep.

user guide

  • 1 - Make sure each CG element and its Deep Data is connected to the corresponding inputs of a DeepRecolor node.
  • 2 - Make sure each DeepRecolor node has the target input alpha checked, and channels set to all.
  • 3 - Make sure the regular 2d element is on the left-hand side and the DeepRead on the right. Also, it's gonna look better with a dot creating a right angle between the DeepRecolor and the regular 2d element. Like so:

  • 4 - To make it Autocomp ready, please drop a couple of dDot nodes, as shown above, named according to the following convention. To drop the dDots, either use the hotkey "Shift+." or go to the "dDot" menu and run the "dDotParent" tool. A little Nuke Panel will pop up for you to input the name. Once done that, just click OK and a new dDot node will be created.
  •     4.1 - For the regular 2d input name, please use any alphanumeric string. It may be as long as you need and could use camel case in case you want to include several words. Please avoid empty spaces or underscores. For instance, all these would be valid names:
  • "road",
  • "2dRoadCam1"
  • "whatEverYouWantAsLongAsItIsInOneWordWithNoSpacesOrUnderScores1212"
  •     4.2 - For the deep input, just add a "_deep" trailing to the former name. For instance:
  • "road_deep".
  •     4.3 - Please note that if you don't drop dDots there, everything will still work fine, just without the Autocomp feature. And by the way, the dDots are just regular Dot Nodes with an additional hidden Knob that allows for smart linking and that type of stuff. They won't cause any trouble otherwise!
  • 5 - Voila, select all your DeepRecolor (and only DeepRecolor ) nodes and click on the "create_holdouts" button. If everything goes fine, this is what you'll get:

A full set of holdouts to stencil your CG elements with each other :)
6 - Now you'll notice there is a Write node for each element, connected to a Switch node. It is a very good idea to prerender your holdouts, import and connect them to the Switch node´s 1 input and switch to 1. We are done here.
By the way, one last thing, I'd use this convention for the Holdout pre-comp output:  <elementname_holdout>. For instance: "road_holdout".
AUTO COMP

Having obediently complied with above's procedure, and provided you chose to drop the dDots using the hotkey or the dDot menu as suggested, now you can auto comp all your CG elements together in literally less than a second just by clicking a button.

Instructions
1 - At the end of each Holdout setup there's a dot node automatically named according to the <elementname_holdout_version> rule. For instance: "road_holdout_0", "cones_holdout_0" etc...

2 - You will notice that, after creating the Holdout setup, all these dots are automatically selected. Now with the "b_deeptoolset" still open, just click on "Autocomp".
3 - Voila, a working auto comp of all your elements held out witch each other and disjoint-over merged together, in less than one second!!
4 - Now, If you reveal hidden connections (alt+a), you'll see that each Dot in your auto comp is connected to each CG element and its corresponding holdout, which is used as a mask for a "Multiply" node that multiplies by 0.
DEEP_UBERPASS

Sometimes, you will get a bunch of different CG elements with deep data that you would rather want to have combined in one big ass pass.

What the Uberpass tool does is precisely combining all your CG elements and its AOVS, on the one hand, and all the deep data, on the other.

This way you will still have all the sweetness of working with deep but with a reduced amount of complexity and overhead.

Instructions

1 - Select all your DeepRecolor (and only DeepRecolor ) nodes, launch the tool, and click on the "uberpass" button.

2 - As you see, there are two DeepMerge setups: one for rendering out all the combined color together with all the AOVS, and the other to DeepWrite out the combined deep data.

3 - Render those out and bring them back in the comp. Now you should have a combined color input with all AOVS and a new DeepRead node reading all combined deep data. Just connect them together with a DeepRecolor node and you are good to go.

DEPTH_FROM_DEEP
This tool is going to extract a clean depth pass from the deep data for later use in the comp along with your favorite z-defocus tool, for creating fog effects, for grading, you name it.
Instructions
1 - Select all your deepRecolor nodes and click on the "deep2depth" button. In less than a second, you should see a setup by the end of which you'll have an adequately processed depth channel ready to be pre-comped and used. IMPORTANT NOTE:  If you wanted to create both the Holdouts and the Deep2Depth setups, you need to create FIRST the Deep2Depth and then the Holdouts, otherwise the tool will make a mess and will fail. I will try to fix this bug in the next iteration!!
2 - By the way, notice how the tool has created a new set of DeepRecolor nodes, colored in pink. This is because, for the depth to be correct, we need a new set of DeepRecolor nodes with the "target input alpha"  NOT checked (as opposed to how it needs to be for the Holdouts setup). Otherwise, you'd have weird edge problems.
3 - Also, take a look at the Expression node's alpha channel expression: "Zdepth.red == 0 ? 15000 : Zdepth.red". Feel free to set up your 0 alpha value as convenient for your shot. By default is set to 15.000 units.

4 - Finally, just pre-comp it and use it where needed in the comp

Read more →