- Home /
2D: Is there a way to zoom without changing orthographic size or scale?
I feel like the answer to this might be no...
In my 2D game I have a pixel art background sprite that relies on the orthographic camera size sticking to one resolution to maintain its square pixels. Is there a way I can smoothly zoom the camera in without changing this orthographic size? I've thought about scaling everything in the scene up, but that would be a pain in the neck to deal with in my game.
Thanks very much!
Romano
Answer by Owen-Reynolds · Feb 21, 2014 at 11:38 PM
Can't be done. Whatever method was used to zoom, it has to cause the same "non-square" problem.
Say your image looks good at 128 pixels and zoomed in at 256 pixels, but not in between. This is what a "pixel correct" ortho camera size helps you do -- makes it easy to say that a cube takes exactly 128 or 256 screen pixels, and avoid those bad sizes. And that's all it does. If you zoom in, from 128 to 256 over time, no matter what technique, you're purposely making the image be all those sizes where it looks bad.
Thanks Owen. I'm not great at maths, you could be right that it's impossible to zoom between those numbers but I don't believe it can't be done at all with any resolution, since it does happen in games. I know that you can't simply decrease the orthographic size arbitrarily over time, but I wondered if there was another method that doesn't mean having to find each usable orthographic size.
I took a look at sword and sworcery on the iPad 3 with its retinal display. That zooms in very smoothly and with very sharp pixels. I tried it out on PC for comparison and with a resolution of 1366x768 the zoom still looked very good. Down at 640x480 I could tell there was a slight bit of wobbly pixel going on as it zoomed and it certainly wasn't as smooth. Is it just a case of finding all the usable orthographic sizes between $$anonymous$$imum and maximum and jumping between them? That could be tedious...
"usable [...] sizes between $$anonymous$$imum and maximum"
Exactly. And really, a sequence that looks good. $$anonymous$$aybe some sizes shrink his hat by a pixel, and some grow it by one. Choose either, just not both types alternating. It may be an equation -- like adding 8 pixels each time -- or trial and error.