View Full Version : Quick Tutorial: Zbuffer, DOF, Lens Blur
08-25-2005, 06:40 PM
Hello my Lightwave homies. I've seen a few threads kicking around with people asking how to do zbuffers and such, and I thought I'd post a quick tutorials based on something I'm kicking around with a few guys here at the office.
Okay. If you are like me, using the Lightwave Zbuffer isn't intuitive enough. I always get wacked out results and pull my hair out. If you are one of the few enlightened ones, feel free to chirp in on how to get good results easier out of it, because it would save a step here.
But, since this is MY tutorial, I'm going to do it MY way. We're going to generate a ZBuffer with lightwave's distace fog, and we're going to enjoy tweaking it with realtime previews, which you don't get using the "real" zbuffer.
Here we go:
Step 1. Here is my basic city plate. We rendered this in fprime. It's a bunch of low low poly buildings with texture maps made from going downtown LA and shooting buildings with a Digital Elf. Our resident modeling genius Andy whipped this out in almost no time at all :) . We threw some other lights in for beautification.
Here's the wire:
For this technique to work, we have to set ALL the objects in the scene to render black. I use the Scene Editor to select all items, then under the Scene Editor's Property tab, select Object:Render Flags, and toggle all of your items to "Matte Object" by checking them all at once in the Matte Object colum.
We want to make our fake z-depth/Zbuffer. So open up your volumetric controls and turn on Linear fog. Linear fog is one thing Lighwave manages to preview nicely at this point. This is going to give us our z-depth. Make sure to set your fog color to white.
Also set your scene backdrop color to white so that areas of the render with no geometry render as far away.
08-25-2005, 06:41 PM
Make sure you turn on the OpenGL fog preview in the display panel:
when you do, you will end up with a nice z-depth/Zbuffer preview like this:
It's not 100% accurate, but it's close enough to dial in your distance fog settings to get your z-depth right.
I rendered this with PLD 1 pass to save time (even though I'm using motion blur).
It's not perfect, but it works great for a z-depth/Zbuffer.
OKAY. So what do you do with this zbuffer after you've rendered out the sequence? It's up to you and your compositing skills. Let me show you how to fake DOF with it using the nifty Photoshop Lens Blur plugin. I've just started tinkering with Lens Blur, so with a little experimentation you will get cooler results than me, but this will get you started.
Step 5. I'm working with animation, and I use AFX to composite most of my stuff (not the best, but it's way more powerful than some people give it credit for). Since I want to use the Lens Blur from Photoshop, I can't use AFX to make my depth of field because AFX doesn't yet have this ability (hopefully it will soon!).
The Lens Blur filter in photoshop takes the alpha channel from an image and uses it to control the ammount of bluring of the image. This is way different than blurring an image and mixing it back with an alpha channel because blurring that way gives you one constant blur radius and "screens" it back with the alpha, which doesn't look good. The Lens Blur filter takes the alpha channel's grey value and uses it to control the radius and other features of the blur on a pixel by pixel basis. It's not "real" DOF, but it's really pretty good for faking it. Hopefully that makes sense. I'm in a hurry so my writing is degrading.
To use our rendered plate and seperately rendered z-depth image, we have to combine them into one file. I bring both my plate and my z-depth into After Effects, create a new comp with both layers, then set my base plate to track-matte the z-depth render based on Luma:
Then render this out to a new sequence with the alpha imbedded and the matte set to unmatted. This will leave the fill unaffected by the matte.
08-25-2005, 06:42 PM
Step 6 (who's counting?).
Now you've got your files ready to blur! Open up a frame in Photoshop CS or CS2 and select Filter -> Blur -> Lens Blur.
my screen looks like this:
You are almost there! The rest is up to you. Set the Depth Map source to Alpha 1. Play with the iris settings to control your Blur/Brokeh quality and shape. Specular highlights nicely fakes the blurring of bright objects into spots of light. Play with the brightness and threshold until you find your look.
You can see in my image above that the far buildings are now thrown out of focus, and the close ones are in focus. I can roll this focus anywhere I want along the focal plane with the Blur Focal Distance setting.
Here's a more extreme example:
Since we made an animation, we would have to batch process the whole sequence through photoshop in order to apply this affect to every frame. What I do is dial in my blur in one frame, then hit undo, then record a new Photoshop action and re-apply the filter. The action will record your blur settings. Then I batch all my frames with that action, and I'm done. Bring it back into your compositng app and finish the shot to your satisfaction.
I hope this answers some questions and helps a few people out. Post questions if something doesn't make sense. Sorry if it's a bit of gibberish. I don't have time to edit.
08-25-2005, 06:49 PM
08-25-2005, 07:07 PM
oh yeah. MODS: I put this here instead of tutorials because nobody looks there *ducks*, and I figured more people could see it here, then maybe you could file it there later if people like it enough.
08-25-2005, 07:12 PM
You should post this on spinquad.com tutorial section, so more people has access to it...
08-25-2005, 07:58 PM
Man, I have been looking for a long time on the internet and LW books on how to do this. I really appreciate you taking the time to create this tutorial.
08-26-2005, 08:42 AM
Excellent - thasnk you very much! :bounce:
08-26-2005, 03:34 PM
I'm completely lost as to how you get the fog sequence imbeded in the main sequence.
When I follow your AFX steps, I get a sequence that's the same as the fog sequence only with a desaturated version of the main sequence as an alpha.
I can't find it now, but there was a tutorial like this online before using fog to generate a fake Zdepth image. You'd then use that image to mask a simple blur; thus, faking DOF. In that tut, it said that you can't use AA or motionblur because that would give everything a fuzzy halo when you applied the blur. I don't know if this new lensblur filter gets around that.
A variation of this if you'd like to precisely set a focal point somewhere in the middleground or if you want to have a changing focal point would be:
1) Add null, called "null" and parent to camera, constrain to Z
2) background color black
3) surface everything with a gradient, black and white, set to distance to object - "null"
What happens, obviously, is everything closest to camera is white and fades to black. So why have a null? Well, move the null forward. Neat, huh? Now you can key the null moving and do rack focus.
08-26-2005, 04:11 PM
hmm. Strange that the AFX steps aren't working for you. I guess I'd re-check two important things:
1. is your main plate correctly luma tracking the depth plate? If it is, it will look messed up before you render out your sequence because it's obviously using the depth as an alpha channel. The way you get around that is:
2. In your render options, make sure you have your color (fill) set to "Straight Unmatted). That renders every pixel that is left even a fraction of a percent visible by the alpha to 100% visible in the fill, which (in most cases) will have the net result of leaving your fill (main plate) 100% unaffected unless it's 100% matted by the alpha channel, in which case we'd need a new workaround in order to embed the alpha with AFX.
sorry if you already know all this, I'm not sure exactly what else to try...
to everyone else: glad you liked the tutorial! thx!
08-26-2005, 05:23 PM
I had the layers switched in AFX. You're right. Carry on.
08-26-2005, 05:23 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.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.