V-Ray Depth of Field with shade map

Here we will take a look at rendering in-camera Depth of Field (DOF) using the V-Ray stereoscopic shade map.

I always prefer rendering DOF in the camera. I don't know why. Maybe I'm a purest and just prefer to get things right up front. But maybe not. I love the bokeh that V-Ray gives me and the control I get over setting its parameters. Despite this love for V-Ray's DOF, it has still always been a bit slow and clunky to adjust. You can imagine therefore my delight when I found a time-saving solution to testing and implementing DOF in-camera. Let me introduce you to it...

What even is DOF?

Good question. It is essentially the distance in front of and behind a specific point which is sharp in the output. We'll call that point the focus point. The size of the area that is sharp as well as the amount of blurriness is dependent on a variety of settings in the camera, which we'll look at in more detail in a minute.

Here is a great example of a very shallow DOF. The low f-number (4.0) and long focal length (200mm) give this result

Here is a great example of a very shallow DOF. The low f-number (4.0) and long focal length (200mm) give this result

A brief word on DOF

Think about it! Don't overuse it or use it incorrectly. This is partly why I find it best to do it in-camera because then the result is correct. Using DOF is a beautiful artistic tool that enables us to bring in an emotive aspect to our visuals. It also helps us to keep the viewer's focus on those areas that we want. There is therefore great power and opportunity with it. Your best bet would be to get out in the real world with a camera and experiment. Get used to how the settings affect the output and grow in confidence that way.

The viewer's eye is immediately focused on the leaf. Everything else is so out of focus that the viewer has little choice here. A good example of DOF used artistically. Copyright © Allyson907

The viewer's eye is immediately focused on the leaf. Everything else is so out of focus that the viewer has little choice here. A good example of DOF used artistically. Copyright © Allyson907

Controlling the DOF

As previously mentioned, you can control the DOF with several settings. The 2 main controls we will focus on here are the focal length and the aperture size. In principle, the longer the focal length, the shallower the DOF will be. Obviously a wide angle lens is going to have a wider DOF. In terms of the aperture (f-number or f-stop); basically the smaller it is, the shallower the DOF will be. If you want to make sure that everything is in focus then go for a higher aperture. Please note that these will only affect the DOF if it is switched on in the V-Ray camera.

Here you can see that the area in focus is greatly adjusted by the f-number

Here you can see that the area in focus is greatly adjusted by the f-number

Setting up DOF in V-Ray: Part 1

Firstly go into your V-Ray Physical Camera and to the Sampling rollout. Tick the ‘depth-of-field' tick box and increase the number of subdivisions for a cleaner, less noisy result. I usually use 8 subdivisions for test renders and then I might raise it to 32 subdivisions for production quality renders. This is a time versus quality thing.

Unless DOF is ticked you won't see any DOF in your image, no matter what your other settings are

Unless DOF is ticked you won't see any DOF in your image, no matter what your other settings are

Setting up DOF in V-Ray: Part 2

Once DOF is activated in the camera, you then need to adjust your settings to tweak the result. I adjust the focal length, f-number and focus distance to get the result I need. The focal length adjusts how wide the viewing angle is. The f-number adjusts the distance that is in focus. And finally, the focus distance adjusts the centre point that is most in focus. I would recommend playing around with these on a simple scene so that you get used to how they affect each other.

Do make sure you play around with the settings to see how fine-tuning has an effect on the image

Do make sure you play around with the settings to see how fine-tuning has an effect on the image

Use the V-Ray Stereoscopic helper

Start by going to the ‘Create' menu and the ‘Helpers' section. Pick ‘VRay' from the dropdown. Then create a ‘VRay Stereoscopic' object anywhere in the viewport – it doesn't matter where. Set the eye distance to 0 because we're not using this helper to create a 3D stereoscopic image where the eyes are separated. Then set the Shademap mode to ‘Render shade map' and specify a file for the result to be outputted to. This will ensure that when render is next executed, the shade map will be rendered.

We will utilise the stereoscopic helper but not for what you might think!

We will utilise the stereoscopic helper but not for what you might think!

Render the shade map

Now that your stereoscopic helper is set up, double-check your camera DOF settings are as desired and then hit render. Please note that because you are rendering the shade map, there will be no DOF in the resulting image. Don't worry about this. Just think of this step as a pre-calculation step.

This pre-calc step enables you to render the DOF much quicker next time round, even if you've made adjustments to your scene

This pre-calc step enables you to render the DOF much quicker next time round, even if you've made adjustments to your scene

Switch to using the shade map

With the shade map rendered, select the stereoscopic object and set the ‘Shademap mode' to ‘Use shademap'. Make sure that the file is the same as the one you've just pre-calculated. With that completed, go back to your camera and hit render again. This will render your final image with the DOF but it'll do it in a much quicker time than ordinarily.

This image took around half the time to render using the shade map option, compared to the standard process

This image took around half the time to render using the shade map option, compared to the standard process

Switch to using the shade map

With the shade map rendered, select the stereoscopic object and set the ‘Shademap mode' to ‘Use shademap'. Make sure that the file is the same as the one you've just pre-calculated. With that completed, go back to your camera and hit render again. This will render your final image with the DOF but it'll do it in a much quicker time than ordinarily.

A simple crop of the resulting image in half is all that is required to finish the job

A simple crop of the resulting image in half is all that is required to finish the job

Disadvantages vs advantages

The obvious disadvantage to this technique is the inherent approximation that is included. If you want a perfect, physically accurate result, then you will need to render it straight out of the camera. However, you have the obvious advantage of speed with the shade map technique. You can make adjustments to your lighting for example, and re-render again and again using the shade map. This is a massive time saver, especially during the test render phase.

Looking at real in-camera DOF will vastly improve your own work. Here is another example of how it is used well

Looking at real in-camera DOF will vastly improve your own work. Here is another example of how it is used well

Top tip 1: Guide the eye with DOF

One of the best uses for DOF other than for artistic flair is that it is a great tool to guide the viewer's eye to the exact part of the image that you want them to focus on first.

The DOF is set up on the mushroom to make the viewer look at it first. This is a beautiful photo which uses DOF very artistically

The DOF is set up on the mushroom to make the viewer look at it first. This is a beautiful photo which uses DOF very artistically

Related links
Head over to Paul Hatton's website over at CADS
Looking for photo reference? Try sxc
Want the latest V-Ray version? 3.0 is in beta now!

Fetching comments...

Post a comment