Hello Guest

Author Topic: tk2dCamera woes  (Read 6304 times)

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
tk2dCamera woes
« on: January 26, 2015, 03:34:42 pm »
Ok, so I'm very far along in my game and have recently decided that the ratio of sprites on screen is too big and want to scale it down a bit. I naturally tried messing with the camera PPM setting (which has always been set to 64). I found that 58 has the perfect size of everything on screen, but it very subtly screws with some pixels - things like some pixels fatter than others, some half pixel-ish stuff, etc. It's subtle, but very frustrating.

My question is: Am I SOL? It's far too late to change source graphics where were all designed with the intention of 64 pixels per meter (the tilemaps, etc). Is there a way to calculate the scale so it renders perfectly? I know it's a good idea to have the sprite collections PPM and the camera PPM to be the same, but if I change the sprite collections PPM then everything is even worse.

Please tell me there is a solution! Thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera woes
« Reply #1 on: January 26, 2015, 04:04:20 pm »
You need camera and collection PPM to be exactly the same to display pixel perfect. If its not pixel perfect you end up with weird pixels, half pixel chopping, etc - the stuff you've seen.

You need to change the artwork so its correct to the resolution you want to display it at, and then adjust the sprite collection ppm setting so the sprite is the same physical size as it was before. Eg. if you've scaled all the sprites from 100x100 -> 50x50 and your PPM was 20, you should reduce it to 10 and it'll appear at the same physical size. You shouldn't need to change the camera.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: tk2dCamera woes
« Reply #2 on: January 27, 2015, 07:58:01 pm »
Thanks for the reply. Sounds like it's far too late to make these sorts of changes :/

Though, you say I shouldn't have to change the camera - but don't the camera and collection PPM have to be the same? Sorry, just confused because you said two different things.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera woes
« Reply #3 on: January 27, 2015, 09:58:11 pm »
If you want pixel perfect output (i.e. 99.99% of the time) you should have ppm the same on both.

Changing the ppm on the camera will show more or less of the scene, eg. 2x or 0.5x ppm = will show twice or half the amount of information. The sprites themselves are the same physical size.

If you change the ppm of the sprite collection, you get the same result, but this time the camera sees the same amount of stuff, but the sprites are 2x or 0.5x the size as they were before.

Make sense so far?


Now, if you physically change the size of the sprite, eg. from 128x128 -> 64x64, the sprite will naturally appear 1/2 the size as it was. Imagine 2 sprites positioned side by side, once you resized it, you'll see a gap between them. 2 choices - reposition the 2nd sprite, or... scale the sprites up 2x. #1 involves setting up your scene again in most cases, however, luckily its easy to do #2 - you just change the ppm on the collection to compensate. In this example, changing the ppm on the sprite collection and not the camera will result in exactly the same scene as before, but with less detail. If you then want to adjust your camera to match thats up to you - thats the easy bit.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: tk2dCamera woes
« Reply #4 on: January 29, 2015, 05:03:30 pm »
Thanks for the explanation, makes sense.

fsadeq

  • 2D Toolkit
  • Sr. Member
  • *
  • Posts: 353
    • View Profile
Re: tk2dCamera woes
« Reply #5 on: February 04, 2015, 09:27:30 pm »
So, I ended up resizing the source assets and everything is peachy except for one thing: I'm getting the weird half pixels/broken pixels on an iPhone 6 only. It looks perfect on an iPhone 5 and iPhone 6 Plus, but the 6 gets strange pixels. I'm using the 5/5S as native res and then the camera override is a wildcard with Fit Visible / Center. Any reason why just the iPhone 6 (and not the 6 Plus) would do this?

Thanks, again, for the 100th time  :)
« Last Edit: February 04, 2015, 09:32:46 pm by fsadeq »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera woes
« Reply #6 on: February 04, 2015, 10:30:37 pm »
Because it isn't pixel perfect on that platform I guess... Not sure why specifically but my guess would be the amount it has to scale to fit, could probably work it exactly but I am too sleepy for maths right now.

pankaj68

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: tk2dCamera woes
« Reply #7 on: February 05, 2015, 07:36:33 am »
hi currently i am using 2D toolkit 2.4 in my project... i face screen resolution problem in iPhone5 and some android devices.i already set overrides as wildcard & stretch...really i don't know what to do now.... please give me some solution so i can complete my project....thanks in advance....

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera woes
« Reply #8 on: February 05, 2015, 09:19:07 pm »
Quote
hi currently i am using 2D toolkit 2.4 in my project... i face screen resolution problem in iPhone5 and some android devices.i already set overrides as wildcard & stretch...really i don't know what to do now.... please give me some solution so i can complete my project....thanks in advance....

And what is it you're trying to do exactly? Every game needs to be scaled differently.