View Full Version : Mental Ray DOF with Glare

02 February 2006, 05:07 AM
Mental ray glare shader. Software 3DS MAX 7.5

Hi guys, just looking for a solution to rendering depth of field with the glare shader.
Because both are calculated in 3d (aparently) the DOF gives the glare effect a "harsh edge" look on everything.

I am aware this can probably be done better in passes, but is there a way anyhow?

Also what controls the quality of the depth of field (i.e samples etc)

I am trying to use mental ray from being a vray user so a few things are a bit hard to find in the documentation.


02 February 2006, 10:01 AM
The glare shader - being an output shader - is actually an entirely 2d process.

I have never had the issues you're describing with DOF+glare (although the glare shader usually does produce rather sharp edges, but I doubt that that's what you're referring to). Can you post a pic of what you're getting?

DOF actually doesn't do any of its own multisampling. Instead, it relies on your global sampling settings to smooth out the DOF to an acceptable result (and with DOF really just being a lens shader, it makes sense that it works that way).
So, to adjust the DOF sampling, the things you'd want to play with are your min/max sampling values, as well as the spatial/temporal contrast values (rendering->renderer->sampling quality rollout).

02 February 2006, 06:29 AM

I have got a reasonable effect by selecting "overlay only".. however I thought that this was the "2D" method of using glare.

The effect I am getting looks like the glass filter in photoshop (this happens around the Blurred adges) It just looks like DOF does not blur the glare.. or the glare is computer after the DOF blur..

I will try to upload an image if this still is making little sense.


02 February 2006, 09:02 AM
DOF is always calculated before glare. DOF is a lens shader - these are basically wrapper functions for each eye ray, sending out the eye ray from the origin, and then deciding what to do with the result. Glare is an output shader - shaders only processed after every sample in the frame has been gathered (so DOF has already been processed), and the samples have been filtered to give your rasterized image. Output shaders are always the last shader called up by Mental Ray.
If you want to have the DOF blur the glare, you may have to render out a z-depth pass to do your DOF in post. Using the glare's overlay option, you could still do your DOF directly through MR as an actual 3d effect, and then only use 2d DOF on the glare layer, if you wanted.
The glare could potentially be handled with the use of FG (with the right shaders), allowing it to be affected by the blur. But I don't know what kind of quality you could get out of it. It'd take some experimenting...

02 February 2006, 12:42 AM
Thanks for the explanation.

I was already looking at Post DOF and came up with this;

Any idea on how to use this in max? its a shader, although I am confused as to what it is meant to be attached to.

The documentation only cover maya and lightwave because the max release is "unsupported, yet functional".


Also just to confirm the overlay works fairly well, although the effect is a little bit "overdone".
I basically would need to render out 2 passes, one with the glare, one without. Then I can setup 2 layers, one to screen mode and adjust the opacity.

02 February 2006, 01:01 AM
That zDepthDOF shader is just an advanced z-depth shader implemented as a texture (surface) shader; it doesn't actually give you the 2d DOF.
And standard DOF isn't always quite as useless as that info pages seems to suggest. Near and far ranges can already be freely adjusted - independent of the camera's clipping range -directly in Max (through the render elements tab), and you can get a broader color range by rendering to HDR as well.
But using it should just be as simple as creating a new mental ray material, and setting the zdepthdof shader as the surface shader.

02 February 2006, 04:48 AM
Thanks for that. I thought it was a camera shader.

Basically I can use a mix material to toggle between the zdof and my original materials right?

Just in terms of practicality.

I didnt know about rendering to HDRI either.. fantastic tip.


03 March 2006, 10:55 PM
Here's something you might find uses full but it looks good

CGTalk Moderation
03 March 2006, 10:55 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.