Create a ticket
Follow

How to render multiple Switch inputs using a single Write node.

SUMMARY

This article explains how to use a Switch node in conjunction with a single Write node to output different results within a Nuke script. 

The Switch node serves the purpose of alternating between various inputs. When used as an input to a Write node, it can allow the script to render multiple results by using frames to call individual inputs.

MORE INFORMATION

An expression can be used in the “which” knob of the Switch node that sorts the frames for each input available, as illustrated in the example below. 

This script may be useful for outputting multiple results from a script to be rendered at one time. For example, let’s say that there are 3 images appearing too fast in a sequence. You can use this Switch node process to increase the number of frames for the images, thereby altering the speed of the sequence by adding more frames to slow it down.

Example: 

Rendering 3 inputs with 10 frames each on a single Switch: 

  1. In the Node Graph, create a Switch node.
  2. Add 3 Constant nodes.
  3. Change the color values for each node as Red, Green, and Blue, as seen below. 

  1. Connect the Constant nodes to the inputs of the Switch node. These should now appear connected as (Red - 0, Green - 1, Blue - 2) respectively.

  1. Double-click the Switch node to open the Properties Bin.
  2. Right-click the “which” knob and select Add expression...
  3. Add the following code to the Expression field and press OK to confirm: root.frame()%30/10  



  4. Add a Write node and connect it to the Switch node.
  5. Open the Properties Bin of the Write node, and set the file path to render files in a specified directory.
  6. Click Render and view the render prompt.
  7. Set the frame range as 0-29, and click OK to begin rendering.
  8. View the output folder and observe the images created.

With the above rendering, there should be an output of 3 colors with 10 frames each from a single Write node, as seen in the following screenshot:

     


ADDITIONAL NOTES: 

  • You can use this process for rendering multiple inputs at once, sorting frames by the expression in the “which” field of the Switch. From my example above, the expression of root.frames()%30/10 can be extended for however many inputs are accessible. You may also use the expression frame%30/10 to achieve the same results.

  • If you only want 1 frame per render, than you would use an expression such as: root.frames()%3 per 3 inputs. Additionally, if you wanted 3 frames per render, than the expression root.frames()%9/3 could be used.

NOTE: The expression %3 would change with each input to be relative to the maximum amount of inputs available. (i.e %4 using 4 inputs, %5 for 5, etc.) Please view the Further Reading section below for more information regarding the expression with the percent symbol used as modulus math.


FURTHER READING 

To view more information about the Switch node, please visit the Documentation for the Switch parameters.

 Please view this document on expressions to read about how expressions work.

 Additional information regarding the expression with modulus math (%3) can be found here: https://en.wikipedia.org/wiki/Modulo_operation


 
Keywords: Switch, nodes, input, frames, render, which, Nuke, nuke, colour

Was this article helpful?
/

We're sorry to hear that!

Please tell us why.
0 out of 0 found this helpful

Comments