sampler2D downsampledImage; //float weights[7] = //{ // 0.015625, // 0.09375, // 0.234375, // 0.3125, // 0.234375, // 0.09375, // 0.015625 //}; // 1/64, 6/64, 15/64, 20/64, 15/64, 6/64, 1/64 // weights half4 weights = { 0.015625h, 0.09375h, 0.234375h, 0.3125h }; #define TEXELWIDTH 0.0015625h // (1/640) half texelModX; struct vertexOutput { half4 oPosition : POSITION; half2 oTexCoord : TEXCOORD0; }; vertexOutput gaussianBlurXVP( half4 position : POSITION, half2 texCoord : TEXCOORD0 ) { vertexOutput OUT = (vertexOutput)0; OUT.oPosition = position; OUT.oTexCoord = texCoord; return OUT; } half4 gaussianBlurXFP( vertexOutput IN ) : COLOR0 { half4 result = half4(0,0,0,0); half4 colour; half texelMod = texelModX; // Attempted to stop the bleeding here...doesnt seem to have worked. // Think we need to check the samplers are clamping and not repeating. half2 newTexCoords[6]; newTexCoords[0] = saturate(IN.oTexCoord + half2(-3*texelMod, 0)); //newTexCoords[0].x = max(0, newTexCoords[0].x); newTexCoords[1] = saturate(IN.oTexCoord + half2(-2*texelMod, 0)); //newTexCoords[1].x = max(0, newTexCoords[1].x); newTexCoords[2] = saturate(IN.oTexCoord + half2(-1*texelMod, 0)); //newTexCoords[2].x = max(0, newTexCoords[2].x); newTexCoords[3] = saturate(IN.oTexCoord + half2( 1*texelMod, 0)); //newTexCoords[3].x = min(1, newTexCoords[3].x); newTexCoords[4] = saturate(IN.oTexCoord + half2( 2*texelMod, 0)); //newTexCoords[4].x = min(1, newTexCoords[4].x); newTexCoords[5] = saturate(IN.oTexCoord + half2( 3*texelMod, 0)); //newTexCoords[5].x = min(1, newTexCoords[5].x); colour = tex2D(downsampledImage, newTexCoords[0]) * half4(weights.xxx, 1.h);// * ceil(newTexCoords[0].x); result += colour/colour.a; colour = tex2D(downsampledImage, newTexCoords[1]) * half4(weights.yyy, 1.h);// * ceil(newTexCoords[1].x); result += colour/colour.a; colour = tex2D(downsampledImage, newTexCoords[2]) * half4(weights.zzz, 1.h);// * ceil(newTexCoords[2].x); result += colour/colour.a; colour = tex2D(downsampledImage, IN.oTexCoord ) * half4(weights.www, 1.h); result += colour/colour.a; colour = tex2D(downsampledImage, newTexCoords[3]) * half4(weights.zzz, 1.h);// * ceil(1.0f - newTexCoords[3].x); result += colour/colour.a; colour = tex2D(downsampledImage, newTexCoords[4]) * half4(weights.yyy, 1.h);// * ceil(1.0f - newTexCoords[4].x); result += colour/colour.a; colour = tex2D(downsampledImage, newTexCoords[5]) * half4(weights.xxx, 1.h);// * ceil(1.0f - newTexCoords[5].x); result += colour/colour.a; result.a = 1.h; result = result/max(max(result.r, result.g), max(result.b, 1.h)); return result; } technique gaussianBlurX { pass p0 { VertexProgram = compile vp30 gaussianBlurXVP(); FragmentProgram = compile fp40 gaussianBlurXFP(); DepthTestEnable = false; DepthMask = false; BlendEnable = false; } }