//**************************************************************************/
// Copyright (c) 2008 Autodesk, Inc.
// All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//**************************************************************************/
// DESCRIPTION:
// CREATED: October 2008
//**************************************************************************/
sampler2D colorTexture;
// Unused for this example, but you'd set this in the
// .cpp filter & use them here.
// Depth for each pixel
sampler2D depthTexture;
// Normals for each pixel
sampler2D normalTexture;
// 3D positions of each pixel. Either 16 bit floats or 32.
// rgb = xyz
sampler2D positionTexture;
float BlurWidth = 0.0012f;
float Gauss[9] = {1,3,7,11,12,11,7,3,1};
int GaussianBlur = 1;
float4 Blur(float2 texCoord)
{
int count = GaussianBlur == 1 ? 3136 : 0;
float4 scene = (float4)0;
texCoord.x -= 4*BlurWidth;
texCoord.y -= 4*BlurWidth;
for(int x = 0 ; x < 9 ; x++)
{
for(int y = 0 ; y < 9 ; y++)
{
float4 curscene = tex2D(colorTexture, texCoord + float2(BlurWidth * x, BlurWidth * y));
count += GaussianBlur == 1 ? 0 : 1;
scene += curscene * (GaussianBlur == 1 ? Gauss[x]*Gauss[y] : 1);
}
}
scene /= count;
scene.a = 1.0f;
return scene;
}
void main(
in float2 texCoord : TEXCOORD0,
out float4 outColor : COLOR )
{
outColor = Blur(texCoord);
}