I’ve been experimenting trying to make a 2D game with Unreal and displaying the pixel art without distortion. I disabled the anti-aliasing without too much trouble but now I’m struggling to find a sensible way of always displaying my sprites at the correct resolution on screen, and being able to scale them up by powers of 2 if desired, so that the image isn’t distorted and none of the scripting gets broken anywhere.
I began with the obvious creating an orthographic camera with the same ortho width as my sprite (which represents a world map I intend to be larger than the screen and scrollable) and the window set to be the same size as the sprite. This causes the whole sprite to be drawn to the screen at its proper resolution. However, changing the size of the window will cause the sprite to be scaled, rather than what I would want which is to keep the sprite at the same resolution and simply not show as much of it.
i.e. If I had a sprite measuring 400x400, I’d initially want to be able to have it rendered to take up exactly 400x400 pixels under all conditions.
Scaling is another issue: pixel art will naturally look weird if it’s scaled disproportionately, so I want to be able to take my sprites and scale them up by powers of 2 if needed, without a load of manual recalculation of various things (such as the camera ortho width I mentioned).
e.g. I’m able to scale a sprite to twice its normal size by something like using a window 1/2 the size of the sprite and using a camera ortho width of 1/4 of the sprite’s width. But not only am I calculating this manually, but it ruins my scripting for having the camera pan around the map because I have to use different bounding values due to the new size of the sprite.
All in all, it would be quite a mess doing it this way, surely there must be easier ways? Are there any settings that are generally used for pixel art? The main problem seems to be how Unreal is expecting a 3D game and does a lot of things automatically that aren’t appropriate for 2D; I started this game with C++ and OpenGL a long time ago and didn’t have this problem; making the window smaller just causes less of the sprites to be in view. Perhaps some of these things can be turned off?
Another thing is that I’d like to be able to set the scaling of each sprite separately. I might have my world map with some icons on it and want to zoom in or out without scaling the icons. So something like calculating everything and rendering it, then scaling it all up together, isn’t going to work for that.
I could probably do a lot by creating some sort of mapscale variable like I did in my earlier C++ version, but that still doesn’t solve the main problem of the camera and the window size. How could I force a sprite to be drawn in its original resolution (and scale it to whatever I like after that) regardless of window size? I could decide on a window size/ratio now but I wouldn’t like to have to commit to a definite size at this early stage and if I was to change it later then I don’t want everything getting screwed up due to the new settings.