npressfetimg-1569.png

How to create a smooth zoom for 2D games from scratch? (SFML) – GameDev.net

C++ Tutorials

LorenzoGatti said:
The bad appearance you mention sounds like nearest neighbour scaling. Don’t do that, use proper interpolation;

Interpolation isn’t always welcome when using pixel art. Often you want too see individual blocky low res texels to cover multiple pixels of the high res framebuffer. With interpolation, the desired blocky texels would become a blurry mess.

The easy way to fix this is to upscale the assets without any filter, so each pixel becomes a 4×4 or 2×2 block of the same color for example. With such upscaled textures you can use interpolation and the desired pixel art look is preserved.
Another way to achieve this is to modify UVs in the pixel shader, so you get the same result without a need to upscale textures.

YesBox said:
The way I am working around this limitation right now is by having a tile atlas PNG for every zoom level (multiples of sqrt(2)). Obviously this is a lot more work for me, though I created a script to generate each sprite sheet to the appropriate size for each zoom level and adjust as needed.

You would need to upscale each zoom level texture as above, then you could use them as mip maps with a trilinear filter, so the GPU blends 2 levels automatically. Techneically you get a smooth interpolation then, without any discontinuities.
But if manually made images of different levels differ wildly, blending two of them may still not look great artistically.

It’s hard to imagine your situation without seeing some screenshots, but upscaling + filter surely is worth a try.
When i tried SFML, i think i noticed it uses a virtual low res screen resolution like 640 x 400. That’s maybe another obstacle where you need to experiment with different settings.

Source: https://www.gamedev.net/forums/topic/712245-how-to-create-a-smooth-zoom-for-2d-games-from-scratch-sfml/5447623/