Z composite with IFF in Shake

Report this File

Missing

Views:

6,174

Updated:

Mar 31, 2005

Readership Level:

Intermediate

Tags:

Shake Versions:

2.x, 3.x

Platforms:

irix, linux, mac, windows

Owner:

Language:

English


Z composite with IFF in Shake

Utilizing the Z channel (depth information) of Maya's IFF files in Shake is a bit tricky because of the way Maya stores depth information... here's a quick tutorial to get you started.

Note that this tutorial is applicable on not only Maya's IFF files but also on other image format files rendered out of other 3D applications. I will add a data table of Z ranges for other 3D applications soon. If you happen to know how your 3D application store Z depth, please email me and let me know.

Happy shaking!

Download

zCompExample.iff - Maya IIF image
zCompositeIFF.shk - Shake script





Render out your own IFF image using Maya's batch renderer or use my example (download above) to experiment with. The file above was rendered with mental ray version 3.3.1 for Maya 6.

Load the IFF image or IFF sequence (containing an alpha channel and a Z channel) into Shake using the FileIn node. The channels of your image are listed in the top of the viewer (in this case RGBAZ).

Maya always renders the Z channel of IIF files in 32-bit floating point. Other 3D applications can output the Z channel in 8-bit which means that the Z channel is built up of a maximum of 256 shades of gray (28 = 256). In high end production this might not be enough to visualize the depth and in that case you can render in 16-bit (216 = 65 536 shades of gray) or 32-bit (232 = 4 294 967 296 shades of gray) to increase the resolution of the depth.




Our Z channel is already 32-bit, but the RGB and the alpha channels are just 8-bit. Create a Bytes node and put it to float space. This will change the bit-depth of your image to 32-bit floating point. Please note that this won't affect the actual image, just the way it is described. Before, RGB and alpha information was described between 0-256 and we have now converted it into 0-1 where we can drive values above 1 and below 0.




Now we will bring the Z channel into RGB so that we easily can perform RGB operations on it. Create a Reorder node and set its channels to "zzzz".




The grayscale depth image should be visible in RGB now, but since Maya stores depth information like this: -1/Z ...it will not show up. To correct this we will need to multiply the Z channel with -1 (or in this case the RGB channel since we brought the Z channel into the RGB channels in the previous step). This is something we can do because we are currently in float space!

Create a Mult node, and inside of it, create a local variable by right-clicking in the Mult's parameters tab. Let us name the local variable "brightness" and make it a float.




Next, expand the Mult's color attributes twice until you see the red, green, blue attributes. Into the red attribute textfield type "-1*brightness". This will change the depth value data from -1/Z to Z. But only for the red channel. Type "red" into the green and the blue channel to make them inherit the value from the red channel. Now drag the brightness slider around to offset the depth information to a viewable range. Please note that you might have to exceed the slider's max value quite a lot (depending on the size of your scene). For the IFF file provided at the top of this page, 4 seems to be a good value for the brightness.

If you are using your own rendered file and keep getting an entirely black image, you need to increase the value of brightness. If your image is all white, you need to lower the value of brightness.

On a sidenote it is worth mentioning that there is a reason for why we have named the local variable "brightness". Brightness is nothing more than a multiplier on the RGB channels ...and that's exactly what we have done here.




If you like, you can perform aditional RGB operations since all depth information is now in RGB space. Perhaps you want to use an Expand node and/or an Invert node here (to match other render passes). Try to not make the edges of objects in the Z channel anti-aliased as this would move the edges away from its object, depth wise.

If you used the IFF file in this tutorial, your RGB channel would now look like the image to the left.




To transfer the new grayscale depth image to the original image's Z channel, create a Reorder node (let's call this Reorder2) and type "rrrrr" into its channels textfield. Then create a Copy node on its own branch directly under the FileIn node. Put "z" into the channel textfield of the Copy node. Connect the output from the Reorder2 node to the Copy node. This takes your original image and copies the Z channel from the Reorder2 node. You finally have a Z channel that Shake can do something useful with!




If you would like to make a "view Maya Z" macro, you can select the Bytes1, Reorder1 and Mult1 nodes and hit shift-m. This will bring up the create macro dialogue. Scroll down to the Mult1 and expand it. Here you can make the brightness slider visible in the macro by clicking the status icon next to it. Also, you can define a maximum value for the slider instead of 1. Change the macro name and you are ready to start Z-comping that little sucker!
Tutorial_next_page

Comments

Write a Comment

You must be logged in to leave a comment. Login or create an account

Related Marketplace Items

  • 000

  • Camaro01

  • Subwaygates3

  • S3d-cloths-casual0

  • Gargoyle2

  • 1

  • Hans03

  • Kitchen_0008_01