Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XNA: Scaling down Texture 2D antialias?

I'm working on a project in XNA, and I'm using some rather large textures, which I'm loading into the game as Texture2D objects, and drawing on the screen much smaller than they are loaded in. The reason for this is that I need to draw them at various different sizes in different places, and, while I could do this with multiple textures, it is impractical to do so.

My problem is that XNA does not seem to antialias these Texture2D objects upon scaling them down. I have set:

graphics.PreferMultiSampling = true;

and also

spriteBatch.Begin(SpriteBlendMode.AlphaBlend);

But to no avail. I have also tried various things involving the filters in the GraphicsDevice but, to be honest, without really knowing what I was doing.

Obviously, I'm drawing this using a spriteBatch, but aside from that, nothing particularly interesting in the way I'm drawing it.

Here is an (enlarged) example of what's happening, and what I'm trying to make happen:

Actual ResultDesired Result

As you can see, XNA is not providing any anti-aliasing when rescaling the image. Is there a way I could force it to do so, in an effort to make the edges look cleaner?

like image 559
Hoeloe Avatar asked Apr 06 '12 15:04

Hoeloe


1 Answers

Are you calling graphics.PreferMultiSampling = true; before GraphicsDevice is created? You must turn it on before it is created, either in the Game constructor or Initialize().

like image 68
Caleb Jares Avatar answered Oct 15 '22 14:10

Caleb Jares