PDA

View Full Version : Depth of Field Streamlining.


kweechy
01-18-2010, 04:26 AM
Been doing some extensive DoF work that has been turning out extremely well with Frischluft's Lenscare plugins, however right now I am simply using Z images that go from white at the camera to black at a point I determine.

My question is this: how would you set up (preferably in Maya) a shader that will be white at X distance from the camera and fade to black as things get further away from that point?

The reason I ask is that I'm envisioning a workflow that takes the guesswork out of post-DoF work, but leaves all the benefits of the speed it has. I picture being able to simply set my DoF's focus point to 255 white and leave it there for my entire comp, controlling where this 255 spot rests in Maya itself in my shaders.

Keying Z focus points in post is simply far too big a pain and far too artificial feeling from what it really should be like.

Kev3D
01-18-2010, 05:24 AM
I read this post whilst rendering a zdepth pass that does something similar to what you are after.

I made a new render layer and gave it Luminance Depth preset.

I then picked the 'Set Range' node and broke the connections for Old Min and Old Max.

I used the Distance Tool to measure between the camera and the object.

In my scene, my camera starts close in on the cap of a bottle and slowly cranes down and back to reveal the face.

I parented one of the helpers from the Distance Tool to the camera and the other I animated by hand, this way I was able to see exactly where the point of focus would lie while I played the animation in the viewport.

Then it was a simple matter of writing an expression that linked the Old Max to the distance value from the Distance Tool. I gave it a multiplier so the point of max distance wasn't completely black (how would the focus falloff behind the bottle work in this case?). I'll just use the multiplier to figure out what distance I need to type into After Effects for it to work.

I left the Old Min on '0' but you could change that to whatever distance you liked. you could even do the same Distance Tool trick.

Anyway, it hasn't finished rendering yet so I don't know how this will work but I don't foresee any issues at the moment.

Kev3D
01-18-2010, 05:54 AM
Just checked the render and it appears to work perfectly with Frischluft Lenscare. The transition from cap to label worked better then I hoped it would.

kweechy
01-18-2010, 08:31 AM
Good tips, I'll give something like that a shot!

One issue I can think of is that I tend to have a bad time with generating Z Depth passes for objects that have cutout sections...for example, when rendering a tree, you have hundreds of poly planes with leaves on them, but for the Z Depth, naturally you only want the leaf itself to contribute and not the rest of the leftover polygon.

My best solution so far for this has been to generate my Z Depth with MR using an Mib_Volume shader attached to the camera's volume shader. Set this mib_volume to white and set the Max to whatever works for your scene. Put black surface shaders on all objects in the pass and 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.

How do you go about rendering those kinds of 'cutout' objects with the preset Luminance_Depth that Maya has to offer? I tried breaking the material override, cloning their material and mapping the transparency of the surface shader with my desired alpha map, but Maya doesn't seem to love that solution and I tend to get some ghosting going on.

Kev3D
01-18-2010, 08:50 AM
How do you go about rendering those kinds of 'cutout' objects with the preset Luminance_Depth that Maya has to offer? I tried breaking the material override, cloning their material and mapping the transparency of the surface shader with my desired alpha map, but Maya doesn't seem to love that solution and I tend to get some ghosting going on.

That was the solution first came to mind. Have you tried chucking the depth texture into the self illumination slot of a lambert instead. I'm not sitting in front of Maya so I can't check but I reckon a lambert should give you more control.

kweechy
01-18-2010, 09:45 AM
Actually now that you mention it...perhaps I could chuck the Luminance Depth preset shader into the additional_color slot on mia_X with my alpha pumped into the cutout_opacity. Mia_X seems to handle cutouts better than any other shader I've ever worked with.

israelyang
01-19-2010, 03:40 PM
Hey Lorne
Have you looked at these?

http://www.djx.com.au/blog/2007/12/11/depth-of-field-pass-for-maya-or-mentalray/
http://homepage.mac.com/bauer/portfolio_shaders/zDepthDOF/zDepthDOF.html

Kev3D
01-20-2010, 12:47 AM
Wow! Those links were really handy.

One issue I ran into was that Frischluft says that there should be no anti aliasing in the ZDepth render. Is this possible in either Maya Software or Mental Ray? They both appear to apply some AA no matter what I do.

Kev3D
01-20-2010, 04:02 AM
Just an update on my experimenting , I found that an AA setting of 1,1 with a Lanczos filter of 4,4 gave a proper, non AA render.

The Mental Ray shader didn't work so I re-created David's shader network. Too complicated for me to understand all of what was going on but it does work. The only thing I found was that with Frischluft Lens Care, the depth map had to be inverted for it to work properly otherwise it looks really bad.

kweechy
01-20-2010, 06:26 AM
That's funny, I was literally about to click reply and say "use Lanczos set to 4,4 and 1min/max AA sampling" until I scrolled down.

0min/max seems to work as well.

But then of course you end up with nasty edging artifacts especially when working at lower resolutions which brings me to my next set of questions for someone out there:

1) When doing "professional" DoF work to your CG pieces (by professional, I mean small studio, not insane budgets) do you render your Z Depth images at 2X+ size to work with them and avoid edge artifacting?

2) If this is the best way...do you also render all color pass information at that size as well or merely scale your renders by 2, apply the DoF and scale back down? Also if that is the best way, what tends to be the minimum scale boost to achieve the desired smoothness and quality of work without killing render budgets? Ie: render @ 1.5X, 1.25X maybe even 1.1X is good enough?

3) Nuke and other comprehensive compositing packages have extensive 3D capabilities...is it possible to simply import your 3D scene into Nuke and use that to drive DoF instead of rendering out Z Depth passes?

I'm getting some really beautiful results here, but the edges don't hold up to scrutiny. All I can think of doing for the moment is render everything double size, work at that resolution, then scale it back down to what I need (NTSC on this particular project, so rendering double isn't a huge deal...but if it were a 720p or 1080p project, it could start to get bad).

Edit: Uploaded a quick test animation: http://vimeo.com/8859653

kweechy
01-20-2010, 06:39 AM
Israel how ya been man! Long time since I've seen you now.

That plugin is pretty much exactly the concept I was describing, great link. It does, essentially, what you tell a DoF compositing plugin to do.

However...I can instantly see a major flaw that people should absolutely avoid when using that shader:
- In a few of the examples on his site, the depth ring is black at the plane of interest, then fades sharply to white from there. I assume his intent was to achieve a narrow depth of field but doing this, but it's completely unrealistic as your scene's depth information is brought to a screeching halt the instant the gradient hits white.

Set it up the way he does on the site, with the plane of interest where you'd like for it to lie...but never let the gradient go to full white. That's all really, then you're in good shape.

There's still the big anti-aliasing issue though no matter how you generate your Z images.

israelyang
01-20-2010, 02:24 PM
Hi Lorne,
Yeah you are right that could be an issue. But with something like the z-depth where you need high precision you should render it out with a 16 or 32 bit float format, as long as this shader setup in Maya does not clip anything above white to white, the float output would keep all the pixel values outside the 0-1 range. I haven't worked with Frischluft DOF for a whilte, but if it only takes 0-1 range you can always shrink your z-depth output to within that range.

Kev3D
01-20-2010, 11:36 PM
@ kweechy:
I'm still pretty new to the whole thing, I've only just discovered Frischluft, before that I was using the Adobe Lens Blur and wandering why my depth of field always looked crap.

If I understand the Lens Care documentation correctly, you should render off the depth pass aliased and at double res to get the best results. It suggests that the beauty pass should be rendered off at double res as well with AA settings turned down to compensate but it is acceptable to scale a normal res render up for the depth of field blur and then back down for the final composition.

The latter is the workflow I took for my latest project. This has worked very well for me. When my camera is above the lid and the rest of the scene is blurred, I used to get buzzing around the edges of the lid. Now it looks smooth.

@ isrealyang
Good point about the EXR, should allow a lot more information, I'll have to look into that. However, using the method you posted earlier, you effectively get 512 levels in an 8-bit render, this should surely be enough for most scenes.

sdyer23
01-28-2010, 02:24 PM
Hey guys,

This is a great post topic. I was wondering though if the proposed work flows and workarounds would be similar for 3DS Max? I mean to my understanding, Mental Ray is Mental Ray but I also know that each program has their subtle differences.

The links presented by israel were very helpful and I was able to find a plugin for Max, but I was not able to get it to work, stating that the plugin was not loaded or that it would not load. :-( Most disheartening, to say the least.

So yea, Would a similar work flow for DoF be the same as presented for 3DS Max, or would it be different. and if it is different, how so?

Thanks in advance.

SD

CGTalk Moderation
01-28-2010, 02:24 PM
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.