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

Turning off 2D Sprite Anti-Aliasing

Last post 4/10/2007 2:33 PM by JeffWeber. 12 replies.
  • 3/22/2007 11:36 AM

    Turning off 2D Sprite Anti-Aliasing

    A friend and I are putting together a 2D sprite game and we were wondering if there's any way to turn off Anti-Aliasing. As it works right now, since the sprite is working kind of like a texture a flat surface, it's being rendered like a texture and so the edges are getting softened - this is giving is some ugly lines when the sprites are "in between" pixels on the screen. Since we don't need Anti-Aliasing, we were wondering if there's some way to force it off. I'm sure there's probably some documentation about it out there somewhere, but we haven't been able to find it >.< If anyone knows where to point us or has an answer, it would be awesome! Thanks guys.

  • 3/22/2007 12:24 PM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    Try setting the uv mode to clamp and the filtering to point.

     

     

  • 3/22/2007 8:25 PM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    Thanks for the reply, we'll give that a shot and see if it works :)
  • 4/6/2007 12:38 PM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

  • 4/6/2007 3:14 PM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    SpriteBatch.GraphicsDevice.SamplerStates

     

  • 4/8/2007 7:55 AM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    Here is what I find for SamplerState properties:

     http://msdn2.microsoft.com/en-us/library/microsoft.xna.framework.graphics.samplerstate_properties.aspx

    Which filter should be set to "Point" the MipFilter?

    Also, should these be set on SamplerState[0] ?

     

  • 4/9/2007 3:04 PM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    You should set both MinFilter and MagFilter to point, on SamplerState[0].

    If you are using SpriteBatch for your drawing, you will need to specify SpriteSortMode.Immediate when you call SpriteBatch.Begin, and set these states immediately after the Begin call, but before calling SpriteBatch.Draw. Otherwise SpriteBatch will reset the states to normal filtering mode for you.

    I'm actually not convinced it is such a great idea to set point sample filter mode, though! If you don't like the look of the filtering, wouldn't it be easier to just clamp your sprite positions before you draw them, to avoid ever rendering at a fractional screen location? 

    XNA Framework Developer - blog - homepage
  • 4/10/2007 7:48 AM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    "I'm actually not convinced it is such a great idea to set point sample filter mode, though! If you don't like the look of the filtering, wouldn't it be easier to just clamp your sprite positions before you draw them, to avoid ever rendering at a fractional screen location? "

     Could you elaborate on this. 

    All I want is to minimize any jaggies on my sprite. I have some all black sprites that are pretty small and I notice some jaggies/distortion on the edges when the sprite rotates. This is at 1024x768 full screen.  Possibly this is just caused by how I created the images, but I'm seeing the distortion on a straight edge so it doesn't seem likely.

    The clamping idea sounds like it might be a way to go. Does this just mean always making sure my sprite positions are whole numbers?

  • 4/10/2007 10:30 AM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    JeffWeber:

    The clamping idea sounds like it might be a way to go. Does this just mean always making sure my sprite positions are whole numbers?

    It means making sure your sprite rendering positions are whole numbers. Continue to use floating point to store your sprite positions for accurate simulation. Just pass integer-clamped values to the Draw call.

     

     

  • 4/10/2007 12:12 PM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    JeffWeber:

    All I want is to minimize any jaggies on my sprite. I have some all black sprites that are pretty small and I notice some jaggies/distortion on the edges when the sprite rotates.

    If you are rotating, you definitely don't want to turn filtering off: the hardware does this precisely to minimize jaggies, and you will get MUCH worse results using point sampling.

    Could you post a screenshot of the problem you are seeing? 

    XNA Framework Developer - blog - homepage
  • 4/10/2007 12:33 PM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    Yes, I can post something in the next couple days... If I don't solve the issue first.

    Should I be clamping the position of all my sprites, even the dynamic ones ? Currently the sprite positions for all my dynamic sprites come from my physics enigne. I can easily enough clamp those prior to setting the sprite position. I will try it tonight.

     Thanks everyone for the help.

     

  • 4/10/2007 1:18 PM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    Just make sure you only clamp the values used for drawing. Otherwise you will lose precision and your physics will begin to fall apart.

     

  • 4/10/2007 2:33 PM In reply to

    Re: Turning off 2D Sprite Anti-Aliasing

    Yes, I don't think my physics enigine would operate very will with integer precision. :-)

     Thanks again for the help.

Page 1 of 1 (13 items) Previous Next