Jump to content
  • Advertisement
Sign in to follow this  
circassia

downsampling + blur = flickering

This topic is 2602 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

Hi guys,

i have created a shader with 5 passes:


1) downsample
2) upsample
3) tent downsampling setting
4) horizontal gaussian blur (5taps)
5) verticla gaussian blur (5taps)

the result is ok, but i get a flickering, is there a method to reduce flickering?

thank you very much?

Share this post


Link to post
Share on other sites
Advertisement
Increase the number of samples per low resolution pixel when downsampling.
Make sure that you use clamped sampling when working with post effects so that the edges don't show artifacts.

Share this post


Link to post
Share on other sites

Increase the number of samples per low resolution pixel when downsampling.
Make sure that you use clamped sampling when working with post effects so that the edges don't show artifacts.


Hey Dawoodoz, what do you exactly mean by "increase the number of samples per low resolution" ? can you give some more details about it?

thank you very much

Share this post


Link to post
Share on other sites
When downsampling, you sample a texture at many locations in a rectangular area and take the average color.

This example show a rotated square shape.

return (tex_0.Sample( samLinear, (PixelPos + float2(-0.4f, 0.2f)) / OutputDimensions )
+ tex_0.Sample( samLinear, (PixelPos + float2(0.2f, 0.4f)) / OutputDimensions )
+ tex_0.Sample( samLinear, (PixelPos + float2(0.4f, -0.2f)) / OutputDimensions )
+ tex_0.Sample( samLinear, (PixelPos + float2(-0.2f, -0.4f)) / OutputDimensions )) / 4.0f;


Using linear sampling will give an uneven distribution between 4 reads per sample but will make it smooth when rescaling.

Share this post


Link to post
Share on other sites

You basically have to sample the points around the current sample location, like a 9x9 quad, and average them when downscaling.


that would mean 8 lookups am i right? the 8 pixels around the center pixel? or am i on the wrong way?

thx for your help

Share this post


Link to post
Share on other sites
A 9x9 quad gives 81 samples including the middle.
A 3x3 quad with 9 samples should be enough. [/quote]

Ah, sorry, I somehow got that wrong. Of course I mean a 3x3 quad with a total of 9 pixels sampled :rolleyes:

1) downsample
2) upsample
3) tent downsampling setting <- (?)
4) horizontal gaussian blur (5taps)
5) verticla gaussian blur (5taps)[/quote]

Should be like this:
1) downsample
2) horizontal gaussian blur (5taps)
3) vertical gaussian blur (5taps)
4) upsample


You can give the downsampled scene to your blur-shaders. The whole blurring process should be much faster like this.
You can make more than 5 taps then, which may looks better.

Share this post


Link to post
Share on other sites

When downsampling, you sample a texture at many locations in a rectangular area and take the average color.

This example show a rotated square shape.

return (tex_0.Sample( samLinear, (PixelPos + float2(-0.4f, 0.2f)) / OutputDimensions )
+ tex_0.Sample( samLinear, (PixelPos + float2(0.2f, 0.4f)) / OutputDimensions )
+ tex_0.Sample( samLinear, (PixelPos + float2(0.4f, -0.2f)) / OutputDimensions )
+ tex_0.Sample( samLinear, (PixelPos + float2(-0.2f, -0.4f)) / OutputDimensions )) / 4.0f;


Using linear sampling will give an uneven distribution between 4 reads per sample but will make it smooth when rescaling.


Hi Dawoodoz, the "tent" shader i was discussing, was a pass in my shader, which does the same you described but triangular, which normally should reduce flickering. It reduces the bad effects, but it's still not good enough. Thank you for your detailled description, code's are helping a lot more then words.

To my Friend "mind in a box"

i did some tests, but the order

1) Downsample
2) Upsample
3) Horizontal Blur
4) Vertical Blur

is doing a better job for me? but i have to mention, that maybe i did something wrong...but also logically, it doesn't sound correct for me, to blur the downscaled image, i will give it a second try when i have more time then tonight ;)

Of course thank you too for sharing your knowledge!

Share this post


Link to post
Share on other sites
What exacly do you mean with "is doing a better job"?

If you downsample the rendertarget to 1/16 size, blur it, and then upsample it again you will have only 1/16 of your pixel-shading costs for the blur filter.
That's the whole point in downsampling the rendertarget.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!