Lars Kâ„¢

27 Feb, 2006

Quick DOF tip

Posted by: Lars Koudal In: 3d| Tutorials

This tutorial is mostly directed towards 3D Studio MAX users, but any 3D program should do it.

Most 3D artists have tried playing with GI (Global Illumination) and DOF (Depth Of Field) in their images. These tricks have been explored more widely with the inclusion of these in plugin-renderers such as Mental Ray, Vray and Brazil. common for all of these are that they are time-consuming. Re-creating realistic DOF and GI will impose a serious load on your CPU, and halt your work-flow. Global illumination adds the extra quality to your image, and DOF adds the little extra touch that can make a picture a whole lot more convincing.

I have a small trick though, that will make your life a whole lot easier.

Before using the Depth Of Field (DOF) trick
Before image

Image generated with the Depth Of Field (DOF) trick

Image generated with the Depth Of Field (DOF) trick (less than a minute)

In this tutorial I will go through the basics of a quick way of creating a DOF effect. Well, easy and quick once you get the hang of it. Remember, the emphasis doest not lie on creating a realistic DOF, but only to do show a quick way to create a production-ready method for fast scenes or the adding the little subtle detail that gives your scenes that million-dollar-look.

A close-up of the before-and-after Global Illumination generated in Photoshop.

My tools will be 3D Studio MAX 4 and Adobe Photoshop 5.5, but any 3D program and image-manipulation software will do. The trickery lies in the ability of the 3D software’s renderer to generate a depth-pass. There are ways to bypass a renderers lack of this ability, for instance by creating a material, which diffuse map is a gradient from white to black, based on the distance to the camera. If you have to do that, then this trick is beginning not to be worth the effort.

On with the trick.


Step 1

Create a sample scene for you to work with. The most work in this tutorial lies in Photoshop, not the 3D program.

This is the unmapped model I started with. A lot of work is necessary, as you can see :-)

As I mentioned earlier, the model was found on www.turbosquid.com

Textured, and ready to go.

The leather is a simple standard material with a brown texture applied, a bit of noise in the bump slot, and then I played a bit around with the Specular Level and Glossiness.

The metal is also a standard material witha Metal shader with Specular at about 188 and Glossiness at 57. In the reflection slot I put a Swirl map with the two colors turned to grey values. Remember to set the reflection map to spherical environment, or the metal reflection will look kindda funny.

Step 2

Render out the different parts out we need for our next step, in Photoshop.

Remember to save alle of these images with their alpha-mask. You never know when you might need them. So, use .tga or .tiff formats. Dont attempt to use .jpg’s. They will not take up as much harddisk space, but you will reduce the quality too much.

Diffuse pass Standard rendering. It is up to you, but I recommend rendering it with out shadow casting lights. It is not necessary for creating this trick, but it does give you more freedom.
Z-depth pass This little trick is where the key to our quick DOF lies. What we want is a depth map based on the environment’s distance to our camera. How we do it (in 3D Studio MAX is as follows):

In the rendering settings (F10) go down to Render Elements.
Add "Z Depth".
Below the "Render Elements", you will se a "Z Element Parameters". Here you can tweak the settings. Default is 100min and 300max. Dont worry too much hitting the appropriate settings, you can tweak it later on in Photoshop, so just make an educated guess.

Shadow pass A seperate pass with alle the shadows in the scene. It is a lot easier if you keep the different elements seperated for as long as possible in any process. Tweaking and fine-tuning can be achieved much easier in a program that is made for it, such as an compositing program, or Photoshop for stills.
Sliced pass This is a normal rendering (with an alpha-mask) of the bottom part of the model. This pass is used to create the fake GI later on in the compositing.

Step 3 (Depth Of Field)


Time to open up Photoshop.

Start off with the actual rendering. Create a copy of the background-layer and apply a gaussian blur to it. Try to compare your scene to something real if you cant decide on how much blur to add.

Remember, we are trying to make a subtle effect, we dont want to overdo it, so people will focus on the strange blurring.

- Switch to the depth-pass image, and and copy it into memory.
- Switch back to your blurred rendering, and go into the channels tab.
- Paste the z-depth into a new layer.
- Load the new alpha mask. (Select->Load Selection)
- Switch back to your Layers tab and select the blurred layer.
- Add it as a layer mask. (Layer->Add Layer Mask->Hide Selection).

layers1.gif

You now have a seperate layer with a DOF-effect, which you can fine-tune by changing the opacity of the layer.

If you want to change the depth of field, you can tweak the layer mask, by marking it with your mouse, and then press CTRL-L, which opens up Photoshop’s Levels-dialogue.

Continue along to this post: 2 numre af Kreativ Strik til halv pris.
Tags: , , , , , , , , , , , ,

Related posts

4 Responses to "Quick DOF tip"

1 | Eddie Robinson

April 3rd, 2006 at 12:12

Avatar

Hi, when i add a z-depth pass in max6 the render just comes out blank (white),and of course we both know a z-depth pass is ment to be in shades of grey, can you please help me????

2 | Lars Koudal

April 3rd, 2006 at 15:15

Avatar

Hello Eddie

I think you might have to change the settings of the falloff material in the material editor. settings view

Above screenshot is from the settings I used for the quick scene I set up below:

normal rendering
The rendering of the scene (blue background added for visibility).

depth rendering
Here is the rendered output with the settings in the beginning of the post. Please note that this trick involves a bit of tweaking of the settings, based on distance to the objects from the camera.

3 | Eddie Robinson

April 4th, 2006 at 9:09

Avatar

Thanks Lars that worked fine, with a bit tweaking of the distance settings,the z-depth pass really does save on
render times when used as a mask in photshop with lens blur etc.You would think such a high end program would create the pass automatically,Bryce at £50 creates
z-depth pass automatically, but then again thats all it can’t do any more passes,so what material do I apply to my object to create an alpha pass, do i just make it black with
just diffuse light?, thanks again

4 | Lars Koudal

April 7th, 2006 at 10:10

Avatar

Hi Eddie

If you just want the alpha mask you can just take your rendering and save it to any format that supports alpha channels, such as .tiff or .tga.

3D Studio MAX should ask you if you want to save it as 24-bit or 32-bit, in which case you choose 32-bit.

When you open the file in Photoshop, you should have an alpha mask in the “Channels” panel (next to “Layers”).

Comment Form

Where To Find Me Online



About

koudal.dk is the personal homepage of Lars Koudal who have worked in the IT business for over 10 years.

I currently live in and work in Barcelona/Spain.