Home Technical Talk

32bit depth pass maya 2010?

polycount sponsor
Offline / Send Message
malcolm polycount sponsor
Anyone every successfully done this? I've tried a bunch of the file formats they all seem to clamp the depth pass to 8bit except the .exr file format, but that just renders out all black? What am I missing here read a bunch of googles posts but this just won't work.

Replies

  • Illusions
    Options
    Offline / Send Message
    Illusions polycounter lvl 18
    If by 32 bit you mean 24 bit color with 8 bit alpha/transparency, then I have something working. Also, if you're wondering about a file format, .tif works fine. Its lossless and supports alpha channel transparency. Here is how you will have to set up your render layer for a depth pass with transparency though:

    Step 1 - Create a new render layer with all the objects you want in your depth pass. The easiest way to do this is to select those objects, then in the render layer manager click that icon with the plane, gear, and sphere. It should say "Create new layer and assign selected objects" when you hover over it.

    Step 2 - Right click your new render layer, and go down to the bottom and select Attributes.

    Step 3 - In the attributes manager click on Presets and choose "Luminance Depth". This will create a special surface shader, in that its sampler info node will have connections available that the regular one does not have readily available, and apply it as a material override for the render layer. If you're a bit interested in how this shader operates you can continue reading, but if not skip to step 4.
    How this shader seems to operate is as follows:
    1. Using the sampler info node, gets the position of an object the shader is assigned to relative to the camera on the z-axis, and feeds it to a multiply/divide node as Input 1.
    2. The multiply/divide node multiplies this value by -1. You can see why it does this if you select a user created camera in your scene, and switch to the move tool. The axii that the move tool displays when an object is selected point in the positive direction of whatever translation space the tool is currently working in. With the camera selected, the z-axis arrow points away from the lens of the camera, which means that any objects you are filming are going to have a z-axis value that is negative relative to the camera.
    3. Using the sampler info node, gets the cameraNearClipPlane and cameraFarClipPlane and feeds this data into a set range node as the Old Min and Old Max values respectively. The resultant value of the multiply/divide node is feed into the value input. In addition the Min value is set to 1, and the Max to 0. A few important things are going on here:

      If you were to just to try and plug in the pointCameraZ value into the RGB color value of the surface shader, when you assigned it to an object and rendered, you'd see black to white gradient banding on the object. This happens because RGB values are 0 to 1, while pointCameraZ can store values higher than that. If a 0 to 1 value is fed a value that goes above 1, it essentially repeats. The banding is due to this repetition.

      To fix this issue, the Set Range node is used. I remaps the pointCameraZ values so that they lie in a 0 to 1 space based on the near clip plane and far clip plane of the currently active camera.
    4. The outValueX is then plugged into the outColorRGB of the surface shader.
    5. Objects with this shader when rendered appear closer to white the closer to the camera they are, and closer to black the further away they are.
    Step 4 - We do not want this surface shader as a material override for the whole layer, just certain objects. In the render layer manager, right click on your render layer and go down to Overrides > Remove Material Override.

    Step 5 - With the depth pass render layer selected, assign the surface shader that was created in Step 3 to all objects that will not use transparency. This would also be a good time to name this surface shader something that will remind you that its related to the depth pass.

    Step 6 - Create a layered shader for each object with a unique transparency map in your depth pass. We're doing this instead of duplicating the surface shader and assigning it transparency directly because the Out Color of a surface shader acts like Luminance on other shaders.

    Step 7 - Put the surface shader from Step 3 in each layered shader and remove the default green layer that gets created with each.

    Step 8 - In the Layered Shader Attributes, assign each Layered Shader a transparency map for the objects you want to be transparent, and change the Compositing Flag to "Layer Texture".

    Step 9 - Assign each Layered Shader to its respective object.

    Step 10 - Do a test render to make sure this all worked. If it did, objects closest to the camera should be closer to white, objects furthest from the camera should be closer to black, and objects with transparency you should be able to see through (in addition if you click the Display Alpha Channel button in the Render View they should display an appropriate alpha channel).

    * - If using this method in animations note that if an object that was previously not in frame or not in view, moves into view, or conversely an object in view moves out of view, then all objects will change to reflect this. This may result in unwanted behavior.
Sign In or Register to comment.