visual artifact with spritesheet animation library

I created a custom library to load up and animate RPG Maker compatible character sprite sheets.

These are set up as one or more groups of 3x4 or 4x4, with the rows being for down/left/right/up animations.

I got the code working 99%, I have three sprite sheets, one with a 4x4 grid, one with 6 3x4 grids, and one with 8 3x4 grids. I have it to where you can easily switch which character.

Unfortunately, I’m having a visual artifact where the top of the sprites have a little thin black line above them. It doesn’t seem to be related to the y position of the bounding rectangle because if I adjust it by a pixel then it seems to break the code.

I’m feeling stuck, not sure what I’m doing wrong.

Anyway, I’d be greatly appreciative if anyone can take a look at the source and guide me in the right direction.

here’s the source code:

If you have x-box controller the left stick changes direction, the LT and RT change characters. on keyboard the wasd changes direction and left and right arrow changes characters.

Looks like interpolation. Since you have sprint sheet and it looks like bottom row of pixels is right above start of next frame, thus pixels are being interpolated and bleeding between frames. Either use point sampling (which is most likely what you wanted to do in first place) or add some empty pixels as a frame around sprites for each frame.

I get what you’re saying about the interpolation, but unfortunately I have no idea what point sampling is or how to implement that. My code is simply calculating the position/dimensions of the rectangle and then in the SpriteBatch Draw method it is using that rectangle to clip the loaded Texture2D.

You can pass a SamplerState to SpriteBatch.Begin.

1 Like

Aww, thanks so much, all I had to do to fix this rendering issue was set the spritebatch to PointClamp instead of letting it default to LinearClamp.

I really appreciate it :smiley:

1 Like