Artifacts When Rotating Sprite

I’m getting artifacts when rotating a 2d sprite. It only appears against all black tiles/sprites. My SamplerState is set to Point.Clamp and PreferMultiSampling is set to false. The texture has PremultiplyAlpha set to true in the Pipeline tool and the BlendState on my SpriteBatch.Begin is set to null. All of my sprites are without issue except tiles that are all black. Any thoughts/suggestions?

If your using spritebatch.Draw you need to set those states after you call begin.
Try setting the blend state to opaque im not sure its not set to that by default though.

If its just the edges its probably a point clamp issue.
if its the whole thing its probably a blendstate issue.

My my thought is that you are describing…
Additve blending, alpha blending or edge aliasing.

Thanks for the response! So, yeah… I’m passing all of the relevant settings as arguments to SpriteBatch.Begin(). PreferMultiSampling = false is set in the Game1.cs Constructor. I’m guessing I’m dealing with edge aliasing. It only happens on these specific tiles (solid color, black). Kind of strange… I’ll look into edge aliasing from rotation and how to deal with it.

check your images in your paint program as well that can cause artifacts too sometimes.

The image is fine. The artifacts seems to be appearing right at the tile edges and I’m using a source rectangle to draw the tiles, so I’m guessing this is either edge aliasing or some type of issue with the texture mapping so to speak… the rotation is happening via transform matrix that’s supplied to the SpriteBatch.Begin method, so all of the tiles are being rotated (and cut from the same spritesheet) and drawn the same exact way…

When stuff like this happens, if you can boil it down to a very simple program, it’s sometimes helpful to debug. It also has the added benefit of being able to be posted to a site like this so people can try it out :slight_smile:

So yea, can you provide a link to your image, as well as your code (pastebin is useful here) so we can try it out?

Here’s a screen shot. You can see tiles are slightly rotated. The artifacts (pink, grey) are all occurring at tile edges. You can’t tell that, but I know where the tile edges are. I may be able to make a small, sample project later.

Image Link

Ok, so I’ve determined that the artifacts are showing up along tile edges when said tile edge is next to a row of transparent pixels in my sprite sheet. Tiles that are completely surrounded by other tiles do not have the issue. It’s either an aliasing or texture wrapping issue. Although SamplerState is set to PointClamp, so I think texture wrapping/sampling shouldn’t be the culprit…