Book Image

3D Graphics with XNA Game Studio 4.0

By : Sean James
Book Image

3D Graphics with XNA Game Studio 4.0

By: Sean James

Overview of this book

<p>XNA is a very powerful API using which it's easy to make great games, especially when you have dazzling 3D effects. This book will put you on course to implement the same 3D graphics used in professional games to make your games shine, and get those gamers addicted! If you think 3D graphics is something that limits your games, then this book is for you.<br /><br />3D Graphics with XNA Game Studio 4.0 is a step by step companion to implement the effects used in professional 3D games in your XNA games. By the time you're done with this book your games would have eye-catching visuals and 3D effects. <br /><br />The one thing that can make or break a game is its appearance; players will mostly be attracted to a game if it looks good. With this book you will create your 3D objects and models and make them look more interesting by using shadowing and lighting techniques, and make them move in nasty ways using animation. Want to create realistic terrians for your games? Need some place for your 3D models to engage in battle? This book will enable you to do all that and more, by walking you through the implementation of numerous effects and graphics techniques used in professional games so that you can make them look great.</p>
Table of Contents (16 chapters)
3D Graphics with XNA Game Studio 4.0
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 images in another post processor, which determines how much to blur the image based on the depths stored in the depth map at each pixel.

The effect that we will need to render the depth map is very simple, and we have seen most if not all of it before...