XNA: Scaling down Texture 2D antialias?
Asked Answered
H

1

6

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 Result Desired 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?

Howie answered 6/4, 2012 at 15:41 Comment(0)
A
2

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().

Aloin answered 6/4, 2012 at 17:49 Comment(2)
I'm calling it in the Game constructor, after defining the GraphicsDeviceManager (obviously) and before calling ApplyChanges().Howie
I may also add that no matter where I add it, it seems to make no difference.Howie

© 2022 - 2024 — McMap. All rights reserved.