O'Reilly logo

3D Graphics with XNA Game Studio 4.0 by Sean James

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required