Hmmmm... I see LOTS of postings about this but no definitive answers. I"m trying to get DOF using depth in Maya iff files. I believe my script is hooked up properly (and I can see a decent looking depth channel in my Mult node) and indeed I am able to get some blurring effect. However, this node is VERY unintuitive, or at least while it appears to be intuitive it's almost impossible to control regions of focus (at all). I have a very simple test sequence with three spheres at varying distance from the camera but am unable to even create a simple region of focus in the middle distance. It's not clear to me what value ranges I should be working with in each of these parameters. 0-1 (for black to white)? 0-100 (for percent). -1 to 1?!?! Someone here suggested that the near and/or far parameters had to have negative values?! This is very confusing and if I can't get this to work I'll be defecting to After Effects and the Lenscare filter, which although cannot read depth from iffs is at least much easier to use than this. Can anyone at least tell me what value ranges ought to work? Thanks!
You need to sample the ranges from the picture...
The range is based on real distances in the cameraspace so you cant realy know what it is beforehand (the space isnt normalized so that even if it changed youd still get teh same reuslt). But you can ask shake to tell you the value.
Now to do this you must use the Z-view viewerscript. Load its parameters to aa tab to manipulate them and set the floatZinA parameter to original. YOu can now use the pixel analyzer to read the REAL values in the alpha channel.
Shake does not normalize things for you but rather shows you the pure RAW values maya sends sometimes they might seem whacky (trust me you WANT to operate on raw data).
Lilke in my test scene the furthest object was -0.019664 away and the closest -0.052260 wich isnt realy what you expect now is it! once you set those measured values in into your near far values your set. Now as you might notice its allmost impossible to guess the range! Now theres certain smart things about not normalizing. MAinly the fact that thisway you can get the same blur even iff the footage chnages range over time.
Nothing to it!
I appreciate your response. However, I'd have to ask you to clarify a number of things here.
The main thing that I do not understand about what you say is that you seem to be saying there are "real world" distances encoded in the Z channel. This undermines my understanding of what the Z channel actually is. That is, my understanding of the Z channel is that it is pixel based, being nothing more than a grayscale image based on distance from the camera. Ideally, white equal closest (normally), black equals furthest away, based on the camera's clipping planes. The gamma of this channel can be manipulated to affect blurring levels.
You seem to be implying that there are somehow absolute values encoded into the Z channel that Shake can somehow access? Does this mean that the visible Z channel is only a representation of depth information? (Of course in a sense this is true of all all channels, i.e. they are just visible representations of values). Is Shake not actually reading the grayscale information directly, but the values from which the grayscale is derived?
If this is indeed the case, how can Shake "know" what the camera's clipping values were at render time in order to derive "absolute" distances from the camera?
(I assume that when you mentioned the alpha channel in your post, you actually meant the Z channel?)
In any case, perhaps if you could be a bit clearer about the workflow you describe I could investigate this and your advice might make a bit more sense to me...
Thanks!
Check out Fredrik's nice tut on manipulating the zdepth files:
http://www.averpil.com/fredrik/index.php?p...orials&id=1
This undermines my understanding of what the Z channel actually is. That is, my understanding of the Z channel is that it is pixel based, being nothing more than a grayscale image based on distance from the camera.
Zdepth file is not an actual image file, it is a data file (floating point information). The data is distances from the camera to the object in the scene within the scope of the clipping plane for your camera. The black and white image is actually an interpretation of that information into b&w data. That is why zdpeth information isn't antialiased. It is created by the software render(usually a scanline) so it can figure out where objects are in space. So it can clip objects and faces that aren't from the viewpoint of the camera. This is faster than shooting rays at everything to figure out where they are in space (raytracing).
I've seen this tut. Nice, but it doesn't solve the problem of how to use the Z info using Shake's Zblur node, which is what I posted about. Thanks anyway.
Zdepth file is not an actual image file, it is a data file (floating point information). The data is distances from the camera to the object in the scene within the scope of the clipping plane for your camera. The black and white image is actually an interpretation of that information into b&w data. That is why zdpeth information isn't antialiased. It is created by the software render(usually a scanline) so it can figure out where objects are in space. So it can clip objects and faces that aren't from the viewpoint of the camera. This is faster than shooting rays at everything to figure out where they are in space (raytracing).
For compositing purposes, which is what my post is about, the Z channel IS an image file, however you want to dice it technically. So my question is, how do I manipulate this properly in Shake? This thread is going way off my original topic....
You can extract Z using "Depthkey" node in the KEYS menu.
the Value works depends on the scale of the 3D element you have used.
if the 3D element is real size like 10 feet height and 20 feet width, you will get a nice depth using values ranging from 0-100 or 0 - 500.
most of us use reduced scale elements in 3D, just because particle to work faster. or sometimes particles doesnot render atall with real size elements. check the scale of your 3D element, if its in few inches or centimeters,
in the above condition
1. use "depthkey" node,
2. keep your viewer in to alpha mode
3. adjust the values between -0.001 to 0.001 play around with this values may be it works with -0.04 - 0.06
4. you will get some clue about the depth information and now you can use expand mode and extract the z information properly.
since all your z information is available now in the alpha channal you can use IBLUR for bluring or use it as a matte for desaturation and other color treatments. thank you.
No it isnt its bang on topic you just dont want to eat the fact that z is not a valued channel form 0 to 1 or even 0 to anything specified.
yes the z is actualy based on the camera space distances. (or actualy is something like -1/ range or like that) but shake can compute that for you (just set the z viewers alpha attrib to distance). So i can actualy tell the size and unit of your scene by looking at the iff file.
And yes shake reads the real values.
And yes and no you cant realy count on measuring the range to the clippingplane, but you could do that. because its defined as infinite but if you can find the futhest or closest pixel you arent faar off. Or by reading the file headers.
And no you misunderstod.
The viewscipt show z will conwert the image into black and white normalized. But it has a option to pass the real value in the alpha channel. Now when you set the viewscript to pass the real range as apha. then all you need is to move the mouse over your image and read teh alpha value or copypaste it from the pixel analyzer. to you far and near values in the z blur node! All other z nodes use the real z data as source so its the indentified value.
And no you cant tell the range in advance! you MUST measure it to be sure. but again jsut moving and cliking the poiiter will do that.
And yes you can use depth slice switch channels to convert to balck and white image for theose nodes that dont eat z values. BUt you still must measuure the range (theres a reason for this, and its so that if you design fog for exmaple it wont suddenly jump into faaraway if a new object appears at the range, since your slice still uses your set range)
NOTE all 3d apps measure th z distances a bit differently, so for example the z rabnge of max is differnet form Mayas. And no even MAxsews z isnt a grascale image!
PS. i can usnerstand that you may have problems unsdrstading theis as AE actualy is relay ridiculously stupidwhan it comes to zdepth so you dont realy have a coise but to use ait as abaclk and withe image without the actual range data.
Pps anyone at assembly this year?
OK, so I will accept what UR saying about the depth channel of an image not being the same as any other channel and it having arbitrary values based on worldspace in 3D. I did not know this.
(Unfortunately still having a hard time deciphering much of what you are saying, but that may speak more to my relative lack of high-end comping experience -- I'm primarily a 3D artist).
BUT. Can you please then explain how it is possible for me to take a depth shader, apply it to all my objects, and render a grayscale image into RGB and get the EXACT same results when using this to generate depth of field blur as if I had used the Z channel?
I gave up on Shake and am using the Lenscare plugin for After Effects. This allows me to read grayscale from a Z channel or from RGB images that have been rendered with a depth shader and I get exactly the same results.
Is this therefore "fake" depth? What's the difference, in practical terms, since if my end images look the same that's all that matters?
hard to say. moist likely so! Theres nothing fancy about the way shake does zdepth. simple as 1 2 3.
Ifact its realy hard to justify you not understanig whats said it just 2-3 (7 tops if your settings are unoptimal) buttonpesses to get what our after.
Im gled you got what you were after.
Infact ist wierd you can do this in AE as its harder to do in basic AE then it is in shake. And AE is much less intuitive too.
Dont take it personaly but try to analyzer the answers as my first opst tells you EXACTLY what to do. And the manual explainds this even better tiugh not under z but rether the tutorial... Nothing facy but a bit triuiky i do aree with thet.
zcompose automatically overs the pixels with bigger z value and create a new clean merged z each time you use it..
On the other hand you can use a depth slice with grad turned on to put the z in alpha and use that image to control color corrections (mult, expand, add..) blurs and defocus, or any other effect.
I found depthSlice far more handy than depthKey!
The only tricky thing is to find the right lo negative value (ex : -0.008... it's very sensitive, use CTRL while dragging on the float values) I also use to use the z to extract part of 3d shapes to make cool 3d background from iff elements very quickly (instead of wasting my time with rotos only)
you can even use add to offset Z values!
and a move 2d before a zcompose also use z info to merge z elements!
Another tip : if you need to transfert z from one image to another you should use a copy node with "z" as channel parameter
Unfortunatly I had the same problems you are having with a simple Z-Compose or using Z-Depth. The problem is in Maya; well for me it was. When I was exporting the Z-Depth Channel I was storing it in a TGA file. The TGA data will not read correctly (even in after effects). Render just your Z-Depth into a RLA format. This format i have had the most success on through our pipeline. Both After Effects and Shake like this format better.
Also, in shake make sure your Z-Depth is loading when you do a filein. There should be a Z-Channel (check the top of your viewer). See the Shake 3.0 book for a the Z-Compose tutorial or check your manual (the z-depth building tutorial).
Best of luck,
-tc
Tgas dont support z-depth. render out iffs, otherwise maya spits out a iff and a taga asuming z output is on.
OK, while we are talking about Zdepth, let me ask.
Does anyone have actual production experience of using Zblur or Zdefocus?
How did you get round the issue of edge artifacts? I know that the documentation suggests that this can be cured by splitting up the render into Z slices and comping them in post, but lets face it, this is mostly impractical in real production environments. So what is the answer?
Did you use an actual aliased Zchannel or a shader that pumps out antialiased depth information as a normalised greyscale image which can then be solarised, etc. and then used with Iblur or Idefocus?
Genarts S_ZdepthCueBlur (what a name) set to composite combined with Zkey or Zslice seems like it gives the best solution to the edges problem but it is only a blur and not an optical defocus simulator. In other words, it doesnt give very real looking results.
Have I covered all the bases or are there other solutions out there?
For an example of the edge artifacts, please see www.geronimo.co.il/3dl54pe431f\_05/images/zexample.jpg It was blurred using Zblur and the Zchannel was provided courtesy of maya, rendered through mentalray.
i am not sure if that really answer your question but this is how i use z channel:
1 - Just combine elements with z compose it will create clean merged z : Let zCompose do it's magic!
The problem of aliasing only occurs when you need to limit z with the alpha but zcompose gave me grat results ofside of such case (see 3 - for a workaround to this)
1 bis - If i need to offset the z info i use zadd just after the z elem file in
2 - i apply global z filtering and color corrections at the end of the tree using a depth slice (with grad turned on and neg range values) to extract Z in an alpha channel and using image based nodes (I_Add, etc...)
3 - If i need to insert elems without Z in the tree (ex : real shots) i use inside / outside to act on elements alpha an using zSlice (with grad off) as the second operator. This use of zSlice is also great to extract part of shapes without using roto, according to z info
I hope i understand your question though !
Can you past the tree showing the problem of you image (the aliased egde)
PS :
1 - zadd : i mean the z variable in the add node
2 - don't color correct or premultiply elems before zcompose it can give strange results sometimes
the tree was really simple, it is essentially a file in and a zblur node.
maybe avoid zblur / zdefocus and use zslice / I_defocus instead ? anyway you will have more control this way
which is exactly what the zblur/defocus macro is made of and therefore it gives the same artifacts.