LC #42 Pipers Alley

View Full Version : best DOF solution?

05-05-2003, 01:11 PM
I'm working on a little animation at the moment.....and now the problem is which DOF should I use?

1. mayas own DOF with the maya renderer
-slow as hell and bad results

2. the mental ray DOF lens shader
-pretty nice but for a whole animation also really slow :(

3. render the animation as a iff sequence with the included z-channel and add the DOF in a compositing package
-really fast but the problem is that I get bad not antialiased edges because of the bad z channel

so what do you normally use?

I think I remember something that you could render your animation with greytones and use this combined with a compositing package? Anybody know something about this way?

thx for your help

05-05-2003, 04:27 PM
found a shader on highend3d which does more or less that what I want

it creates an black-white image which you can use in your compositing package

but the problem is it only works on objects....and I'm working alot with particles :(

has anybody a better solution?

05-05-2003, 04:48 PM
you can tweak your particles in the same way, that they behave like the objects..

i dont know how the shader from highend works..

have a try with this mine:
create fake depth ( )

read the header in the file and only use on a scene that has been double saved :)

you will have to adjust your near and far cam cplipping planes first, before running it..

it wont take the particles into account, but you can fix that easily:
change your particle shaders in a way that they are plain white (see the shader which the objects get).
but keep all transparency values you had before..
that gives you a grayscale for the particles as well..

i guess you could do something silmilar with what you downloaded from highend..



05-05-2003, 05:50 PM
For an animation, I'd render lots of separate elements and layers, so I could blur distant things separately, blur the particles separately, comp transparent things over a soft background, blur what you see through the particles separately for mock refraction or heat ripple effects. Combine this approach with a Z-buffer (or fake Z-buffer rendered with fog) for elements with a lot of depth that need to be selectively blurred.

For a cool still image, or when rendertime wasn't as big a concern, I'd just use a renderer like MR or PRMan that has reliable DOF.

Either way, it's good afterwards to add an extra pass building "bokeh" effects around the blurred highlights.


05-05-2003, 06:15 PM
Thx jeremy, I think thats the best way to go. For my background and the particles the included z-channel will be ok. Just for my mechanical elements I will need an other solution.

you said you fake the z-channel with fog? Sounds good, do you have a more detailed description for this?

oh, and whats a bokeh effect? ;)

05-05-2003, 07:13 PM
Any kind of depth-fading can be used to simulate a Z-channel (although not at floating-point accuracy, of course) in your rendering. For example, use a white environment fog, and all-black shaders on your geometry, and your render will work as a depth map for purposes like displacement mapping, faking DOF, adding smoke, etc.

Bokeh effects are what's missing that makes CG DOF look flat and fake, whereas a real lens falling out of focus makes highlights bloom and glisten and form little beads of light:


05-05-2003, 07:28 PM
thx very much

works pretty good

05-15-2003, 02:05 AM
Hello Jeremy,

Could outline your method of achieving bokeh?

I've often used the z-depth map to achieving dof. And I've done the same with my specular pass in an attempt at bokeh.

What I'm really curious about is how you blow out those highlights in your comp. It seems that the "beads" of light that sell the bokeh effect have a fairly specific look to them and using a blur looks close, but no cigar. Maybe I'm just being too picky, but I'm curious how others do this.


CGTalk Moderation
01-15-2006, 02:00 AM
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.