## Implementing a Gaussian blur filter

In this recipe, we use the separability of the Gaussian blur convolution filter to apply a Gaussian blur in two passes for a vertical and horizontal Gaussian blur.

The Gaussian blur is used in many image processing and 3D graphics operations. The filter can be used to soften edges, apply blurring during depth of field operations, or for use within the Bloom lighting technique.

### Getting ready

This recipe begins with the completed horizontal and vertical filter compute shaders and C# code to execute them from the *Implementing box blur using separable convolution filters* recipe.

### How to do it…

By adjusting the kernel values, we can create a Gaussian blur filter. For each of the following kernels, the center weight (weight of current texel) is highlighted:

In order to create a 3-tap Gaussian blur, change the

`BlurKernel`

method of the horizontal and vertical compute shaders to:`#define FILTERTAP 3 ...SNIP static const float BlurKernel[FILTERTAP] = { 0.2740686,`

**0.4518628...**