View Full Version : optimizing Maya Z-depth render

Richard Slechta
08 August 2004, 07:57 PM
I am trying to optimize my z-depth render time in maya. I have been using the z-depth shader availble on highend3d. love it. It renders fast and has controlability. However, it will not support objects that require transparency maps. Thus I am back using the Maya Z depth.
Currently in order for me to get a z-depth image into shake for compositing, I need to render the whole scene in RGBZ. I don't need the RGB as I am rendering all the elements in separate passes. My question is it possible to render a Z-depth pass in Maya without it having to calculate and create the RGB stuffs?

08 August 2004, 11:03 PM
Try rendering your scene with a linear fog, apply a black surface shader to your models(the ones that aren't transparent and kill all of your lights.... oh yeah make you fog white. After that renders you can re-order the L channel to the alpha and use that for any map controlled effects, or you can copy the A channel of the re-order to the Z channel of your image sequence. That will work like the Z was embeded at render. This way you can control the range and levels of your depth pass.

Richard Slechta
08 August 2004, 01:27 AM
Thanks Matt,
I did a litttle test with the enviroment fog - simple. Instead of the surface shader, I kept the transparency maps on the blinns but brough color, spec, incad, ect to black. Thus keeping the shape of the objects on cards. It is not a perfect z-depth but probably close enough. The render times were definately an improvement, about 2 min.

08 August 2004, 03:31 AM
no problem.. Good luck!! post some stills when you are done, if you have the time, the lighting on your site looks great, I would love to see what you got goin'!

08 August 2004, 07:36 AM
Sometimes when I need a urgent Z I render it in the Hardware Render buffer.
It goes realy fast but you don't have the antialiasing you can get with the Zshader.
So you may render it at a higher resolution > resize-it ( +filtering ) and assemble RGBZ in compose.

08 August 2004, 09:18 AM

i might be wrong on this: but mayas Z render does not take transparencies into account as well afaik.. and that is correct like that.
the only real idea to have a transparency being taken into account would be the idea of having a "clip-map" like transparency like on tree billboards or so.

rollmops: you can use the new hardware renderer, which will have anti aliasing in a faster and better way than the hardware render buffer.

here is a z-depth mel script i wrote a long time ago which i found to be very fast.
it uses a ambient opint light in the camera to create the depth and thus is correct concerning distances from the camera center.
before you run the script the only thing you have to do is set the clipping values in your render camera as you want the black/white distribution in the rendering.
have a try.

please read the instructions carefully before you run the script.. it will change a lot in your original scene file!



// author: alexx
// usage:
// will change your scene in a way, that the rendered image is a fake depth pass
// output format is IFF16 by default.
// all lights get hidden
// note!: the camera clipping planes are used to set the min and max value for the image.
// you have to diable automatic clipping planes and set them as close as possible
// to your min and max (closest and farthest object visible)
// !!all your texture assignments are overwritten!! so be carefull how you save the scene!!
// this script is somewhat old.. so nevermind some strange scripting style or problems when executing :)
global proc createFakeDepth()
//in here to make fake depth pass
// first hide all the lights in the scene (procedure)
string $allLights[] = {};

select -clear;
$allLights = `ls -lights`;
if (size($allLights) != 0)
select $allLights;
$allLights = `pickWalk -d up`;
for ($i=0; $i<(size($allLights)); $i++)
setAttr ($allLights[$i]+".visibility") 0 ;

//check for the camera that will be used for rendering.
$camSelection = `ls -type "camera"`;
select $camSelection;
pickWalk -d up;
$camSelection = `ls -sl`;

//check all the cameras for the render flag
while (!(`getAttr ($camSelection[$i]+".rnd")`))

//feedback what camera is used to group the light to
print ("\n// Camera that is used for rendering: ");

select -clear;
//create the ambient light that illuminates the scene (light not directional)
$depthLight = `shadingNode -asLight ambientLight`;
setAttr ($depthLight+".ambientShade") 0;

//create an intensity curve
$depthIntensityCurve = `createNode animCurveUU -n "depthIntensityCurve"`;
//create Light Info Node
$lightInfoNode = `createNode lightInfo -n "depthLightInfoNode"`;

//make the connections
connectAttr ($depthLight+".worldMatrix") ($lightInfoNode+".worldMatrix");
connectAttr ($lightInfoNode+".sampleDistance") ($depthIntensityCurve+".input");
connectAttr ($depthIntensityCurve+".output") ($depthLight+".intensity");

//set Keys for the decay region -> get them from the clipping planes in the camera aa
setKeyframe -f (`getAttr ($camSelection[$i]+".nearClipPlane")`) -v 1 $depthIntensityCurve;
setKeyframe -f (`getAttr ($camSelection[$i]+".farClipPlane")`) -v 0 $depthIntensityCurve;

//Make a point constraint that the point light follows the renderCamera
pointConstraint -weight 1 $camSelection[$i] $depthLight;
// create a new material (lambert, color white)
$depthLambert = `shadingNode -asShader lambert`;
sets -renderable true -noSurfaceShader true -empty -name ($depthLambert+"SG");
connectAttr -f ($depthLambert+".outColor") ($depthLambert+"SG.surfaceShader");
setAttr ($depthLambert+".color") -type double3 1.0 1.0 1.0;

//and assign it to all objects
select -all;
sets -e -forceElement ($depthLambert+"SG");

//finally set the image format to Maya IFF16, since an 8 bit format makes no sense
setAttr defaultRenderGlobals.imageFormat 10;

08 August 2004, 02:11 PM
Thanx a lot Alexx! ;)

CGTalk Moderation
01 January 2006, 02:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.