Depth of field

The next effect that we will look at builds on our Gaussian blur effect to recreate the "depth of field" effect. In the real world, cameras have one specific range they can focus clearly on, and everything outside of that range is blurred somewhat, getting increasingly blurry as the subjects move farther from the focal range. Generally, the effect isn't terribly noticeable, but in some cases it can be exaggerated intentionally for aesthetic effects.

The process is simple: First, we render the scene storing only the depth values in a depth map (like we did in Chapter 3, Advanced Lighting). Then we render the scene normally, storing both the original render and a blurred version of it. Finally, we combine the blurred and non-blurred ...

Get 3D Graphics with XNA Game Studio 4.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.