Anti aliasing a pixel using SpriteBatch

I am developping for the PC, Windows

I am trying to use a single pixel texture to draw primitives on screen using spritebatch.Draw().

I want those primitives to be anti aliased, but I cannot get it to work. Here is an image showing the problem

What I have tried so far :

  • Using a white 128x128 texture instead of a single pixel

  • The following code in Game.Init()

    graphics.PreferMultiSampling = true;

    graphics.GraphicsDevice.RasterizerState.MultiSampleAntiAlias = true;

  • The following code in spriteBatch.Begin :


None of the above as had an effect. Any help is appreciated.

What is your approach to draw the circle?

If you draw the circle using many small parts, then MSAA won’t help in your case at all because it is simply not designed for that use case. It works with larger primitives.

Honestly, I wouldn’t be surprised if MSAA would not be supported at all.

Thank you for your reply!

My approach to draw the circle is drawing large rectangular primitives (32 rectangles for a circle), using trigonometry to place the rectangles at equidistant points around the circle, and rotating / scaling my single pixel texture so that those big rectangles touch each other, giving the illusion of a circle if the number of rectangle is high enough.

I am currently using 32 rectangles, but I have the same problem wether I use 8 (then I have a regular octogon) or 6 (hexagon)

Here is a perhaps more useful picture of how I am drawing the circle (the alpha on my rectangular primitives is set to 0.5 so you can see the overlap and the aliasing :

Found the issue regarding MSAA: