DepthToDisparity

Description

Many Ocula nodes rely on disparity maps to produce their output. Usually, disparity maps are created using a combination of the O_Solver (see Solver) and O_DisparityGenerator (see DisparityGenerator) nodes.

However, if you have a CG scene with stereo camera information and a z-depth map available, you can also use the O_DepthToDisparity node to generate the disparity map. Provided that the camera information and z-depth map are correct, this is both faster and more accurate than using the O_Solver and O_DisparityGenerator nodes.

Using one of the camera transforms and the corresponding depth map, O_DepthToDisparity does a back projection from one view to find the position of each image point in 3D space. It then projects this point with the other camera transform to find the position of the point in the other view. The difference between the two positions gives the disparity in one direction.

As with the O_DisparityGenerator node, the final disparity vectors are stored in disparity channels, so you might not see any image data appear when you first calculate the disparity map. To see the output inside Nuke, select the disparity channels from the channel set and channel controls in the top left corner of the Viewer. Examples of what a disparity map might look like using the RGB and R channels are shown below. As you can see, the RGB layers on the left are harder to read than the single R channel.

Once you have generated a disparity map that describes the relation between the views of a particular clip well, it is suitable for use in most of the Ocula nodes. We recommend that you insert a Write node after O_DepthToDisparity to render the original images and the disparity channels as a stereo .exr file. This format allows for the storage of an image with multiple views and channel sets embedded in it. Whenever you use the same image sequence, the disparity map is loaded into Nuke together with the sequence and is readily available for the Ocula nodes. For information on how to generate a disparity map using O_DepthToDisparity and render it as an .exr file, see Generating a Disparity Map from Depth.

Note:  To use O_DepthToDisparity, you need the positions of the stereo camera rig for the two views.