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

Gaussian blur post processor


The next post processing effect that we will look at is blurring, specifically with what is called a "Gaussian" blur. A Gaussian blur is a blur which, instead of simply calculating a weighted average of a pixel and its neighbors, calculates a weighted average, weighing pixels based on their distance from the center pixel. The weights are calculated according to the Gaussian (or "normal") function:

In normal use of this function, x is the distance from the mean of a data set, and σ is the standard deviation. In this case, x is a pixel's distance from the center pixel and σ is used as a parameter to determine how much the image is blurred. The following graph shows how much a pixel will be weighted as its distance approaches 1, 2, 3, and so on σ's from the center pixel:

The GaussianBlur post processor is an extension of the basic PostProcessor class:

public class GaussianBlur : PostProcessor
{
}

We will sample from the input texture 15 times and calculate a weighted...