Showing posts with label NukeX Tutorials. Show all posts
Showing posts with label NukeX Tutorials. Show all posts

Sunday, June 2, 2013

How to create a position pass in Nuke 7 using the DepthToPosition node

The DepthToPosition node is used to generate 2D position pass using the depth data available in the input image. The position pass is created by projecting the depth through camera. Then, position of each projected point is saved. This node along with the PositionToPoints node is used to create a point cloud similar to the point cloud that the DepthToPoints node generates. In fact, the DepthToPoints node is a gizmo that contains the DepthToPosition and DepthToPoints nodes. In this tutorial, we will generate a position pass and then place a 3D sphere in the scene. To do this, follow these steps.

Step - 1
Navigate to the following link and then download the zip file to your hard-drive: https://www.dropbox.com/s/xo7eemr6qz16icl/nt007.zip. Next, extract the content of the zip file.

Step - 2
Using a Read node, bring in the nt007.rar; the Read1 node will be inserted in the Node Graph panel.

Step - 3
Connect the Read1 node to the Viewer1 node by selecting the Read1 node and then pressing 1, refer to Figure 1.

Saturday, June 1, 2013

How to render position pass in Maya and then use it with the PositionToPoints node

The PositionToPoints node is used to generate a 3D point cloud using the position data contained in the image. In this tutorial, we will first create a position render pass in Maya 2014 and then we will create a 3D point cloud using the position data in Nuke. Then, we will composite a 3D object in our scene with help of the 3D point cloud. Lets get started:

Step - 1
Create a project folder in Maya and open the scene that you need to render. Next, create a camera and set the camera angle. Figure 1 displays the scene that we will render.
Figure 1
We will be rendering a 32 bit image so first we set frame buffer to 32 bit.

Step - 2
Invoke the Render Settings window and then select mental ray from the Render Using drop-down list.

Step - 3
Now, choose the Quality tab and then enter 1.5 in the Quality edit box.

Step - 4
Scroll down to Framebuffer area in the Quality tab and then select RGBA (Float) 4x32 Bit from the Data Type drop-down list.

Next, you will create layers in Layer Editor and create layer overrides.

Step - 5
Select everything in the viewport and then choose the Render tab in Layer Editor. Next, choose the Create new layer and assign selected objects button from Layer Editor, refer to Figure 2; the layer1 layer will be created in Layer Editor.

Wednesday, May 29, 2013

Working with the ZDefocus node in Nuke 7 Part - 1

The ZDefocus node is a major upgrade to the ZBlur node. The ZDefous node is used to blur an image according to the depth map channel and gives you ability to simulate blur using depth of field. This node splits the input image into layers. All pixels have the same depth value within a layer. Also, the whole layer receives same amount of blur size. After processing all the layers present in the input image, the ZDefocus blends layers together from back to the font of the image thus preserving the order of the elements in the scene.

To add a ZDefocus node to the Node Graph panel, select the input image that you need to blur and then choose the Filter button to display the Filter menu. Next, choose ZDefocus from the menu; the ZDefocus# node will be inserted in the Node Graph panel. Also, The ZDefocus# node properties panel will be displayed with the ZDefocus tab chosen in the Properties Bin, refer to Figure 1.
art21-1
Figure 1
You notice in the Node Graph panel that the apart from the regular mask and Output connectors, the ZDefocus# node has two more input connectors: filter and image. These are discussed next:

filter: This image connected to this input takes the shape of the out of focus highlights. These highlights are also referred to as “Bokeh”. You can use a Roto or Flare node to create the filter image. If you want to add color fringing to Bokeh, you can use also connect a color image to the filter input.

image: This input is used to connect to to the input image that you want to blur. Make sure that this image contains a depth channel.

You will also notice a focal point widget in the Viewer# panel. This widget is used to adjust the position of the focal plane. On moving this widget, the focus plane and focal point parameters update automatically. If you select the Use GPU if available check box in the node properties panel, the processing of the node is run on the GPU instead of CPU. If GPU is present in the scene, its name will be displayed above the check box, refer to Figure art21-1. You can also select which GPU you need to use. To do so, open the Preferences dialog box by pressing SHIFT+S and then choose the desired option from the GPU Device drop-down of the GPU Device area, refer to Figure 2.
art21-2
Figure 2
Before moving farther, navigate to http://www.mediafire.com/download/lpbg7sv7lf7hlz2/art021.zip and download the zip file. Next, extract the contents of the zip file to your hard drive. The zip file contains the chopper.exr file which we will used to explain the concepts here.

Step – 1
Lunch Nuke and start a new script in it.

Step – 2
Load the chopper.exr file into the script; the Read1 node will be inserted in the Node Graph panel.

Step – 3
Make sure the Read1 node is selected and then press 1 to view its output in the Viewer1 panel, refer to Figure 3.

Step – 4
Select Z_Depth from the Channel Sets drop-down; the depth channel will be displayed in the Viewer1 panel, refer to Figure 4. Now, select rgba from the Channel Sets drop-down.
art21-3
Figure 3
art21-4
Figure 4
Step – 5
Connect a ZDefocus node to the Read1 node. You will notice an error message in the Viewer1 panel about the missing depth channel. This error is generated because by default the ZDefocus node looks for depth information in the depth.z channel which is selected by default in the depth channel drop-down.

Step – 6
Select Z_Depth.red from the depth channel drop-down; you will notice blur in the Viewer1 panel, refer to Figure 5.

The options in the channels drop-down located above the depth channel drop-down are used to select channels on which the blur will be applied.

Step – 7
In the Viewer1 panel, move the focal point widget to the front part of the chopper; the area around the point will be in focus immediately, refer to Figure 6.
art21-5
Figure 5
art21-6
Figure 6
Step – 8
Select depth from the math drop-down.

The options in math drop-down are used to specify the method that will be used to calculate the distance between the camera and the object using the information available in the depth channel. If you hove the mouse pointer over the math drop-down, a tooltip will appear with information about the formula used to calculate the blur. By default, the far=0 option is selected in this drop-down. This option is compatible with the depth maps generated using Nuke and RenderMan.

Step – 9
Enter 0.1, 8, and 10 in the depth of field, size, and maximum fields, respectively.

The depth of field parameter is used to specify the depth of field around the focus plane. The size parameter is used to set the size of the blur. The size of the blur is clipped at the value specified using the maximum parameter. The blur inside check box located next to the depth of field parameter is used to apply a small amount to the in focus area so that the transition between the in focus and out of focus areas look smooth.

Step – 10
Select the focal plane setup from the output drop-down; the depth of field information will be displayed in the rgb channels in the Viewer1 panel. Move the focal point to see the output properly, refer to Figure 7.

The red color represents the area (less than DOF) that is in focus. The green color represents the area that is inside DOF. If depth of parameter is set to 0, you wont be able to see green area in the viewport. The blue color represents the area that is greater than DOF.

Step – 11
Select the layer setup option from the output drop-down.

This option is similar to the focal plane setup option but it displays the DOF information after the depth is divided into layers, refer to Figure 8. When the automatic layer spacing check box is selected, the ZDefocus node automatically decides how many depth layers to be used based on the value specified by the maximum parameter. When you clear this check box, you can use the depth layers and layer curve parameters to control the numbers of layers and spacing between the layers, respectively.
art21-7
Figure 7
art21-8
Figure 8
Now, experiment with the controls in the ZDefous1 node properties panel until you get the desired result. Also, use the focal point widget in the Viewer1 panel to interactively change the focus point.

This concludes the part – 1.

Read Part - 2 here.

Tuesday, May 28, 2013

How to use Unpremult and Premult nodes in Nuke 7

In this tutorial, you will learn about the premultiplication and when to use it in your composition. When you composite CGI images, you must be aware of premultiplied vs unpremultiplies images otherwise some artifacts can appear such as dark edges around the composited CGI object. Also, some edge artifacts may appear after the color correction. Most the rendered images that modern day 3D applications produce are premultiplied. In such images,the RGB channel is already multiplied by the its alpha channel. Therefore, it should not be multiplied again while compositing it in post. If you are composting a CGI image having semi-transparent alpha pixels, all color pixels will be scaled down and thus become darker. While applying color-correction on a premultimplied image, you might get artifacts where semi-transparent areas exist in the image. To overcome this problem, you should first apply an unpremultiply operation and then premultiply the image again after color-correction. In Nuke, the Permult node is used to premultiply the input image. This node multiplies the rgb channels of the input image with its alpha channel. An input image that is not premultiplied is referred to as straight or unpremultiplied. If the black areas in the alpha channel are not black in the color channels, then the image is considered as straight. The Unpremult node is used to divide the rgb channels of the input image by its alpha. Lets first start with how the Multiply operation of the Merge node works in Nuke.

Step - 1
Navigate to the following link http://www.mediafire.com/download/ubzwukea7cql8w7/nt005.zip and download the zip file. Next, extract the butterfly.jpg and jet.tif from the zip file to your hard drive.

Step - 2 
Start Nuke and then create a new script by choosing File > New from the menu bar.

Step - 3
Hover the cursor over the Node Graph panel and press S; the Project Settings panel will be displayed in the Properties Bin. Make sure the Root tab is chosen and then select NTSC_16:9 720x486 1.21 from the full size format drop-down.

Next, you will import images to the script.

Step - 4
Choose the Image button from the Nodes toolbar; the Image menu will be displayed. Next, choose Read from this menu; the Read File(s) dialog box will be displayed. In this dialog box, navigate to the location where you have saved the butterfly.jpg and then choose the Open button; the Read1 node will be inserted in the Node Graph panel.

Step - 5
Make sure the Read1 node selected in the Node Graph panel and then press 1 to view the output of the Read1 node in the Viewer1 panel, as shown in Figure 1.
Figure tu5-1 The output of the Read1 node
Figure 1 The output of the Read1 node
Step - 6
Choose the Transform button from the Nodes toolbar; the Transform menu is displayed. Next, choose Reformat from this menu; the Reformat1 node will be added to the Node Graph panel and a connection will be established between the Read1 and Reformat1 nodes.

Step - 7
Select the Reformat1 node in the Node Graph panel and then add Transform node from the Transform menu; the Transform1 node will be inserted between the Reformat1 and Viewer1 nodes.  In the Transform tab of the Transform1 node properties panel, enter 90 in the rotate field and 0.56 in the b field; the output of the Transform1 node will be displayed in the Viewer1 panel, as shown in Figure 2.
Figure tu5-2  The output of the Transform1 node
Figure 2  The output of the Transform1 node
Step - 8
Click on the empty area of the Node Graph panel and then choose the Draw button from the Nodes toolbar; the Draw menu will be displayed. Next, choose Radial from this menu; the Radial1 node will be added to the Node Graph panel.

Step - 9
Press 1; the output of the Radial1 node will be displayed in the Viewer1 panel. Next, adjust the shape of radial ramp, as shown in Figure 3.
The radial ramp
Figure 3 The radial ramp
Step - 10
Make sure the Radial1 node is selected in the Node Graph panel and then connect a Multiply node with the Radial1 node; the input A of the Multiply node will be connected to the Radial1 node.

Step - 11
Drag-drop the Multiply node on the pipe connecting the Transform1 and Viewer1 nodes; the input B of the Multiply node will be connected with the Transform1 node.

Notice the result of the multiply operation in the Viewer1 panel. The result of the Transform1 node is gradually appearing darker from center to the edge of the frame. Next, you will use the Premult node. First, combine the RGB and alpha channels using a Copy node.

Step - 12
Delete the Multiply node from the Node Graph panel and then select the Radial1 node. Next, press K; the Copy1 node will be inserted in the Node Graph panel and the input A will be connected with the Radial1 node. Click-drag the input B of the Copy1 node to the Tranform1 node; a connection is established between the Copy1 and Transform1 nodes.

Step - 13
Make sure the Copy1 node is selected in the Node Graph panel and then press 1 to view the output in the Viewer1 panel.

Step - 14
Make sure the Copy1 node is selected in the Node Graph panel and then connect a Premult node to it from the Merge menu; the Premult1 node will added to the Node Graph panel.

You will notice in the Viewer1 panel that we the output is exactly same as that of the Multiply node. Figure 4 shows the node network in the Node Graph panel.
Figure tu5-4 The node network in the Node Graph panel
Figure 4 The node network in the Node Graph panel
Next, you will learn the workflow while color-correcting a premultiplied image.

Step - 15
Choose File > New from the menu bar to create a new script.

Step - 16
Load the jet.jpg image in the script; the Read1 node will be inserted in the Node Graph panel.

Step - 17
Add a Checkerboad node to the Node Graph panel; the Checkerboard1 node will be inserted in the Node Graph panel.

Step - 18
Select the Read1 node in the Node Graph panel and then press M; the Merge1 node will be inserted in the Node Graph panel.

Step - 19
Click-drag the input B of the Merge1 node and then drag the cursor to the Checkerboard1 node; a connection is established between the Merge1 and Checkerboard1 nodes.

Step - 20
Select the Merge1 node in the Node Graph panel and then press 1 to view the output of the Merge1 node in the Viewer1 panel, as shown in Figure 5.
Figure tu5-5  The output of the Merge1 node
Figure 5  The output of the Merge1 node

Step - 21
Select the Read1 node in the Node Graph panel and then insert an Add node between Read1 and Merge1 nodes.

Step - 22
In the Add tab of the Add1 node properties panel, select rgb from the channels drop-down and then specify a color value for the value parameter. You will notice that the adjustment is affecting whole image, refer to Figure 6. To overcome this, you need to first unpremultiply the result of the Read1 node and then premultily the output of the Add1 node.
Figure tu5-6  The affect of color correction
Figure 6  The affect of color correction
Step - 23
Select the Read1 node in the Node Graph panel and then insert a Unpremult1 node between the Read1 and Add1 nodes.

Step - 24
Insert a Premult1 node after Add1 node. Now, make color adjustments using the Add1 node. You will notice that the color-correction is now applied to the jet properly. Figure 7 shows the node network.
Figure tu5-7  The node network in the Node Graph panel
Figure 7  The node network in the Node Graph panel



Sunday, May 26, 2013

Basic composting in Nuke 7

The compositing of images implies combining multiple images to create a single seamless image. In this tutorial, we will create a simple composite using the Read and Merge Nodes. The nodes in the merge category are used to composite two or more images. Before we dive into the tutorial, lets first understand how the Merge, Premult, and Unpremult nodes work.

MERGE NODE
The Merge node combines two input images based on the transparency (alpha channel) using various algorithms. The alpha channel is used to determine which pixels of the foreground image will be used for the composite. This node takes three inputs: A, B, and mask. The A input is used to connect foreground image to the Merge node. This image merges with the image that is connected to the B input. When you connect an image to the A input of the Merge node, an additional A input will be displayed on it, refer to Figure 1.
Additional input A displayed on the Merge1 node
Figure 1 Additional input A displayed on the Merge1 node
 Each input is named in the order it was connected with other nodes, A1, A2, A3, and so on. It means that you can connect as many images as you need on the A side of a Merge node. NukeX copies data from the A input to the B input. If you disconnect the node connected to the A input, the data stream will still flow down as NukeX will use the B input. The mask input is used to connect a node to use as a mask.

The Merge node connects multiple images using various algorithms such as multiply, overlay, screen, and so on. To add a Merge node to the workspace, press the M key; the Merge# node will be inserted in the Node Graph panel and its properties panel will be displayed with the Merge tab chosen in the Properties Bin, refer to Figure 2. The options available in the Merge tab of the Merge# node properties panel are discussed next.
The Merge# node properties panel
Figure 2 The Merge# node properties panel
operation
The options in the operation drop-down are used to set the algorithm to be used for merging the images. By default, the over algorithm is selected in this drop-down. It layers the image sequence connected to the A input over the image sequence connected to the B input according to the alpha channel present in the A input.
Tip: To see the math formula for a particular merge algorithm, place the cursor over the operation drop-down; a tooltip will be displayed. This tooltip contains the information about the mathematics behind a merge operation.
When the Video colorspace check box located next to the operation drop-down is selected, NukeX converts all colors to the default 8-bit colorspace before compositing and then outputs them in linear colorspace. You can change the default colorspace for 8-bit files from the Project Settings panel. To do so, hover the mouse over the workspace and then press S; the Project Settings panel will be displayed. In this panel, choose the LUT tab; the Default LUT settings area will be displayed. Next, select the desired option from the 8-bit files drop-down, refer to Figure 3.
Partial view of the LUT tab of the Project Settings panel
Figure 3  Partial view of the LUT tab of the Project Settings panel
On selecting the alpha masking check box located next to the Video colorspace check box, the image is processed according to the PDF/SVG spec. According to this spec, that the input image remains unchanged if the other composited image has zero alpha. The calculation applied to the alpha will be according to the following formula: a+b-a*b. If this check box is cleared, the formula applied to alpha will be same as that applies to other channels.
Note: This check box will be disabled when it does not affect the operation selected from the operation drop-down or PDF/SVG.
set bbox to
The options in this drop-down are used to set the bounding box. The bounding box defines the area of the frame that is having valid image data. It is used to speed up the processing. By default, full image area is the bounding box of the input image but if you crop a particular input, the bounding box will be reduced to the cropped area. The default option in this drop-down is union, the other three are: intersection, A, and B. These options are discussed next.

union
The union option combines the two bounding boxes from the A and B inputs. It resizes the output bounding box to fit the two input bounding boxes completely.

intersection
When you select the intersection option, the output bounding box will be the overlapping area of the two input bounding boxes.

A
Select the A option to use the bounding box from the A input.

B
Select the B option to use the bounding box from the B input.

metadata from
The options in this drop-down are used to specify the node whose metadeta will flow down the process tree.

A channels
The options in the first A channels drop-down are used to specify which channels from the A input will be merged with the B input. The options in the second A channels drop-down are used to specify additional channel (alpha) to be merged with the B input. If you select none from the first A channels drop-down, the output of the A input will be black or zero. You can select check boxes on the right of the first A channels drop-down to select individual channels.

B channels
The options in the first B channels drop-down are used to specify which channels from the B input will be merged with the A input. The options in the second B channels drop-down are used to specify additional channel (alpha) to be merged with the A input. You can select the check boxes on the right of the first B channels drop-down to select individual channels.

output
The options in the first output drop-down are used to specify the output channels after the merge operation. The options in the second output drop-down are used to specify an additional output channel (alpha) after the merge operation. You can select the check boxes on the right of the first output drop-down to select individual channels.
Note: There are four check boxes on the right of the A channels, B channels, and output drop-downs, namely red, green, blue, and Enable channel, refer to Figure 4. You can use these check boxes to keep or remove the channels from the merge calculations, as required. When the Enable channel check box is selected, the channels selected from the drop-down placed on the right of this check box are enabled. This check box is available in the properties panels of many nodes.
Figure 4 The Enable channel check boxes displayed in the Merge1 properties panel
also merge
The options in the first also merge drop-down are used to specify the channels that will be merged in addition to the channels specified from the A channels and B channels drop-downs. The options in the second also merge drop-down are used to specify the additional channel (alpha) to be merged. You can select the check boxes on the right of the first also merge drop-down to select individual channels. These check boxes appear when you select option other than none in the first also merge drop-down.

mask
The Enable channel check box located on the left of the mask drop-down is selected when you connect a mask to the mask input of the Merge node or select a channel from the mask drop-down. The options in this drop-down are used to select the channel that will be used as mask. When the inject check box is selected, NukeX copies the mask input to the predefined mask.a channel. The injected mask can be further used downstream in the process tree. By default, the merge is limited to the non-black areas of the mask. When you select the invert check box, the mask channel will be inverted and now merge will be limited to the non-white areas of the mask. The fringe check box is used to blur the edges of the mask.

mix
The mix parameter is used to blend the two merged inputs. When the value of this parameter is set to 0, only the B input will be displayed in the Viewer# panel. The full merge will be displayed when the value for this parameter is set to 1 which is the default value.

PREMULT NODE
The Permult node is used to premultiply the input image. This node multiplies the rgb channels of the input image with its alpha channel. The alpha channel is used to determine which pixels of the foreground input image will be visible in the final composite. An input image that is not premultiplied is referred to as straight or unpremultiplied. If the black areas in the alpha channel are not black in the color channels, then the image is considered as Straight. Generally, most 3D rendered images are premultiplied. The Merge node expects premultiplied images so you should use the Premult node before any merge operation if input image is not premultiplied. This helps in removing artifacts such as fringes around a masked object. While color-correcting a premultiplied image, you should first connect an Unpremult node to the image and then perform color-correction. Next, connect a Premult node to get back to original premultiplied state for the merge operations. To add a Premult node to the Node Graph panel, select Premult from the Merge menu of the Nodes toolbar; the Premult# node will be inserted in the Node Graph panel and its properties panel will be displayed with the Premult tab chosen in the Properties Bin, refer to Figure 5. The options available in the Premult tab of the Premult# node properties panel are discussed next.
The Premult1 node properties panel
Figure 5 The Premult1 node properties panel
multiply
The options in the first multiply drop-down are used to set the channels (generally rgb) to be multiplied with the alpha channel. To select the individual channels, you can select the check boxes available on the right of the multiply drop-down. The options in the second multiply drop-down are used to set the additional channel to be multiplied with the alpha channel.

by
If you select the Enable channel check box located on the left of the by drop-down, the channel set in it (generally alpha) is multiplied with the channels set using the multiply drop-downs. The invert check box is used to invert the output of the alpha channel.

UNPREMULT NODE
The Unpremult node is used to divide the rgb channels of the input image by its alpha. To add a Unpremult node to the Node Graph panel, select Unpremult from the Merge menu; the Unpremult# node will be inserted in the Node Graph panel and its properties panel will be displayed with the Unpremult tab in the Properties Bin, refer to Figure 6. The options available in the Unpremult tab of the Unpremult# node properties panel are discussed next.
Figure 6  The Unpremult1 node properties panel
divide
The options in the first divide drop-down are used to set the channels (generally rgb) to be divided with the alpha channel. To select the individual channels, you can select the check boxes available on the right of the divide drop-down. The options in the second divide drop-down are used to set an additional channel to be divided with the alpha channel. The function of the by and invert check boxes is same as discussed in the Premult node.

TUTORIAL
In this tutorial, we will create a simple composite using the sunset.jpg, tree.png, and man stading.png files. Figure 7, 8, 9, and 10 display the sunset.jpg, tree.png, man standing.png, and the final output, respectively.
Figure 7 The sunset.jpg image
Figure 8 The tree.png image
Figure 9  The standing man.png image
Figure 10 The final composite
Step - 1
In your browser, navigate to http://www.sxc.hu/photo/1252649; a image will be displayed. Next, download and save the image with the name sunset.jpg to your hard drive.

Step - 2
Navigate to the following link http://www.mediafire.com/download/ob9on43alamlk0l/nt004.zip and download the zip file which contains the png files. Next, extract the content of the zip file to the location where you have saved the sunset.jpg.

Step - 3
Start Nuke and then create a new script by choosing File > New from the menu bar.

Step - 4
Hover the cursor over the Node Graph panel and press S; the Project Settings panel is displayed in the Properties Bin. Make sure the Root tab is chosen in it and then select NTSC_16:9 720x486 1.21 from the full size format drop-down.

Next, you will import images to the script.

Step - 5
Choose the Image button from the Nodes toolbar; the Image menu will be displayed. Next, choose Read from this menu; the Read File(s) dialog box will be displayed. In this dialog box, navigate to the location where you have saved the sunset.jpg and then choose the Open button; the Read1 node will be inserted in the Node Graph panel.

Step - 6
Make sure the Read1 node selected in the Node Graph panel and then press 1 to view the output of the Read1 node in the Viewer1 panel.

Step - 7
Choose the Transform button from the Nodes toolbar; the Transform menu is displayed. Next, choose Reformat from this menu; the Reformat1 node will be added to the Node Graph panel and a connection will be established between the Read1 and Reformat1 nodes.

Step - 8
Import tree.png and man standing.png files to the script, refer to step 5, the Read2 and Read3 node will be added to the Node Graph panel.

Step - 9
Make sure the Read2 node is selected in the Node Graph panel and then press 1; the output of the Read2 node is displayed in the Node Graph panel. In the Read tab of the Read2 properties panel, select the premultiplied check box.

Step - 10
Make sure the Read3 node is selected in the Node Graph panel and then press 1; the output of the Read3 node is displayed in the Node Graph panel. In the Read tab of the Read3 properties panel, select the premultiplied check box.

Step - 11
Select the Reformat1 node in the Node Graph panel and then press 1 to view the output of the Reformat1 node in the Viewer1 panel.

Step - 12
Select the Read2 node in the Node Graph panel and then press M; the Merge1 node will be inserted in Node Graph panel and a connection will be established between the Read2 and Merge1 nodes.

Step - 13
Drag the Merge1 node onto the pipe connecting Reformat1 and Viewer1 nodes. Also, the output of the Merge1 node will be displayed in the Viewer1 panel.

Step - 14
Insert a Reformat node between the Read2 and Merge1 nodes.

Step - 15
Select the Reformat2 node in the Node Graph panel and then press C; the ColorCorrect1 node is inserted between the Reformat2 and Merge1 node.

Step - 16
In the ColorCorrect tab of the ColorCorrect1 node properties panel, enter 0 in the gain field.

Step - 17
Select the Read3 node in the Node Graph panel and SHIFT select the Merge1 node. Next, press M the Merge2 node will be inserted in the Node Graph panel and a connection will be established between the Merge1, Merge2, and Read3 nodes.

Next, you need to crop and scale down the output of the Read3 node.

Step -18
Select the Read3 node in the Node Graph panel and then choose the Crop node from the Transform menu; the Crop1 node will be inserted between the Read3 and Merge2 nodes.

Step - 19
In the Crop tab of the Crop1 node properties panel, enter 120, 335, 955, and 1780 in the box x, y, r, and t fields, respectively.

Next, you will scale down and position the output of the Crop1 node.

Step - 20
Select the Crop1 node in the Node Graph panel and then add Transform node from the Transform menu; the Transform1 node will be inserted between the Crop1 and Merge2 nodes.

Step - 21
In the Transform tab of the Transform1 node properties panel, enter -853 and -845.4 in the translate x and y fields, respectively.

Step - 22
Enter 0.066 in the scale field.

Next, you will apply an overall color-correction.

Step - 23
Select the Merge2 node in the Node Graph panel and then press C; the ColorCorrect2 node is inserted in the Node Graph panel and a connection is established between Merge2 and ColorCorrect2 nodes.

Step - 24
In the ColorCorrect tab of the ColorCorrect1 node properties panel, expand the master area, if already not expanded. Next, choose the Channel chooser button corresponding to the gamma parameter and then enter 0.7614 and 0.48 in the g and b fields, respectively.

Step - 25
Save the composition. Figure 11 shows the node network used in the script.
Figure 11 The node network used in the script

Thursday, April 25, 2013

Generate an alpha channel using the Shuffle node

Tutorial 2 of Chapter 10 (Transformations, Temporal Operations, and Filters) from The Foundry NukeX 7 for Compositors textbook:
In this tutorial, you will create an alpha channel from rose.jpg using the Shuffle node. Next, the alpha channel created using the Shuffle node will be used to mask the color adjustments made by using the HueShift node. Also, you will use the HueRotation parameter of the HueShift node to animate rose color. Figure 1 shows the input image and the output.
Nuke Book - Tutorial 2 Chapter 10
Figure 1  The input image and output
Step –1
Navigate http://www.mediafire.com/?51x6sa7cjscyb47 and then download nt003.zip to your hard drive. Next, extract the content of the zip file to your hard drive.

Step –2
Start a new script and then load the rose.jpg file; the Read1 node is inserted in the Node Graph panel. Next, press 1 to view the output of the Read1 node in the Viewer1 panel, as shown in Figure 2.
The output of the Read1 node
Figure 2  The output of the Read1 node
Step –3
Make sure the Read1 node is selected in the Node Graph panel and then press G; the Grade1 node is inserted between the Read1 and Viewer1 nodes.

Step –4
Hover the cursor over the Viewer1 panel and press B; the blue channel is displayed in the Viewer1 panel, as shown in Figure 3.
The blue channel displayed
Figure 3  The blue channel displayed

Next, you will modify the blue channel of the rose.jpg by using the parameters of the Grade1 node to create the alpha.


Step –5
In the properties panel of the Grade1 node, make sure the Grade tab is chosen and then set the values of the fields as follows:

blackpoint: 0.03 whitepoint: 0.0293 lift: -0.001
gain: 0.08 offset: -2 gamma: 1.3

Also, clear the red and green check boxes located on the right of the channels drop-down. After setting the values, the modified blue channel is displayed, as shown in Figure 4.
The modified blue channel
Figure 4  The modified blue channel
The Grade node is used to color-correct the overexposed images. The blackpoint parameter sets the black point (darkest pixel), whereas the whitepoint parameter sets the white point (lightest pixel) in the image. The color specified by the lift parameter defines the color into which the black pixels will change. The gain parameter is used to set the color of the white pixels. The multiply parameter is used to lighten the image while preserving the blackpoint. The values specified for this field are multiplied with the output of the Grade node. The offset parameter is used to add fixed offset value to the output of the Grade node. The gamma parameter is used to lighten or darken the midtones. It applies constant gamma to the result of the Grade node.

Next, you will blur the blue channel by using the Blur Node.

Step –6
Make sure the Grade1 node is selected in the Node Graph panel and then press B; the Blur1 node is inserted between the Grade1 and Viewer1 nodes in the Node Graph panel, as shown in Figure 5.
The Blur1 node inserted in the Node Graph panel
Figure 5  The Blur1 node inserted in the Node Graph panel
Step –7
In the properties panel of the Blur1 node, make sure the Blur tab is chosen and then select rgb from the channels drop-down. Next, clear the red and green check boxes which appear on selecting rgb from the channels drop-down, refer to Figure 6.
The Blur1 node properties panel
Figure 6  The Blur1 node properties panel
Step –8
Enter 10.5 in the size input box; the blue channel is blurred by 10.5 units. Figure 7 shows the blurred blue channel.
The blurred blue channel
Figure 7   The blurred blue channel
Step –9
Make sure the Blur1 node is selected in the Node Graph panel. Next, choose the Channel button on the Nodes toolbar; the Channel menu is displayed. Next, choose Shuffle from this menu; the Shuffle1 node is inserted between the Blur1 and Viewer1 nodes.

Step –10
In the properties panel of the Shuffle1 node, make sure that the Shuffle tab is chosen. Next, select rgba from the in 2 drop-down and then select the blue check box in the 4th row of the in 2 channel matrix, refer to Figure 8; the alpha channel is shuffled with the blue channel.
The blue check box selected in the 4th row of the in 2 channel matrix
Figure 8  The blue check box selected in the 4th row of the in 2 channel matrix
Step –11
Hover the cursor over the Viewer1 panel and press A; the alpha channel is displayed. Again, press A; the RGB channels are displayed in the Viewer1 panel.

Next, you will add the HueShift node to change the hue of the rose and then mask the changes by using the alpha channel generated above.

Step –12
Select the Read1 node in the Node Graph panel. Next, press and hold SHIFT and then choose the Color button from the Nodes toolbar; the Color menu is displayed. Choose HueShift from the menu; the HueShift1 node is inserted in the Node Graph panel with a branched connection with the Read1 node, as shown in Figure 9. Next, release the SHIFT key.
The HueShift1 node in the Node Graph panel
Figure 9   The HueShift1 node in the Node Graph panel

Step –13
Make sure that the HueShift1 node is selected in the Node Graph panel and then press 1; the output of the HueShift1 node is displayed in the Viewer1 panel.

Step –14
Press and hold the left mouse button on the mask input of the HueShift1 node and then drag the cursor to the Shuffle1 node to establish a connection between the Shuffle1 node and the mask input of the HueShift1 node, refer to Figure 10.
The mask input dragged to the Shuffle1 node
Figure 10  The mask input dragged to the Shuffle1 node
Step –15
In the properties panel of the HueShift1 node, make sure that the HueShift tab is chosen and then set the hue rotation field value to -150. Figure 11 shows the output of the HueShift1 node.
The output of the HueShift1 node
Figure 11  The output of the HueShift1 node
The alpha channel which is generated using the Shuffle1 node is used to mask the output of the HueShift1 node. The HueShift node transforms the colorspace of the input image. The hue rotation field is used to rotate the colorspace around the Y axis. You can use different values for the hue rotation field to get the desired result.

Step –16
Select the Shuffle1 node in the Node Graph panel and choose the Color button from the Nodes toolbar; the Color menu is displayed. Next, choose Invert from the menu; the Invert1 node is inserted between the Shuffle1 and HueShift1 nodes in the Node Graph panel and the alpha channel is reversed. Figure 12 shows the output after inverting the mask.
The output after inverting the mask
Figure 12  The output after inverting the mask
Next, you will animate the HueRotation parameter of the HueShift1 node to create an animated color change effect.

Step –17
Make sure that the Current Time Marker is placed at frame 1. Next, in the properties panel of the HueShift1 node, make sure the HueShift1 tab is chosen and then choose the Animation button corresponding to the hue rotation parameter; a flyout is displayed, as shown in Figure 13. Next, choose the Set key option from this flyout; a keyframe is created at frame 1. Also, the base color of the HueRotation field turns blue which indicates that this parameter has been animated.
A flyout displayed on choosing the Animation menu button
Figure 13  A flyout displayed on choosing the Animation menu button
Step –18
Choose the Last frame button from the timeline controls and then enter 180 in the hue rotation field in the HueShift tab of the HueShift1 node properties panel; a keyframe is created at frame 100. Also, an animation node indicator (A) appears on the HueShift1 node tile in the Node Graph panel which indicates that one or more parameters of the node are animated, refer to Figure 14.
The animation node indicator displayed on the HueShift1 node
Figure 14  The animation node indicator displayed on the HueShift1 node
Step –19
Choose the Play forward button from the timeline controls to start the playback. You will notice in the Viewer1 panel, the color changes as the animation starts playing.

Next, you will render the script using the Write node.

Step –20
Make sure the HueShift1 node is selected in the Node Graph panel and then press W; the Write1 node is connected between the HueShift1 and Viewer1 nodes and its properties panel is displayed.

Step –21
In the properties panel of the Write1 node, make sure that the Write tab is chosen and then click on the folder icon corresponding to the file parameter; the Write1: Select file(s) dialog box is displayed, as shown in Figure 15. In this dialog box, navigate to location where you need to save the file and then append c04_tut2.%03d_rndr.jpeg to the path displayed in the pathname field. Next, choose the Save button. Notice that the jpeg option is automatically selected in the file type drop-down of the Write1 node properties panel, refer to Figure 16.
The Write1:Select file(s) dialog box
Figure 16  The Write1:Select file(s) dialog box
The Write1 node properties panel
Figure 17  The Write1 node properties panel
The %03d in the file name c04_tut2.%03d_rndr.jpeg represents the frame padding structure in the file name. On rendering the script, NukeX will create a jpeg sequence starting from c04_tut2.001_rndr.jpeg to c04_tut2.100_rndr.jpeg as the global frame range is set from 1 to 100.

Tip:If you are rendering a single file such as a QuickTime (MOV) movie, no frame padding is required. You can just provide the name of the movie.

Step –22
Enter 1 in the quality field.

Next, you will set the frame range that you need to render.

Step –23
Choose the Render button; the Render dialog box will be displayed. In this dialog box, select global from the Frame range drop-down and then choose the OK button; the Progress window is displayed. This window will close automatically on completion of the rendering process.

If you need to render a single frame only, enter the frame number in the field next to the Frame range drop-down. On choosing the Play forward button from the timeline controls, the Write1 node will use the rendered jpeg sequence for displaying the output in the Viewer1 panel instead of its input.

Step –24
Choose File > Save from the menu bar to save the script. Figure 17 displays the network of nodes used in the script.
Network of nodes used in the script in the Node Graph panel
Figure 17  Network of nodes used in the script in the Node Graph panel

create motion blur effect using the motion vector pass

Tutorial 2 of Chapter 10 (Transformations, Temporal Operations, and Filters) from The Foundry NukeX 7 for Compositors textbook:

In this tutorial, you will create motion blur effect using the motion vector pass rendered from Maya and VectorBlur node. Figure 1 shows the input image and motion blur effect applied to an element in the scene.
Nuke Book - Tutorial 2 Chapter 10
Figure 1  The input image and motion blur effect displayed
Step –1
Navigate to http://www.mediafire.com/?k5288w91eeo16 and download file to your hard drive. Next, extract the contents of the file. The zip file contains footage used in this tutorial.

Step –2
Start a new script file in Nuke. In the Properties Settings panel set the HD format (1280x720 px).

Step –3
Read in the mv_MasterBeauty and mv_mv2DToxik EXR image sequences; the Read1 and Read2 nodes are inserted in the Node Graph panel.

Step –4
Click on an empty area of the Node Graph panel to deselect the selected nodes, if any.

Step –5
Choose the Channel button from the Nodes toolbar; the Channel menu is displayed. Next, choose ShuffleCopy from the menu; the ShuffleCopy1 node is inserted in the Node Graph panel.

Step –6
Press and hold the left mouse button on the 1 input of the ShuffleCopy1 node and then drag the cursor to the Read2 node in the Node Graph panel; a connection is established between the ShuffleCopy1 and Read2 nodes.

Step –7
Press and hold the left mouse button on the 2 input and then drag the cursor to the Read1 node; a connection is established between the ShuffleCopy1 and Read1 nodes, refer to Figure 2. Next, select the ShuffleCopy1 node and then press 1 to view the output of the ShuffleCopy1 node in the Viewer1 panel.
The ShuffleCopy1 node connected to the Read1 and Read2 nodes
Figure 2  The ShuffleCopy1 node connected to the Read1 and Read2 nodes
Step –8
In the ShuffleCopy tab of the ShuffleCopy1 node properties panel, select MV2E_mv2DToxik_persp from the 1 in drop-down.

Step –9
Select other layers > motion from the out2 drop-down, refer to Figure 3.
The ShuffleCopy1 node properties panel
Figure 3   The ShuffleCopy1 node properties panel
Step –10
In the ShuffleCopy tab of the ShuffleCopy1 node properties panel, select the check boxes, as shown in Figure 3.

Step –11
Select the ShuffleCopy1 node in the Node Graph panel and then choose the Filter button from the Nodes toolbar; the Filter menu is displayed. Next, choose VectorBlur from the menu; the VectorBlur1 node is inserted between the ShuffleCopy1 and Viewer1 nodes.

Step –12
In the VectorBlur tab of the VectorBlur1 node properties panel, select motion from the uv channels drop-down.

Step –13
Enter 0.5 in the multiply field.

Step –14
Scrub in the timeline to preview the motion blur effect.

Step –15
Choose File > Save from the menu bar to save the script.