XNA: Scaling 2D smoothing texture?

I am working on a project in XNA and I use fairly large textures, which I load into the game as Texture2D objects, and drawing on the screen is much smaller than they are loaded. The reason is because it is necessary to paint them of different sizes in different places, and although I could do it with several textures, it is impractical.

My problem is that XNA does not look like the antialiases of these Texture2D objects when they are reduced. I have installed:

graphics.PreferMultiSampling = true; 

and

 spriteBatch.Begin(SpriteBlendMode.AlphaBlend); 

But to no avail. I also tried various things related to filters in GraphicsDevice, but to be honest, not knowing what I'm doing.

Obviously, I draw this with spriteBatch, but other than that, there is nothing particularly interesting about how I draw it.

Here is an example (enlarged) of what is happening and what I'm trying to do:

Actual ResultDesired result

As you can see, XNA does not provide any smoothing when rescaling an image. Is there a way to make him do this to make the edges look cleaner?

+6
source share
1 answer

You call graphics.PreferMultiSampling = true; before creating GraphicsDevice ? You must enable it before it is created, either in the Game constructor or Initialize() .

+2
source

Source: https://habr.com/ru/post/912614/


All Articles