Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (10 posts)

RenderTarget PointClamp Issues

Last post 12/30/2011 1:39 PM by Khada Kuraki. 9 replies.
  • 12/28/2011 10:48 AM

    RenderTarget PointClamp Issues

    Okay, so i'm trying the classic draw to a render target, and then scale the render target up and draw it to the back buffer, while using Point Sampling/Nearest Neighbor style filtering, to keep the pixel look.

    What I don't understand is that for some reason I keep getting filtering. 

    The render target is working fine if i don't apply any scaling and simply draw it to the backbuffer, comes out nice and perfect. 

    I'm using the following to draw the render target

     batch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, nullnull); 
     batch.Draw(rendertexture, new Rectangle((int)destination.X, (int)destination.Y, (int)destination.Width, (int)destination.Height), null, Color.White); 
     batch.End(); 

    Now if the destination rect for sprite batch matches the width and height of the texture there is no filtering, yet when i pass in a larger width/height such as 2x, I get the linear filtering effect. 

    I've tried changing various things such as using sprite batches scale property vs the rectangle based stretching, but nothing seems to prevent the filtering. 

  • 12/28/2011 1:42 PM In reply to

    Re: RenderTarget PointClamp Issues

    So after another 3 hours of fighting with this, I tried it on another laptop, and it is working fine. It seems to be some issue specific to this development machine, though it doesn't make much sense. I'd really love to know why Point filtering wouldn't work on some GPU, I'd also love to be able to detect if this was the case, as I'd likely change available scaling options in the game if I knew about this.
  • 12/28/2011 4:15 PM In reply to

    Re: RenderTarget PointClamp Issues

    Not really sure if this applies to your situation but are your textures to the power of 2? Certain things don't work unless your texture are ^2 (depending on the GPU). I'm not sure if point clamp is one of those things but give it a go anyway.
  • 12/29/2011 6:01 AM In reply to

    Re: RenderTarget PointClamp Issues

    Yeah not sure here, I tried making the render target a power of two, before it wasn't, but this didn't help any.
  • 12/29/2011 7:01 AM In reply to

    Re: RenderTarget PointClamp Issues

    Point clamp itself is a texture filter though so you want the textures themselves to be ^2. Try using only a single ^2 texture and see how you go.
  • 12/29/2011 6:02 PM In reply to

    Re: RenderTarget PointClamp Issues

    Just before your spriteBatch.Begin, try changing SamplerState[0] (directly on GraphicsDevice) to something else that isn't PointClamp (like SamplerState.LinearWrap).

    There was a bug where sometimes the SamplerState wouldn't update properly, and this was the workaround.
  • 12/29/2011 6:10 PM In reply to

    Re: RenderTarget PointClamp Issues

    In another post Shawn Hargreaves wrote:

    You can override these states as long as you use SpriteSortMode.Immediate.

    Set them to Point immediately after you call SpriteBatch.Begin.
  • 12/29/2011 7:09 PM In reply to

    Re: RenderTarget PointClamp Issues

    Answer
    Reply Quote
    This isn't a not-using-XNA-API-correctly issue, but a broken driver that's not doing what you are asking it to.

    Either the driver is just flat out wrong (make sure you have the latest version?)  or perhaps you have some strange override settings in its control panel?
  • 12/30/2011 11:30 AM In reply to

    Re: RenderTarget PointClamp Issues

    Yeah, I'm going to agree with this being a driver issue. My primary windows dev environment is XP under a virtual machine with GPU support up to SM 2.0, and while normally I don't run into any problems with dev, or even most commercial games, it looks like this is one of these odd bugs.

    Testing on another windows system, shows the expected behavior as well. What a quirky issue. 
  • 12/30/2011 1:39 PM In reply to

    Re: RenderTarget PointClamp Issues

    Ah, that's a bit shitty. Of course Shawns oracle-wizard-voodoo-magical-prophet talents light the way, don't forget to mark your post as answered :)
Page 1 of 1 (10 posts) Previous Discussion Next Discussion