Graphics Reference
In-Depth Information
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:
1.
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 , 0.2740686
};
2.
For a 5-tap Gaussian blur, change the BlurKernel method of the horizontal and
vertical compute shaders to:
#define FILTERTAP 5
...SNIP
static const float BlurKernel[FILTERTAP] = {
0.1524691, 0.2218413, 0.2513791 , 0.2218413, 0.1524691
};
3. And lastly, for a 9-tap Gaussian blur, use the following kernel:
#define FILTERTAP 9
...SNIP
static const float BlurKernel[9] = {
0.08167442, 0.1016454, 0.1188356, 0.1305153, 0.1346584 ,
0.1305153, 0.1188356, 0.1016454, 0.08167442
};
4. Executing both, the vertical and horizontal filters, will achieve the full Gaussian blur.
The following image shows a comparison of the box and Gaussian blur filters at
varying kernel sizes.
Comparison of box and Gaussian blur filters with varying kernel sizes.
 
Search WWH ::




Custom Search