XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

Downsample Texture for Post-Processing Effects

Last post 09-06-2008 1:39 PM by sonnendeck. 6 replies.
  • 09-04-2008 2:30 PM

    Downsample Texture for Post-Processing Effects

    I wrote a little program so I can test some effects. My problem is that I have 15 fps when using a post-processing effect like Blur or Glow and I figured out that the reason must be the size of the texture. I want to downsample it but I don't know how to do that.

    Can someone give me an hint?

    I would do it my HLSL file and I tried but it looks not the way it should look.

     

    Thanks.

     


  • 09-04-2008 3:09 PM In reply to

    Re: Downsample Texture for Post-Processing Effects

    If you're using SpriteBatch to render your fullscreen quads, then it will downsample or upsample automatically for you.
  • 09-04-2008 3:33 PM In reply to

    Re: Downsample Texture for Post-Processing Effects

    I'm using SpriteBatch for rendering but it's not fullscreen. My screen solution is 1280x800 and the window is 1024x768.

    Does SpriteBatch only downsampling in fullscreenmode? I dont think so because it doesn't matter I still have only 15fps instead of 60.

    Ok after I had a look over my code again i think i found something: 

    The for loop run 8 times totally I think thats to much. But may be the reason is my laptop. Is there someone who would try it on a better pc as I have? My laptop is 3 years old with onboard grafik :). If yes I would upload the program.

     

    1 // horizontal blur 
    2 void PS_HorBlur( in VertexToPixel IN, out PixelToScreen OUT ) 
    3
    4     OUT.color = 0; 
    5     for (int i=0; i<8; i++) 
    6     { 
    7          
    8         float4 posColor = tex2D(texSampler, IN.textCoord + float2(pos[i], 0) * blurSize); 
    9         float4 negColor = tex2D(texSampler, IN.textCoord - float2(pos[i], 0) * blurSize); 
    10          
    11         OUT.color += (posColor + negColor)*weights[i]; 
    12     } 
    13 }
  • 09-04-2008 4:01 PM In reply to

    Re: Downsample Texture for Post-Processing Effects

    And thank you for the quick response.
  • 09-04-2008 5:03 PM In reply to

    Re: Downsample Texture for Post-Processing Effects

    Ok I allready tried on another PC and it works better.

    Thanks for your help.

  • 09-04-2008 6:24 PM In reply to

    Re: Downsample Texture for Post-Processing Effects

    SpriteBatch will render at whatever size you tell it to: just use one of the overloads that takes a destination rectangle parameter, and you can scale that destination to whatever size you like.

    A common technique for fill-intensive shaders like blur processes is to shrink the source image to half or quarter size, blur that, then scale the blurred result back up to the original resolution. This can save a lot of pixel shader work with minimal quality loss, since the output image is supposed to be blurred in any case.

    You should be aware, though, that laptop graphics cards often don't have much fillrate, and fullscreen blur processing needs a lot of fillrate! Have you tried running our bloom sample (from this site) on this card? How does that perform?


    XNA Framework Developer - blog - homepage
  • 09-06-2008 1:39 PM In reply to

    Re: Downsample Texture for Post-Processing Effects

    I dont know the fillrate but I have a ATI X600 mobile. I shrinked the image to half size and got 20 instead of 15 fps :)
Page 1 of 1 (7 items) Previous Next