float GaussianCoef(int x, int y){ float sigma = 1.0f; return ( 1 / ( sqrt(2*3.14f) * sigma ) ) * exp( -(x*x+y*y) / (2*sigma*sigma) );}float4 BilateralFiltering(VertexOut input) : COLOR0{ float4 k11 = tex2D( ColoredTextureSampler, input.textureCoordinates.xy + float2(-0.01,-0.01))*GaussianCoef(2,2); float4 k12 = tex2D( ColoredTextureSampler, input.textureCoordinates.xy + float2(-0.01,0))*GaussianCoef(1,1); float4 k13 = tex2D( ColoredTextureSampler, input.textureCoordinates.xy + float2(-0.01,0.01))*GaussianCoef(2,2); float4 k21 = tex2D( ColoredTextureSampler, input.textureCoordinates.xy + float2(0,-0.01))*GaussianCoef(1,1); float4 k22 = tex2D( ColoredTextureSampler, input.textureCoordinates.xy + float2(0,0))*GaussianCoef(0,0); float4 k23 = tex2D( ColoredTextureSampler, input.textureCoordinates.xy + float2(0,0.01))*GaussianCoef(1,1); float4 k31 = tex2D( ColoredTextureSampler, input.textureCoordinates.xy + float2(0.01,-0.01))*GaussianCoef(2,2); float4 k32 = tex2D( ColoredTextureSampler, input.textureCoordinates.xy + float2(0.01,0))*GaussianCoef(1,1); float4 k33 = tex2D( ColoredTextureSampler, input.textureCoordinates.xy + float2(0.01,0.01))*GaussianCoef(2,2);}
All I get is the picture blurred but darker which makes sense considering with the value i am multiplying it with, I have got something wrong with the sigma (its supposed to be the size of the window, does it refer to the kernel?), also is my distance from the center pixel right if my kernel is 3x3? Kernel:
212
101
212