Hello Guest

Author Topic: Pixel perfect sprites and camera zoom values  (Read 4476 times)

LaserDinosaur

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Pixel perfect sprites and camera zoom values
« on: January 20, 2015, 02:13:15 am »
Hi there

I seem to have run into the same problem as this poster back in August.

I have my native resolution matching my preview resolution, I have the pixel-perfect override turned on. After playing about with a dither test on my own I eventually found that it seems to work fine as long as the camera zoom is a whole number. Setting it to 1, 2, 3 etc. means no pixels pulsating and swimming around the screen, but if I set it to 1.2 it goes all screwy. It seems that a half zoom (eg. 1.5) is the worst.

Looking at the preview video of the Pixel Perfect asset that the other poster linked too, it seems that it's zooming in using whole numbers as well - so possibly it has nothing to do with one system being better than the other and entirely to do with using whole numbers when zooming in.

Which leads me (finally) to my point - is there something inherently wrong in using fractional zoom values on a camera? Is there something going on in the background with rounding errors that means cameras (at least for pixel perfect) should always be whole numbers?

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Pixel perfect sprites and camera zoom values
« Reply #1 on: January 20, 2015, 10:17:23 am »
Imagine this pattern in pixels. OOXOOXOO
Now scale it up 2x. OOOOXXOOOOXXOOOO
Scaling up in whole numbers is easy, you just repeat each 'pixel' N times.

How would you scale it up 2.5x? Which pixels do you choose to double?
You can't be pixel perfect when you do fractional scales, just not possible.

LaserDinosaur

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Pixel perfect sprites and camera zoom values
« Reply #2 on: January 21, 2015, 02:42:41 am »
Cool, that's what I was thinking of too, glad to know I was on the right track.
 
It's funny how silly little concepts like this are so obvious in retrospect, but when your just getting started in game development it's such a huge "AHA!" moment ;D