Jump to content
  • Advertisement
Sign in to follow this  
Bluud

How to stop Downsample/blur shaders wrapping?

This topic is 3787 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using simple downsampling and gaussian blur shaders for my bloom effect, and I need to find a way to stop the shaders wrapping the output on the edges of the surface. For example, if I have a bright portion on the far right hand side of my surface and run this blur shader then I get the brightness going off the edge and coming onto the left hand side of my output surface:
float4 HorizontalBlur( in float2 t : TEXCOORD0 ) : COLOR
{

    float4 color = { 0.0f, 0.0f, 0.0f, 0.0f };
    
    for( int i = 0; i < 9; i++ )
    {
        color += (tex2D( tex0, t + float2( HBloomOffsets, 0.0f ) ) * HBloomWeights );
    }
        
    return float4( color.rgb, 1.0f );   
}
how can I stop it doing this? It is driving me mad! I would have thought just ignoring texcoords out of the range 0.f..1.f would work but this doesnt let me compile the shader, I get an error about dependency chains... I've looked at many many tutorials and examples and I cannot see any mention of this problem or anyone whose shader seems to care about the edges. What is going on?

Share this post


Link to post
Share on other sites
Advertisement
setting clamp will resolve most of the problem, but you can still get some odd 'bulge' type effects around the edge of the screen due to the way clamping doesn't stop the sampling it just means the same edge-pixel is sampled many times...

I often found that a more subtle bloom filter was the only way to avoid some of these artifacts - make the effect so soft that you can't really make out the artifacts [smile]

hth
Jack

Share this post


Link to post
Share on other sites
cool, thanks for the replies lads!

The clamping fixed it nicely. And yup, I see what you mean about the edge samples, but its not too apparent so I think I can live with it...

thanks again for your help :)

Share this post


Link to post
Share on other sites
Hi,

You can try the Border addressing mode instead of Clamp...
It allows you to specify a color to be used outside of the [0, 1] range.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!