Any ideas?
Edit: Using Direct3D9
if(D3DXCreateEffectFromFile(d3dDevice, effectFiles.c_str(), 0, 0, D3DXSHADER_DEBUG, 0, &loadEffect->effect, 0) != D3D_OK)
ErrorMessenger::ReportMessage("Failed to create effect from file!", __FILE__, __LINE__);
//PPBlur.fx is an effect containing different ways to achieve a blur on the scene handed to it using a Full Screen Quad for post processing.
float blurIntensity = 1.0f;
float texelSizeU;
float texelSizeV;
texture scene;
sampler Scene =
sampler_state
{
Texture = <scene>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
void vsBoxBlur(float4 iPos : POSITION0,
float2 iUV : TEXCOORD0,
out float4 oPos : POSITION0,
out float2 oUV : TEXCOORD0)
{
oPos = iPos;
oUV = iUV;
}
void psBoxBlur(float2 iUV : TEXCOORD0,
out float4 oColor : COLOR0)
{
texelSizeU *= blurIntensity;
texelSizeV *= blurIntensity;
float4 avgColor = float4(0.0f, 0.0f, 0.0f, 1.0f);
//Row above
avgColor += tex2D(Scene, float2(iUV.x - texelSizeU, iUV.y - texelSizeV));
avgColor += tex2D(Scene, float2(iUV.x, iUV.y - texelSizeV));
avgColor += tex2D(Scene, float2(iUV.x + texelSizeU, iUV.y - texelSizeV));
//Row at
avgColor += tex2D(Scene, float2(iUV.x - texelSizeU, iUV.y));
avgColor += tex2D(Scene, iUV);
avgColor += tex2D(Scene, float2(iUV.x + texelSizeU, iUV.y));
//Row below
avgColor += tex2D(Scene, float2(iUV.x - texelSizeU, iUV.y + texelSizeV));
avgColor += tex2D(Scene, float2(iUV.x, iUV.y + texelSizeV));
avgColor += tex2D(Scene, float2(iUV.x + texelSizeU, iUV.y + texelSizeV));
avgColor /= 9;
oColor = avgColor;
}
technique BoxBlur
{
pass p0
{
VertexShader = compile vs_3_0 vsBoxBlur();
PixelShader = compile ps_3_0 psBoxBlur();
}
}