Sprites rendering blurry with velocity

Posted by ashes999 on Game Development See other posts from Game Development or by ashes999
Published on 2012-12-11T12:37:08Z Indexed on 2012/12/11 17:24 UTC
Read the original article Hit count: 302

Filed under:
|
|

After adding velocity to my game, I feel like my textures are twitching. I thought it was just my eyes, until I finally captured it in a screenshot:

enter image description here

The one on the left is what renders in my game; the one on the right is the original sprite, pasted over. (This is a screenshot from Photoshop, zoomed in 6x.)

Notice the edges are aliasing -- it looks almost like sub-pixel rendering. In fact, if I had not forced my sprites (which have position and velocity as ints) to draw using integer values, I would swear that MonoGame is drawing with floating point values. But it isn't.

What could be the cause of these things appearing blurry? It doesn't happen without velocity applied.

To be precise, my SpriteComponent class has a Vector2 Position field. When I call Draw, I essentially use new Vector2((int)Math.Round(this.Position.X), (int)Math.Round(this.Position.Y)) for the position.

I had a bug before where even stationary objects would jitter -- that was due to me using the straight Position vector and not rounding the values to ints. If I use Floor/Ceiling instead of round, the sprite sinks/hovers (one pixel difference either way) but still draws blurry.

© Game Development or respective owner

Related posts about XNA

Related posts about graphics