PDA

View Full Version : Z-depth in mental ray - Best way for instancing, methods, passes?


InfernalDarkness
12-12-2010, 06:29 AM
Still struggling to achieve a nice clean usable depth-pass workflow. I've tried many ways to make depth renders, from passes to special shaders to surface shader workflows, and am unable still to make a decent usable depth pass in a complex scene. I feel like there are so many variables that I just get lost when I go to render out a depth pass in a big scene with lots of trees and plants and complex objects being instanced or proxied around. I'll try to keep my frustration out and just lay out the issue, and hope for suggestions and workflow procedures to help...

Here's an example "test scene":

http://img821.imageshack.us/img821/5053/zdepthpassessetup.jpg

Using Puppet's p_z shader for mental ray here. The middle sphere is an original object, the others are instances. Regular BSP or Large will work with these instances, but BSP2 breaks the instancing, showing only the original source sphere in a render. No big whoop there, in a scene like this.

http://img101.imageshack.us/img101/5232/zdepthmrpuppet14.png

Here's the instances with a cutout opacity mapped into the p_z shader. All's well.

Moving to a more finished scene, I run into problems now with the cutout opacity:

http://img405.imageshack.us/img405/2835/wildtwistymastermr36lea.jpg

No cutout opacity working on the leaves now, though... And soooo many settings to even make the depth work. Note this is NOT a depth-remapped "pass", but a separate layer. I was unable to make passes work with cutout opacity at all in instances, thus these tests of the Puppet shader.

http://img829.imageshack.us/img829/2005/wildtwistymastermr38lea.jpg

And since I'm rendering out to .exr, I for some reason get a concurrent render of the alpha of the leaves... When I'm using .exr files, I was hoping it would be one .exr file with the depth render "embedded" or whatever. I don't know why I get two separate files, and this one completely useless for me. Extracting an alpha or object ID isn't what I wanted.

To illustrate my problem, when I'm making scenes there's often no sense of "depth" or distance in them, generally because I'm using raw mental ray renders with sun/sky and no atmospheric effects inside Maya. In the past, I would just render a zdepth render and use that in conjunction with object mask renders to add haze and blur effects to the distant parts, based on the gradient the depth pass would give me to control intensity.

This is my unfinished scene so far:

http://img607.imageshack.us/img607/5909/wildtwistymmr27pregamma.jpg

My layer edges really suck here, and there's little to no sense of "depth", but I'm using this simple scene to try to learn how to do depth renders... and failing.

http://img190.imageshack.us/img190/2650/wildtwistyzmr27farfinal.jpg

Managed to get a depth pass for the background sections, but it's still gnarly and almost useless, even after I clean up the edges and remove the reference-position sphere. Certainly not a 32-bit file with any level of clarity, and I'm understanding that AA is to be avoided for depth passes. But how do I deal with my edges then?

I've searched and read and tried every thread here, and still don't know what I'm doing wrong. The variables increase so quickly and dramatically, I feel lost and would just like to know how others go about creating depth renders for complex scenes with lots of tiny objects and opacities... Any thoughts or workflows would be helpful, and at this point I'm clearing my mind and will try any techniques suggested, even if they seem like ones I've tried before. I need to isolate why/how my depth renders fail, and even better yet, how to do a concurrent depth pass with my main renders, if that's even possible.

m0z
12-12-2010, 05:28 PM
out of interest I tried the whole zdepth thing once again.

I used .rla and 32Bit framebuffer. I also used a Camera Depth pass so now I have a own zdepth file like with .exr but .rla actually works for me.

Cutout opacity works but I don't know how to fix those artefacts. :shrug:

my scene:
download (http://www.mathiasmarkovits.com/upload/zdepth.rar)


the good: no need for a special shader. no need for a own render layer. mip_binaryproxy / mia_mat with cutout_opacity / bsp2 works
the bad: sampling artefacts or dunno...

LinchpinZA
12-13-2010, 07:39 AM
Hey InfernalDarkness.

I normally render zdepth using the mentalray passes system, set my near and far distance, and grade the depth pass in comp so that the furtherest point is just below white or '1' and the closest point to camera is just above black '0'.

I can imagine for the effect you're wanting to use zdepth for, with complex detailed scenes, you'll always be struggling with some unlcean edges.

But if all you're wanting the zdepth for in your scenes is atmospheric perspective, you can plug the physicalsky shader into the volume input of your camera. Once you've done that go into the attributes for the physicalsky and adjust the 'Visibility Distance' The haze attribute then adjusts the visibility falloff.

I know if you did this in comp with zdepth you could get more control with colouring the atmosperic perspective to how you want, but maybe this can be a simpler workaround for the effect you want.

-Chris.

ytsejam1976
12-13-2010, 08:02 AM
@infernal.
Are you trying to use mip_card opacity?

kiryha
12-13-2010, 08:41 AM
For me, much easy to refuse cutout opacity at all in workflow, than have strugle with all problems that it involve . I did so long time ago and i`m happy now.

InfernalDarkness
12-13-2010, 09:02 AM
@ m0z: I'm using your scene as a reference and working that technique into my scene for testing. I'll post the results as soon as I get 'em.

@Linchpin: A very good idea! But since I use z-depth as a post-filtering selection method, this doesn't necessarily help me here. The point of using post-effects is that I don't have to wait for another 12-hour test render to see how crappy it's going to look: I can make it look crappy in realtime. But your idea certainly holds merit, and perhaps I can incorporate this into my workflow. It's on the tip of my mind, and I'll be trying it in conjunction with my other z-depth methods.

@ytsejam1976: No, not using the card opacity. Simply the Maya opacity, the mia_material_x cutout opacity, and specifically the p_z opacity sections. I don't see how adding another shader would help z-depth at all, since they already don't respect file cutouts very well.

@kiryha: (Edit) The types of scenes I'm working on are huge and complex. Cutout opacity is not only necessary, it's the key element to making such scenes work. Thanks for your time.


I'll post some new tests tomorrow - they take forever to work on and set up, and there's just less and less free time these days to diagnose things.

kiryha
12-13-2010, 09:09 AM
You have to pay for everything :) May be some times rising quantity of poligons for one leave from 1 to 4-8 bring less problems, than using cutout?

InfernalDarkness
12-13-2010, 09:21 AM
You have to pay for everything :) May be some times rising quantity of poligons for one leave from 1 to 4-8 bring less problems, than using cutout?

@kiryha: Please refer to the Forests in mental ray (http://forums.cgsociety.org/showthread.php?f=87&t=804892&page=3&pp=15) thread for a reference to the type of scenes we're discussing. My leaves already have a minimum poly count of 72 apiece, not 1, and scenes range from 100M polys to 100G polys. Increasing this polycount by any magnitude is not what I'm trying to do. Nor is it even possible to do with current tech. Even my old Apexx 4 would have barfed at 8 Terapolys.

I'm simply trying to extrapolate existing camera depth information from a scene that already renders properly otherwise. That is to say, everything works for me except z-depth; there's no need to go back to the drawing board on a proven and powerful technique. Also, we know mental ray is calculating the distance from the camera to each polygon and filtering it per-shader already, since it's rendering properly in the beauty pass. I merely need to extract this depth data into a usable separate image, for compositing purposes.

LinchpinZA
12-13-2010, 09:28 AM
@kiryha: (Edit) The types of scenes I'm working on are huge and complex. Cutout opacity is not only necessary, it's the key element to making such scenes work. Thanks for your time.
If I'm not mistaken, cutout opacity creates polygon tesselation on the surface at rendertime to create the cuts. Having the leaves proxied with higher polycount versions should result in similar render times to using cutout opacity, so maybe give that a try ?

Also becuase you're using zdepth for just color adjustment have you tried rendering your zdepth with the same subpixel sampling as your beauty render. zdepth passes normally need no subpixel sampling with only 1 sample per pixel, this is important when using it for DOF in post. But this isn't necesary if you're using it for color correction. I dont know if the result will be better , but its worth a try.

InfernalDarkness
12-13-2010, 10:29 AM
If I'm not mistaken, cutout opacity creates polygon tesselation on the surface at rendertime to create the cuts. Having the leaves proxied with higher polycount versions should result in similar render times to using cutout opacity, so maybe give that a try ?

This is not the case with cutout opacity. It's simply a texture-filtering calculation - no extra polygons are generated.

But yes, subpixel sampling is certainly worth a shot. I don't believe unantialiased z-depth will be helpful in my situation given that the above scene is as simple as I need it to be, and the current unAA z-depth isn't helpful enough in postwork to make brightness-based selections accurate.

That said, I still am unable to get a full depth pass out of this scene, or others very similar to it. So until I can have all elements in this scene appear properly in the depth render, it's still a struggle to even define the variables involved for me. It feels like there are dozens of variables, and at 20-100 minute renders just to test one variable, progress is tedious and terribly frustrating.

Redsand1080
12-13-2010, 01:01 PM
I don't believe unantialiased z-depth will be helpful in my situation given that the above scene is as simple as I need it to be, and the current unAA z-depth isn't helpful enough in postwork to make brightness-based selections accurate.


Have you tried rendering out the depth pass at double or triple res with no AA and using the triangle filter? Not sure if you're using the triangle filter for those unAA renders but Zap says that filter has less smoothing than the box so its best to use that filter for those sorts of renders. But if you render to double or triple (or greater) res and then use that to make your depth based selections and then reformat that image down afterwards your selections will be much cleaner. Its a work flow I learned from the Round 6 blog and it works really well. Worth a shot if nothing else, maybe?

-Justin

syna
12-13-2010, 03:45 PM
The method i told you woks great for me, here is one render i did some months ago with the Z-Depth done as i explained. Plus, ive rendered in 32 bit and bsp2.

i don't know why i can't upload biger images so you can see the final image and Z-Depth in this link:
http://picasaweb.google.com/104913604832060956575/Z_depth?authkey=Gv1sRgCIe0mvDakc2SAg#5550207585356591394

Redsand1080
12-13-2010, 06:17 PM
The method i told you woks great for me,

Could you link to the thread where you explained the method? Was it in the forests thread?

Thanks much,

Justin

**EDIT**

I found it...no need to post a link.

InfernalDarkness
12-13-2010, 10:28 PM
Thanks for posting those examples, Syna. Your cutout opacity certainly appears to be working properly! Great scene too, by the way.

I'm working on m0z's pass method today, one more tweak to see if I can get a depth pass itself. So far, my .rla file has no beauty pass, an accurate alpha pass, and the z-depth pass is coming out black. Gonna tweak my camera depths and try it again tonight.

Then I'll launch into your method, which is much more tedious but obviously works, Syna! Thanks for your input.

syna
12-14-2010, 10:09 AM
To acellerate the process you can select all of your materials, go to attribute spread sheet and put weight, reflectivity, difuse, transparency and translucency to 0/off.
the only thing you need to do is to drag and drop the planar projection of the ramp in the aditional color slot. It's faster than it looks.
if anyone can write a script that makes this conection it would make the process much faster. ;)

edit: i have uploaded to my portfolio some more pictures of the same work as that image, you can see them with better quality if you want.

LinchpinZA
12-14-2010, 10:58 AM
I also thought of this method that could be a lot simpler, extract Z Depth with MR using an Mib_Volume shader attached to the camera's volume input.

Set this Mib_Volume to white and set the Max value which is distance, to whatever works for your scene. For objects with a cutout...use mia_material_x, leave it completely black with no reflections and map your desired alpha to the cutout_opacity on the shader and for everything else put a black surface shaders on all the objects in the pass.

InfernalDarkness
12-14-2010, 04:21 PM
@M0z:
I am unable to get the passes method (Camera depth Remapped) to work properly. I get a visible .rla file (in Fcheck, nothing else will open it), which has no beauty pass, a nice clean alpha, and the depth pass is plain black. In Fcheck it says there's a depth render there, but I can't see it.

Here's the alpha, I've only turned on one distant set of grasses to be sure instancing is working:

http://img207.imageshack.us/img207/9048/wtbdpmr2web.jpg

And when I click Z in Fcheck, this text comes up:

http://img819.imageshack.us/img819/6742/fcheckztext.jpg

This of course takes 44 minutes to render. Not sure what I'm doing wrong here, M0z? Do I have to somehow remap the depth render to get visible values, since it's output in 32-bit? Photoshop can't open the file itself...

m0z
12-14-2010, 06:11 PM
Wow that's strange.
I can open the RLA in After Effects, it works. I have the beauty pass as a RLA file and the depth pass as a RLA file.
I set the near and far clip planes in the camera to my desired values like 0.1 and 40, activated Depth in Output Settings (furthest visible depth) and just hit render. :surprised

http://bildupload.sro.at/a/images/39-Untitled-1.jpg

If you like, I can take a look at it for testing. I'd need the scene only with the landscape and the camera.

InfernalDarkness
12-14-2010, 06:21 PM
Yep, I only get one file output, which would be fine if it were say an actual, working, multi-layered .exr file with a master beauty pass, a nice alpha, and of course the depth pass. But instead, I get only an alpha, although both other channels are present in Fcheck, just pure black. And I don't have After Effects at home, alas...

Otherwise I set up the scene how you said to, far as I can tell. Is there something wrong I'm doing with my Render Passes tab in the Render Settings, perhaps?

I'd have no problem sending you my scene file as it's just a personal work, 'cept it's simply too damn big to fit in an email or anything like that. I may make yet ANOTHER test project, though, in which case we'll continue exploring things and can trade files.

So far, that's two of you (at least) with working depth methods, although with that level of noise the pass would be troublesome in post m0z? I'm just going to keep trying.

m0z
12-14-2010, 06:42 PM
absolutely @ the noise. Until I found out how to fix that it's a useless method for me. I'll keep trying too.

I just created the Camera Depth pass and hit "associate pass with currend render layer" which was the master layer. No magic there. Hmmmmmm

edit:
Z-depth values can't be anti-aliased because they necessarily must represent one pixel's position on the screen. Their color represents that pixel's depth from the camera.
interesting...

InfernalDarkness
12-14-2010, 07:47 PM
Perhaps that's my problem, right there.

I just created the Camera Depth pass and hit "associate pass with currend render layer" which was the master layer. No magic there. Hmmmmmm

I have no idea where that "Associate Pass with Current Render Layer" option is. It would appear I'm not getting a depth pass, perhaps because the CameraDepthRemapped isn't associated with anything? Would that also explain why I'm getting one rendered .rla file and you're getting two?

Z-depth values can't be anti-aliased because they necessarily must represent one pixel's position on the screen. Their color represents that pixel's depth from the camera.

This is correct, but not terribly useful, since our beauty renders ARE anti-aliased. So some sort of selection-blurring or culling must occur in post to make depth passes useful?

m0z
12-14-2010, 08:07 PM
connectAttr -nextAvailable defaultRenderLayer.renderPass depth.owner;

or

http://bildupload.sro.at/a/images/40-Untitled-1.jpg

Redsand1080
12-14-2010, 08:10 PM
This is correct, but not terribly useful, since our beauty renders ARE anti-aliased. So some sort of selection-blurring or culling must occur in post to make depth passes useful?

Well, if you are using the depth passes from the mental ray passes tab those depth passes are not anti aliased even if the beauty pass is. They are raw values. You can tell because the edges on those are always nasty even if the edges on the beauty pass are nice and soft. If you render the depth pass yourself with a shader obviously you can control the AA however you would like using the normal methods. I assume you are usually doing just that. I have no idea how each of the post z depth plugins work behind the scenes, but I assume they are doing some edge magic to take those jaggy edges in the depth pass and make them look nice when used to do the blur.

I'll repeat what I posted earlier and offer the option of rendering out the depth pass at double or triple res with no AA and then scaling down in post for depth based selections.

But if you use the Lenscare plugin (which is the best depth plugin I've used) it seems to work best with a no AA render. I did quite a few tests and every one of those tests the AA renders were terribly artifacty compared to the no AA renders.

Also its good to note that not all depth plugins in post are created equal. Each one works a little differently. I've tried the depth blur plugin that comes with Nuke and Lenscare. Lenscare totally won out over the depth blur plugin that came with Nuke. Hands down. It also rendered A LOT faster. If anyone is interested I can post up some tests I did that demonstrate all this. The Nuke z blur plugin seemed to do some really strong blurring to the alpha that looked really nasty to me. Lenscare handled that much nicer.

In my experience the plugin you use in post in just as critical as the depth render you output from your 3D package to get a decent result for post DOF. Some plugins work better than others in certain situations. So I think it's pretty important to experiment with different plugins.

m0z
12-14-2010, 08:17 PM
absolutely correct. We used the Frischluft plugin for a commercial project lately and it's wonderful.

I'll have to do a proper Zdepth with 10thousand firs soon but I guess I'll just convert my mia_materials to surface shaders with the cutout opacity.

This all isn't worth the hassle imho.

InfernalDarkness
12-14-2010, 09:42 PM
Thanks so much for your input, Justin and Mathias!

I'll give the depth pass another shot when I get home, M0z, and hopefully properly associate it this time. I am still very new to passes and have never really used them successfully before. There is almost zero help in the Maya docs about passes, contribution maps, etc. It's still all a mystery to me, so I fumble through it by trial and error. Thanks again for the screenshot, although the buttons look totally different in Maya 2009 I think I'll try the depth pass again and see how it goes.

As for plugins and whatnot for Zdepth, I don't have any. I'm using just Photoshop for compositing (since I'm only doing stills). My typical pre-Maya workflow (in Bryce) was to click "Depth Render", render my depth perfectly and painlessly after my main beauty render, then some alphas and object ID renders, and then take it all into Photoshop as Channels for easy selection.

So in Photoshop, I would simply go to my depth channel and use "Select by Color Range".

So to select a distant hill for example, I would pick that hill's color in my depth render, and then fuzzy it a bit so that either than entire hill was selected or however much distant area would be selected. This would base the selection on a falloff-by-color radius, so that some pixels would be 100%, but most would be less than 100% selected.

Then I would go back into my Layers and create new ones, apply fog and haze and other effects, which would then sit below my foreground layers but over my background layers, obviously, and it all worked fine. I would use the object ID matte renders to add to or subtract from my depth selections as necessary. This has worked well for me since 1997, but in 2004 I decided to shift to Maya and make a profession out of it all, and for the past 6 years have been missing this huge, huge element to my workflow.

I don't need zdepth for DOF effects or anything usually, just to be able to apply filters and effects based on this range of selection falloff. Hope this explanation describes what I'm working towards a bit...

...now back to more depth tests! Any critique of my workflow would be much appreciated as well, outside the depth render stuff we're discussing.

InfernalDarkness
12-15-2010, 04:50 AM
Must be something else I'm doing wrong. Now I get two new folders (proper output, so that's helpful) with one MasterBeauty render and one depthRemapped render. The .rla file in the Beauty folder is identical to my previous .rla; it has no RGB, a nice clean Alpha, and a black Zdepth channel (in Fcheck) but it is present. The .rla file in the depthRemapped folder has the Alpha as its RGB channel, a pure white render as its Alpha, and a "no z buffer" empty z-channel. Slayed here on this one, M0z. Perhaps it works better in newer versions of Maya? I'm stuck with 2009 for now.

If I seem like an idiot here, you must also imagine that I feel like more of one.

Going to launch into another surface shader (luminanceDepth) test once patience returns!

m0z
12-15-2010, 06:10 AM
Fyi: I used the "camera depth" pass, not the remapped one. Not sure if thas he reason though :shrug:

InfernalDarkness
12-16-2010, 02:43 AM
Well I found out that (evidently) you have to have LIGHTS on in a scene, before you can see anything in your beauty pass! Must have turned them off some time ago testing the surface shader method or something... I'm a fool. But still no depth pass. This is what Fcheck looks like in all three channels now:

http://img535.imageshack.us/img535/6028/mr4webtrio.jpg

(most of the plant layers are off for the sake of speed... rendertimes down to 11 minutes, so 9 minutes translating and 2 minutes rendering now)

So I learned a lot about passes so far, and fixed one of my obvious mistakes by turning on the sun/sky so as to be able to see anything in the beauty pass. I'm hoping there's yet another imbecilic mistake made somewhere along the way, too.

Gonna hold off on pass-testing for now and focus on the surface shader (luminance depth) method to isolate why I couldn't get that to work previously. Possibly some other rookie mistake along the way.

So far the three methods I can see are:

1. Depth pass - quicker and more painless, 'cept no visible results yet. (Edit) Going to try a non-remapped test next instead, and fix my camera's near and far clipping first.

2. Surface shaders - ....pending re-research. Lum_depth would fall into this slot, except no support for cutout opacity that I could see, so manual surface shaders are up next.

3. Puppet_z - only respects alpha cutout opacity in some cases, gotta isolate why/when still. If Puppet's still around, feel free to stop by and mock/berate me for misusing your shader.


Any other ideas to help understand this topic would also be very helpful!

Redsand1080
12-16-2010, 01:07 PM
1. Depth pass - quicker and more painless, 'cept no visible results yet. (Edit) Going to try a non-remapped test next instead, and fix my camera's near and far clipping first.


This may be a stupid question and I may have accidentally skipped over where you specified you did this, but just in case, did you set the far clipping plane value for the remap to the edge of your scene? The 'ole method of grabbing a distance node to go from the camera nodal point to the edge of the scene gives a good value for that. Again, that may be a stupid question, but just in case.

And if you are getting no visual results for the remapped version and you did set the planes up correctly you're definitely not going to get any visual results for the non-remapped version in fcheck. That version comes out in floating point space and 9 times out of 10 requires some tone mapping to actually see anything at all even if all the data is present.

InfernalDarkness
12-16-2010, 04:35 PM
Not a stupid question - gotta explore all angles to solve complex problems like this one, with what appears to be almost infinite variables. My depth is set to .01 near and 300 far, which fits my scene well for scale, and also worked initially with the Puppet_z. Like I said, I can get a depth render - just not with all instances and cutout opacity working:

http://img375.imageshack.us/img375/2835/wildtwistymastermr36lea.jpg

For the second part of your post...

And if you are getting no visual results for the remapped version and you did set the planes up correctly you're definitely not going to get any visual results for the non-remapped version in fcheck. That version comes out in floating point space and 9 times out of 10 requires some tone mapping to actually see anything at all even if all the data is present.

How do I go about tone-mapping any of these files, and which one should I be trying to do this to? With the passes method, I get a MasterBeauty folder file and a depthRemapped folder file for each render, but there's no z-channel in my depthRemapped file at all, and no alpha. The RGB channel of this file is identical to the alpha from my MasterBeauty file, and the alpha is plain white. No Z-information in this file. Should I be working with the MasterBeauty file's black (but present) Z-depth information? And how would I save this out to a format that Photoshop recognizes?

Redsand1080
12-16-2010, 05:39 PM
How do I go about tone-mapping any of these files, and which one should I be trying to do this to? With the passes method, I get a MasterBeauty folder file and a depthRemapped folder file for each render, but there's no z-channel in my depthRemapped file at all, and no alpha. The RGB channel of this file is identical to the alpha from my MasterBeauty file, and the alpha is plain white. No Z-information in this file. Should I be working with the MasterBeauty file's black (but present) Z-depth information? And how would I save this out to a format that Photoshop recognizes?

In Nuke I use the Grade node to tonemap the camera_depth pass. This is the only one that requires tonemapping. The depth_remapped is already 'tonemapped' in a way. It's 'remapped' so it fits into the 0 to 1 space of a regular 8 bit file. No tonemapping required for that one.

Some depth plugins may require floating point data...if this is the case then no tonemapping of the camera_depth pass is needed. I've found Lenscare works much better if I normalize the values to a 0 to 1 space so when I use that plugin I always tonemap using the grade node in Nuke. I know you said you are doing your work in PS and I can't be of much help there because I've never actually attempted this process in PS. My first guess would be the exposure tool, though, if you wanted to tonemap the 32 bit file down to the normalized 0 to 1 range.

There should be no z channel for any of the render pass depth passes. It is stored in the rgb channels of that file. I can't remember off the top of my head if it stores the depth info in only one of the rgb channels, or if it is present in all of the rgb channels. A quick look in fcheck or PS would tell you that pretty easily though. Either way, you only need to work with one of those channels, either the r, g, or b will work. But yea, don't be looking for a specific 'Z' channel for the depth_remapped or camera_depth passes. Also, no alpha comes with those passes by default because no alpha is needed for a depth pass. You only need depth information, not transparency information. I believe you can override this behavior in the attribute editor for that pass...but they may have locked the ability to edit this for the depth pass. I can't remember exactly and at work we still use 2008, so I can't check any of this right now.

I hope I wasn't too confusing. If I was let me know and I'll explain it better.

MasonDoran
12-17-2010, 05:53 PM
32 bit Depth channel is stored in EXR, otherwise you can render it to Tif.

32 bit will allow you to grade it to any values you want, which can also do with exposure controls in Photoshop. You will then have to convert to 8bit if you want to use with filters and what not.


Very useful if you want to isolate a very specific depth.

InfernalDarkness
12-17-2010, 06:34 PM
32 bit will allow you to grade it to any values you want, which can also do with exposure controls in Photoshop. You will then have to convert to 8bit if you want to use with filters and what not.


Very useful if you want to isolate a very specific depth.

Not to be rude, but this is precisely the reason I'm trying to render out the z-depth. I already knew all these things - the problem isn't knowing what z-depth is for, the problem is actually getting it to render at all.

32 bit Depth channel is stored in EXR, otherwise you can render it to Tif.

Where is this stored? Which file is this stored in, and how do I access this information from Photoshop? And I've tried TIF as well, and RLA, and BMP, and IFF, and EXR, and Targa. So far coming up with a big fat nothing.

I know you're trying to be helpful so I apologize for being a bit caustic. But compare rendering z-depth in mental ray for Maya to every other rendering package on the market, and it's just plain retarded. Every other application and renderer nails it fine with almost no hassle. MR for Maya = the stupidest, most broken, disjointed and horrendous implementation of rendering available.

m0z
12-17-2010, 07:45 PM
switch to vray then...

(one of our co-workers always tries to convince us to use max & vray :wise: :D haha)

I hear ya. Motion Blur is another story too...

InfernalDarkness
12-17-2010, 09:20 PM
There are many reasons to switch to Vray, and a few to use Max as well (such as OnyxStorm for trees, etc.), but it's also a budgeting issue. I can't justify to my employer the purchase of Vray for Maya, since we don't need it for my arch/viz work. We have no competition up here in today's market, so I'd basically be sacrificing my next raise. But this is also why I still use Maya 2009 - there's simply no reason or extra functionality that 2011 brings to the table for my actual work.

My hobby, or personal artwork, is mostly landscapes and gay castles and flowers and stuff. This is where the z-depth hangup comes in for me. After 6 years of Maya I can't go back to Bryce - it doesn't even have viewport texturing, for the love of god! But I did pound out a lot more artwork back then, that's for certain. Some of it in a day or less. Sure, my personal quality standards have changed dramatically too - and that's why I love Maya. MR's results are amazing too, I just can't wrap my head around this retarded z-depth problem.

I'll put a man on the moon by hand, by myself, before I get a decent depth render, it seems!

So far, what I've gathered (trying to stay positive here, and not sound like a sissy):

1. Passes require Nuke or another compositor to work properly. Photoshop alone won't do the trick.

2. Passes are retarded - thus the need for Mercuito's Core Pass System. But alas, not for 2009 yet.

3. Z-depth is stupid, and I'm an even greater dummy for not being able to pull it off in any but the most basic scenes. A few spheres instanced? No problem. A real scene? No way in hell, here.

What would really be nice would be to simply use Maya Software to render a depth pass. This would work, except that Maya Software doesn't use BSP2. So given the complexity of my scenes, I'd need at least double the RAM I have, if not quadruple, to do this in MS. Brutal.

I apologize for my negativity. I know you're all trying to help, but I'm really getting nowhere and just need to shut up and step back for a few days or get drunk and just cry it all out. Perhaps a bottle of merlot and an appropriate chick-flick emo-film will straighten my mind out. Aliens vs. Predator or something.

Thanks for all your input so far though, my friends! I know it's me that is failing - not you guys.

MasonDoran
12-17-2010, 09:32 PM
Photoshop doesnt support layered EXR, but After FX does....and i believe there are plugins for photoshop that do also.

Otherwise you would have to use other applications to get access to the other layers.

MasonDoran
12-17-2010, 09:38 PM
And Fcheck doesnt support a single channel (R and not RGB) which is what a depth pass is. This is why you keep seeing black, when you load the render pass in the Fcheck.


Just did a test, works the same with .iff And you will get a 32 bit depth pass as a single channel in a Depth layer.


link to the .iff plugin:

http://www.3dbuzz.com/vbforum/showthread.php?119468-photoshop-IFF-plugin

InfernalDarkness
12-18-2010, 05:30 AM
Thanks again for your help and positive attitude, despite my not-so-positive one, MasonDoran! That may be very helpful for me in the future, but for now I've set aside the passes method and revisited my barebones test scene. Just had to vent a little and cool off or whatever, but your information explains a lot why my files weren't visible in Fcheck especially, and I'll try the passes method again tomorrow.

Meanwhile, back in my test scene using the Puppet p_z shader, made some progress and broke it all down from scratch so I can replicate and dissect my workflow for later. Here's what I came up with:

http://img253.imageshack.us/img253/9643/zdepthpuppetinstanceswo.jpg

Here's the p_z shader working with instances. The center sphere is original, the other four are instances. This only appears to only work in Regular BSP but I'll test it again, and try Large BSP and BSP2 as well. Good news is that RAM didn't skyrocket at rendertime the way it does with Maya Software, so at least instancing appears to be working under Regular BSP using this shader. Also the cutout opacity is of course working properly, with the backfaces' distance displayed as well.

http://img831.imageshack.us/img831/6641/zdepthpuppettreeworking.jpg

Same tree from the other scene. I replaced the file node for the alpha from the previous render with the "WildTwisty" tree's leaf file to keep it down to one cutout-opacity-p_z and one without cutout opacity only, for now. As you can see, the cutout opacity is working for me still here. (right-click View Image to see full res) A bit of .jpg artifacting here on the web, but you can see that the foremost branches and leaves are indeed brighter than the rear ones! Sweet!

http://img225.imageshack.us/img225/4927/zdepthpuppettreeinstanc.jpg

And here I've instanced the tree a few times. This is the part where (normally) Regular BSP starts to fall apart, and thus why I can't just switch to Maya Software for a depth render in big, complex scenes. Everything appears to be working for me finally here!

Next I just need to learn enough about Render Layers to make the Main Render use BSP2 and the PuppetZ Render use Regular BSP, etc. A few more things to learn, but it's working properly for me now!

I apologize for all my naysaying previously. I'll be launching back into passes with a fresh save of this scene (new name, folders, etc.) to keep things simple.

m0z
12-18-2010, 09:45 AM
For the renderlayer thing: switch to the layer. Go to render settings and right-click on acceleration method -> create layer override
Then just switch to whatever you like :)

3DRenderer
01-24-2011, 02:23 AM
So what are some peoples render settings that are getting them the best results. I ask only because I have heard and read many different values. Here is what I think is correct but not sure.
http://i1232.photobucket.com/albums/ff379/Smokcan2/rendersettings.jpg
Dont know why I tried those settings of AA 0,0 and triangle filter, because with my original settings of 1,3 and Mitchell Filter, my renders seem to look much better...

crispy4004
01-24-2011, 07:28 PM
Getting a good Z-depth pass requires a separate render anyways so I usually handle it by creating a new render layer, overriding all the materials with say a black surface shader, lower the settings, 2x or 3x the render size, and add a camera depth remapped pass with adjusted values. The Render Pass is not aliased so it will give you more accurate results than resorting to the triangle filtering.

Scale that depth pass down in your compositor and you should be good to go. If you don't have Nuke or Fusion, use Toxik, it works just fine. If you don't have that, you could try Blender's compositor which is free of course. This workflow should work in most cases, but I'm not sure about scenes with mr_proxys.

InfernalDarkness
01-25-2011, 02:46 AM
Getting a good Z-depth pass requires a separate render anyways so I usually handle it by creating a new render layer, overriding all the materials with say a black surface shader, lower the settings, 2x or 3x the render size, and add a camera depth remapped pass with adjusted values. The Render Pass is not aliased so it will give you more accurate results than resorting to the triangle filtering.

This method does not work (in my scenes) for two reasons - it doesn't respect BSP2 proper and also would require a separate shader for each and every leaf-shader or plant-shader with opacity. In my tests it was difficult to get surface shaders to respect cutout opacity at all, therefore my Puppet_z shader tests.

Scale that depth pass down in your compositor and you should be good to go. If you don't have Nuke or Fusion, use Toxik, it works just fine. If you don't have that, you could try Blender's compositor which is free of course. This workflow should work in most cases, but I'm not sure about scenes with mr_proxys.

I need to look into Blender's compositor, but I'm not doing any animation, and you would think Photoshop would be enough. But it's just not. (sighs)

daddyo
01-26-2011, 07:36 PM
I'm still trying to understand why ppl don't use a shader that creates a depth pass that is antialiased and supports transparency if needed, so that it matches their geometry.

Can someone explain me the benefit of this jaggy zbuffer passes? I made a Zdepth shader that works great, includes a height field pass, and supports transparency for cards and other stuff...

m0z
01-26-2011, 08:00 PM
share it? :cool:

InfernalDarkness
01-26-2011, 08:11 PM
I'd love to give your shader a whirl, Daddy-O. So far, only the Puppet_z shader does z-depth properly for my compositing needs, and it still requires a TON of work to make it function properly. But Puppet knows what he's doing - best shader thus far I've found.

But I'd love to have height and z-depth in one shader, with support for cutout opacity and BSP2!

daddyo
01-31-2011, 06:03 PM
Here's the shader in question:

www.cookingwithlasers.com/files/RaphZ_shaders.rar

I packed two versions in there. One is the full automated one, but my setup has issues with world coordinates on some scenes, or because the camera move is so complex, the locators get 'inverted' and the math no longer works for Z depth. In that case, use the 'simple version' for which you just input clipping plane values in the set range node. Directions can be found in the notes for the locator group you'll find in the outliner when you import into your scene.

Note that you can easily replace the simple gradient with a ramp to create a focus field. Just replace the blender nodes with a ramp, pipe the output from the set range into the y or v of your ramp, and bam...

For both versions, red channel has Z, green is Y. Since its built from maya nodes it should work without installing anything, and with any render package that supports the nodes. plug and play. Thanks for any feedback.

InfernalDarkness
07-11-2011, 10:46 PM
Tested this one again as the topic came up in another thread.

Works great for basic stuff, but we already had that covered. When cutout opacity and instancing come into play, it's not producing any different results than the standard depth remapped method, which does not support cutout_opacity from the mia_mat_x.

InfernalDarkness
07-16-2011, 06:38 AM
I can happily report that I'm able to pull out nice clean z-depth passes now in Maya 2012! Not sure what I was doing wrong in 2009 to be honest, or if the passes system was just broken. Thanks for everyone's support on this topic, especially Bitter who made it seem so easy that it became easy!

m0z
07-16-2011, 10:25 AM
how-to? :deal:

InfernalDarkness
07-16-2011, 07:37 PM
I'm just using the Depth pass, and the DepthRemapped. Still having a hell of a time with file formats though. I do get a clean .tif file now but the tonemapping part eludes me. Perhaps I'll render my master beauty as an 8-bit file or something, not sure how to make it all work.

But I'm now getting a depth pass which incorporates the cutout opacity from my mia_mat_x_passes shaders without any headaches or BS, which is precisely what I needed! Much more efficient than making and assigning tons of new shaders to everything, when I know that the cutout opacity data already exists in the mia_mat_x_p.

Previously, I couldn't get the depth pass to respect cutout opacity, thus all my frustration.

m0z
07-17-2011, 09:18 AM
great if it finally works for you. I just tried the whole thing again - with 32bit tif and it works perfect with the nuke zblur. :applause:

InfernalDarkness
07-17-2011, 06:24 PM
Still having a bit of a headache with the file formats. I don't use Nuke (yet), how would you go about tone-mapping a 32-bit .tif in Photoshop instead?

m0z
07-17-2011, 09:36 PM
Basically I just use the Exposure (ps) or Color Correction (nuke) adjustments. It should look like the 8bit with 2.2 then afaik.

InfernalDarkness
07-17-2011, 10:08 PM
Using my scene from earlier, I figured now'd be as good a time as any to dive into the .exr filetype. I was having no luck with .tif, .iff, or .bmp of course. After playing around for awhile, it seems I finally "got it down", and feel rather silly for all my complaining and crying here and abroad on this topic!

Same scene from earlier, only using the depth_remapped pass and the .exr filetype in Photoshop. Still gotta work on linear lighting in a real scene, but this one passes my cutout_opacity tests and I get a decent depth pass finally, albeit with some tweaking of the levels.

Beautypass (not beautiful this time):

http://img594.imageshack.us/img594/7461/zdepth2012exrtest5diffu.jpg

Depth pass:

http://img829.imageshack.us/img829/882/zdepth2012exrtest5depth.jpg

I think I need to override my file filtering on the depth pass or something, it's antialiasing the cutout_opacity, but that's a small hiccup. At last, a quick and painless depth pass! Thanks for all your patience and support people; I'm simply posting up these latest tests in case anyone else runs into these problems.

Edit: Here's a comp test, just adding some colored haze based on the depth pass, similar to adding distance haze in a heavy forest scene for example:

http://img69.imageshack.us/img69/5565/zdepth2012exrtest6color.jpg

m0z
07-18-2011, 09:05 AM
if you select the pass in the attribut editor there's a checkbox for filtering. I guess that's what you're searching. ;)

rchr
09-10-2011, 04:32 AM
Doesn't work with MR Proxy still though...

oracio
01-08-2012, 08:46 AM
But I'm now getting a depth pass which incorporates the cutout opacity from my mia_mat_x_passes shaders without any headaches or BS, which is precisely what I needed! Much more efficient than making and assigning tons of new shaders to everything, when I know that the cutout opacity data already exists in the mia_mat_x_p.

Sorry for jumping an old thread.
Correct me if I'm wrong but you got cutout opacity from a mia_x mat to work with only the Depth Remapped Pass?
If so, how?
The best I could do with the Depth Remapped pass is when I have a mia_x mat with a cutout opacity file based on alpha and not luminance map (B&W texture), but still the Z-pass showed me just the areas in my map where the opacity is 100% and discarded semi-transparent areas.

InfernalDarkness
01-09-2012, 11:19 PM
@Oracio: The trick was something Bitter mentioned, made me feel rather foolish.

Use the mia_material_x_passes for anything pass-related. If you already are, I don't mind helping you dissect the issue further. But the regular mia_mat_x will not spit out Cutout Opacity to the passes, which was part of my struggle initially.

Bitter
01-10-2012, 04:58 AM
Can someone explain me the benefit of this jaggy zbuffer passes?

Because filtered samples from two objects at two different locations results in a pixel with a mixture of hither and yon distances (object distance A and object distance B get merged). Meaning the resulting value belongs to neither object (or more objects that overlap)

123 Main Street and 364 Main Street filtered together (anti-aliased) might be 214 Main Street.

It's a technical concern for correct compositing where you may use something like a z-compose. It will tend to fall apart in the case where your values are filtered together.

oracio
01-10-2012, 02:45 PM
@Oracio: The trick was something Bitter mentioned, made me feel rather foolish.

Use the mia_material_x_passes for anything pass-related. If you already are, I don't mind helping you dissect the issue further. But the regular mia_mat_x will not spit out Cutout Opacity to the passes, which was part of my struggle initially.
Hi InfernalDarkness,
The thing is that the Z-Depth pass doesn't work with semi-transparent maps.
In the end my solution is to use the p_z shader with a little script that I wrote that does the automation of replacing the current shader with the p_z and connecting the opacity files (should be used on a new Render Layer).
You can find it here:
http://forums.cgsociety.org/showthread.php?f=87&t=1027613&page=2

Thanks :)

InfernalDarkness
01-11-2012, 11:05 PM
I did read that thread as well, hope you're making some progress! The problem with semi-transparent masks is outlined best by Bitter above, though. In your compositing application, you may have issues making it work how you want. But I really hope you don't! This process was a nightmare for me as well for a long time, but it gets easier. Keep at it!

InfernalDarkness
01-25-2012, 06:20 AM
Oracio, please excuse my triteness in earlier posts. I'm trying to pull z-depth with cutout opacity on a new scene and it is failing utterly. I have gone through every single step outlined here and in the other threads, and alas... Utter failure on my part to replicate anything usable.

I'm far too frustrated to continue tonight. Will approach this problem yet again (and likely look into Vray yet again, too!) in the morning. I'd say I can't believe it is so goddamn difficult to achieve this simplest of tasks in mental ray, but it is very, very believable.

http://img862.imageshack.us/img862/3463/sgdepthtest7.jpg

There are two shaders here, both mia_mat_x_passes. Note the foreground objects work fine, the instances do not. And what the hell is that two-pixel dot doing there, on the mid-right?!? (grins)

oracio
01-25-2012, 07:19 AM
Hey Infernal,

Have you tried the p_z shader? it works for me with instancing.
Create a new Render Layer with all your objects.
Create a new p_z shader for each of your materials in your scene and connect
to it your cutout opacity texture file.
If you want to automate it (because it can get tedious), you can use this small script
that I created:
http://forums.cgsociety.org/showpost.php?p=7212182&postcount=26

Good luck :thumbsup:

InfernalDarkness
01-25-2012, 08:42 AM
http://img221.imageshack.us/img221/9961/sgdepthtest9.jpg

Duplicates working fine; instances are not. Weird reversals, artifacts, and the extraneous spot on the right. I hoped my depth was just off, and I was seeing a repetition of the map, but increasing it from 300 to 500 to 1000 made no change in the instances, only in the duplicates.

I have "leveled down" evidently, but won't give up just yet.

@Oracio: As mentioned already (http://forums.cgsociety.org/showthread.php?f=87&t=941774&page=1&pp=15), I have used the p_z shader successfully in many tests but it has many issues as well. The biggest one being that's a render layer, not a render pass. But also you would be creating one shader for each leaf/flower/plant shader, and in a simple scene this may be workable, but in a scene with 20 or 30 (I believe this scene has 23) shaders it becomes quite a nightmare to work with.

The goal of using a render pass is that it takes almost no extra rendertime, as the data was already utilized during the initial render. And it needs to be relatively painless and re-doable on the fly, for big scenes and animations. The theory works fine; the practice has many variables and I simply have not isolated them all yet. One little checkbox somewhere I missed, this time.

Edit: resolved.

http://img254.imageshack.us/img254/5604/sgdepthtest13.jpg

Problem re-re-re-resolved. Having no geometry as a far-end evidently was the problem. A simple poly plane backdrop solved the issue outright. All except the original two objects are instances, and the z-depth appears to be working flawlessly. No AA or anything, as you can see in the perpendicular object planes! Some tone-mapping would help in comp, but it's obviously working again and respecting cutout opacity. My guess is the lack of any backdrop was tossing back an inverse result, thus the previous artifacts and weird dots.

I just couldn't call it a day before figuring it out again. Posted this in case anyone else runs into problems with z-depth...



(Another Edit!)

Sorry Dario, I believe we were typing at the same time?

ytsejam1976
01-25-2012, 09:00 AM
Infernal, please what happen on Instance depth? Maybe i miss something on your images, but if you please explain or link the images?
Thanks

InfernalDarkness
03-01-2012, 01:26 AM
@ytsejam1976: I think we were cross-posting, and hopefully I answered your questions in my previous post? If not, ask away and I'll try to be more specific.

But I'm running into a fun issue with the .exr file type. I get one .exr file per Render Layer, as its supposed to be, along with another .exr file for each that has "_depth" appended to the filename. I am unable to open the second file or use it in any way, and my depth pass data is not in the first .exr file either. I'm using 16-bit/half as my output mechanism, but the 32-bit float file has the same effect.

Does anyone know how to use .exr files with depth passes, in Photoshop? What am I doing wrong? I thought it would spit out one .exr file with multiple channels or layers, such as Alpha, depth, whatever you tell it to...

InfernalDarkness
01-03-2013, 05:41 PM
Here's how this test scene "ended up", if anyone's interested. I feel that z-depth really helped develop an atmosphere in this picture.

http://img407.imageshack.us/img407/6400/wildtwistymr52webb.jpg

joie
11-03-2013, 09:05 AM
That's a beautiful atmosphere for a test scene! :)

I'm running into zDepth issues with proxies..., I read that you need the zDepth pass in the scene BEFORE exporting the proxy assembly, but it didn't work for me... :(