Now there are a hundred different ways to do this and a hunded different views on each. If you ever find yourself in a situation of being confused about the proper workflow for a depth pass, be sure itll end up with you banging your head on your keyboard (sure did for me ). Anyways, after many such sessions, i have managed to find out a working method for GOOD DOF and im pretty clear in my head about it..so here goes.
There are three different methods primarily to get a depth pass ( which’ll be used for creating dof in post).
1. by ticking the z depth tab in render globals (lots of problems, major being that it produces z depth in some crazy format that photoshop and aftereffects have problem reading and secondly it increases render time)
2) by choosing mental ray depth pass. advantage : non aliased ( in fact mr does a great job by aliasing overlapping geometry edges but not aliasing alpha edges.. works great for my eyes at least) , uses mental ray renderrer, no need of a separate rendering, in short everything is set up automatically . Only one thing though..the normal settings would give you a depth pass which suddenly turns black after some distance, no change of clipping values affect it.bad and strange. so u need to tick on remap depth values and set it to the farthest point in your scene (not more than that if u want good contrast) and SET THE MAX BUFFER VALUE TO 100. thats all.You’ll get a neat depth pass. Disadvantage is that if you need to rerender the depth pass, ull have to rerender the entire beauty pass again.But the major disadvantage is that there is no (that im aware of) whereby you can get proper depth pass for transparent objects and this makes it pretty much useless for scenes involving transparency.
3) This is the best method and has none of the cons of the above and is lightning fast.
FIRST, you set the camera’s far clip plane to just outside the scene’s boundary (this is necassary to get good contrast). Then You create a new render layer and select luminance depth preset in its attributes. this is maya’s old depth preset. its good and fast .
Advantage 1: If something goes wrong and you need to rerender the depth pass, its done in a matter of seconds.
Advantage 2: If you have transparent objects, you can easily get a luminance pass respecting the transparency ( read my following post).
Note: The preset craetes an override to use maya renderer..which is a problem. Mr renders objects in smooth preview mode (button 3) as smooth but maya dosent. Hence, ull need to break that override and get back to mr. However, sometimes, mr goes crazy and rendres dpth pass as all white or all black. In such a case, go back to maya rendrer once and render the pass and then switch back to mr agin. Will renderfine. ( yes , pain in the ass but that’s what bugs are). Btw, if you want non aliased depth pass, dont forget to turn the alaising values to 0 in the mr globals for this layer. Im still not sure wether dpth pass needs to be aliased or unalised so i leave that upto you. Render both..whichever works .
ASIDE: depth passes can be used for much more cooler stuff than just dof. use it as fog by playing with blending
modes and invert channels.