sampler2D sourceTexture; sampler2D edgeTexture; //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 float4 weights = { 0.015625, 0.09375, 0.234375, 0.3125 }; #define TEXELWIDTH 0.0015625 // (1/640) float texelMod; struct vertexOutput { float4 oPosition : POSITION; float2 oTexCoord : TEXCOORD0; }; vertexOutput gaussianBlurYVP( float4 position : POSITION, float2 texCoord : TEXCOORD0 ) { vertexOutput OUT = (vertexOutput)0; OUT.oPosition = position; OUT.oTexCoord = texCoord; return OUT; } half4 gaussianBlurYFP( vertexOutput IN ) : COLOR0 { float4 colour = 0.f.xxxx; float blur = 0.f; float2 texCoords; // Attempted to stop the bleeding here...doesnt seem to have worked. // Think we need to check the samplers are clamping and not repeating. float2 newTexCoords[6]; newTexCoords[0] = saturate(IN.oTexCoord + float2( 0, -3*texelMod)); newTexCoords[1] = saturate(IN.oTexCoord + float2( 0, -2*texelMod)); newTexCoords[2] = saturate(IN.oTexCoord + float2( 0, -1*texelMod)); newTexCoords[3] = saturate(IN.oTexCoord + float2( 0, 1*texelMod)); newTexCoords[4] = saturate(IN.oTexCoord + float2( 0, 2*texelMod)); newTexCoords[5] = saturate(IN.oTexCoord + float2( 0, 3*texelMod)); // start at centre and work out accumulating edge data // centre half globalBlur = tex2D(edgeTexture, IN.oTexCoord ).r; colour += tex2D(sourceTexture, IN.oTexCoord ) * half4(weights.wwww); // blur down blur = 1.h - globalBlur; blur *= 1.h - tex2D(edgeTexture, newTexCoords[2]).r; texCoords = IN.oTexCoord + (float2(0, -texelMod) * 1 * blur); colour += tex2D(sourceTexture, saturate(texCoords)) * half4(weights.zzzz); blur *= 1.h - tex2D(edgeTexture, newTexCoords[1]).r; texCoords = IN.oTexCoord + (float2(0, -texelMod) * 2* blur); colour += tex2D(sourceTexture, saturate(texCoords)) * half4(weights.yyyy); blur *= 1.h - tex2D(edgeTexture, newTexCoords[0]).r; texCoords = IN.oTexCoord + (float2(0, -texelMod) * 3 * blur); colour += tex2D(sourceTexture, saturate(texCoords)) * half4(weights.xxxx); // blur up blur = 1.h - globalBlur; blur *= 1.h - tex2D(edgeTexture, newTexCoords[3]).r; texCoords = IN.oTexCoord + (float2(0, texelMod) * 1 * blur); colour += tex2D(sourceTexture, saturate(texCoords)) * half4(weights.zzzz); blur *= 1.h - tex2D(edgeTexture, newTexCoords[4]).r; texCoords = IN.oTexCoord + (float2(0, texelMod) * 2 * blur); colour += tex2D(sourceTexture, saturate(texCoords)) * half4(weights.yyyy); blur *= 1.h - tex2D(edgeTexture, newTexCoords[5]).r; texCoords = IN.oTexCoord + (float2(0, texelMod) * 3 * blur); colour += tex2D(sourceTexture, saturate(texCoords)) * half4(weights.xxxx); return colour;//half4(colour.rgb, 1.h);//half4(blur.xxx, 1.h); } technique gaussianBlurY { pass p0 { VertexProgram = compile vp30 gaussianBlurYVP(); FragmentProgram = compile fp40 gaussianBlurYFP(); DepthTestEnable = false; DepthMask = false; BlendEnable = false; } }