Iterating to enanche gaussian blur will darken my image :(

Cd586a7130b6cb95bed9ae57223fad5c
0
SuperPixel 101 Jul 19, 2012 at 16:30

Hi all,

I’m performing gaussian blur with a 9 taps filter and I use bilinear filtering in turn to reduce the number of taps (i.e. getting two sample at once thanks to hw filtering…, so using just half of the taps [9/2]+1).

If I iterate over the previous blurred result to get more blur on the resulting image, the image itself gets darker and darker as the number of iterations raise … until it gets completely black …

Why this behaviour ? :(

Note: I’ve calculated my weights from the pascal triangle and normalized them, also the tex coords offset will reflect the border of the pixel to account for the fact that I’m using bilinear filtering to read more sample at once.

I show just the horizontal pass pixel shader source:

static const float weight[3]  = {0.2270270270,0.3162162162,0.0702702703};
static const float offsets[3] = {0.0,1.3846153846,3.2307692308};
//perform horizontal blur
static const float2 invImageSize  = float2(1.f/1000.f,1.f/800.f);
static const float  downsampledLevel = 0.f;
float4 PSBlurH(VS_OUTPUT Input) : SV_Target{
float3 color    = colorTexture.SampleLevel(textureSampler,Input.tc*invImageSize,downsampledLevel).xyz*weight[0];
[unroll]
for(int i=1;i<3;++i){
  color += colorTexture.SampleLevel(textureSampler,Input.tc+float2(offsets[i]*invImageSize.x,0.f),downsampledLevel).xyz*weight[i];
  color += colorTexture.SampleLevel(textureSampler,Input.tc-float2(offsets[i]*invImageSize.x,0.f),downsampledLevel).xyz*weight[i];
}
return float4(color,1.f);
}

It seems that the background color is influencing the cube … :/

blurpz.png

Thanks in advance for any reply

3 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Jul 19, 2012 at 17:53

Weird. The code snippet you posted looks fine to me. Are you sure you don’t have blending enabled or something odd like that? That could also explain the cube picking up the background color.

Cd586a7130b6cb95bed9ae57223fad5c
0
SuperPixel 101 Jul 19, 2012 at 18:02

@Reedbeta

Weird. The code snippet you posted looks fine to me. Are you sure you don’t have blending enabled or something odd like that? That could also explain the cube picking up the background color.

I disable blending do default setting OMSetBlendState to null, it will reset to default blend … mmmm or maybe I should specify explicitly that with a specific blend state ?

I use this code for the fullscreen quad, which actually draws a quad that is bigger than the viewport such that one triangle of the two will be enough to fill the entire viewport.

// ouputs a full screen quad with tex coords
VS_OUTPUT VSQuad(uint VertexID : SV_VertexID){
VS_OUTPUT Out;
Out.tc     = float2( (VertexID << 1) & 2, VertexID & 2 );
Out.hpos     = float4( Out.tc * float2( 2.f, -2.f ) + float2( -1.f, 1.f), 0.f, 1.f );
return Out;
}
Cd586a7130b6cb95bed9ae57223fad5c
0
SuperPixel 101 Jul 19, 2012 at 19:47

@SuperPixel

I disable blending do default setting OMSetBlendState to null, it will reset to default blend … mmmm or maybe I should specify explicitly that with a specific blend state ?

I use this code for the fullscreen quad, which actually draws a quad that is bigger than the viewport such that one triangle of the two will be enough to fill the entire viewport.

// ouputs a full screen quad with tex coords
VS_OUTPUT VSQuad(uint VertexID : SV_VertexID){
VS_OUTPUT Out;
Out.tc     = float2( (VertexID << 1) & 2, VertexID & 2 );
Out.hpos     = float4( Out.tc * float2( 2.f, -2.f ) + float2( -1.f, 1.f), 0.f, 1.f );
return Out;
}

Fixed !

It came out that I wasn’t sampling from the center of the pixel on …

thanks anyway