Smoothing lines on non-standard scales

I got problem with images smoothness during render on scale down. I got static view render of 4K (3840x2160), then I scale it down depending on the user’s resolution. Everything looks fine on equal scales (100%, 50%, 25%, etc.) but issues start occuring on non-equal, like 33.3% and so on.

Original image size is 3840x2160, so I create core RenderTarget2D with this size, then draw image and scale whole view into target resolution

// Create 4K RenderTarget
RenderTarget2D View = new RenderTarget2D(GraphicsDevice, 3840, 2160);

// In Draw( ) function, I draw image on View RenderTarget
GraphicsDevice.SetRenderTarget(View);
// ...
spriteBatch.Draw(Image, Vector2.Zero, Color.White);

// Then I draw whole View onto screen
GraphicsDevice.SetRenderTarget(null);
// ...
spriteBatch.Draw(View, new Rectangle(0, 0, 1280, 720), Color.White);

If my target resolution is 1920x1080 (scale is equal 50% of 4K render) it looks nice and smooth
obraz

The problem occurs if scale is not a multiple of 4K resolution. For example, this is how it looks for 1280x720 (which is 33.3% of the 4K view). As you can see, edges are no longer smooth and lines are broken, which don’t look nice
obraz

Is there anything I can do to prevent this and smooth the image?

Found the solution and wanted to share it here, cause it was really hard to find info about it and maybe you can struggle to fix it too.

So the issue is in multisampling (I recommend to read about it here and here). The default values in MonoGame are disabled. I guess it works in some cases, like not scaling resolution, pixelart and so on, but if you scale your images a lot, it’s better to enable it.

The post that helped me is this one by Andy

It’s just as simple as turning it in constructor. Set the value of multisample high enough, like 16, just play a little with values

_graphics = new GraphicsDeviceManager(this) {
    PreferMultiSampling = true
};
_graphics.PreparingDeviceSettings += (s, e) => e.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = 16;
2 Likes