Sprite sheets suddenly rendering with single pixel misalignments

Hey there,

I have a pretty large hobbyist MonoGame project that I last put down a year or so ago and haven’t touched since. I booted it back up today (having not changed any of my code or assets, but I did update the MonoGame framework version it was running on about 6 months ago) and noticed that a bunch of my textures are now displaying with single pixel misalignments. I.e., the rectangular section that is being displayed from the sprite sheet/texture atlas is misaligned by one pixel, causing “spillover” bars at the top and side.

I checked the source images and my own definitions of the sprite boundaries, and they still match up fine. Seeing as this was working last time I looked at the project, but I have updated my version of MonoGame since then, I was wondering if there was any obvious change made in the past, say, couple of years affecting Texture2D formatting or rendering that I should account for in my code.

Thanks.

google → texture bleeding

I put padding in all my images to prevent this though I think it’s a hacky solution and you shouldn’t have to do it.

Explanation and source for tool https://www.hernblog.com/blogs/textureBleeding.html

Could this have anything to do with GraphicsDeviceManager.PreferHalfPixelOffset?

1 Like

Apparently, yes! Because setting it to “true” immediately fixed the issue entirely.

Very strange. Thank you for the pointer.

Thank you to the other commenters, but I don’t want to have to go through all my spritesheets adding two pixel buffer zones - and now thankfully I don’t. :slight_smile:

You realize this is usually not done by hand, right?