Hello Guest

Author Topic: Pixel perfect scaling for sharp retro-style pixel graphics?  (Read 39669 times)

theremin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 20
    • View Profile
Pixel perfect scaling for sharp retro-style pixel graphics?
« on: March 17, 2012, 01:39:13 am »
I'm investigating 2D Toolkit for possible purchase, but I want to make sure it accomplishes what I'm looking to do first before I buy.

If I design a game with retro-style sharp pixel graphics (with hard edges and no anti-aliasing) at 480x320 for the iPhone 3GS, can I use Resolution Override with scale=2 to size the game up for iPhone Retina and iPad (and scale=4 for the iPad 3) and maintain the sharpness of the graphics, just at double the size? Or will 2D Toolkit soften the edges? What I'm looking for is for 1:1 pixel ratio on the 480x320 iPhone, and 2:1 pixel ratio on iPhone Retina -- essentially "pixel perfect" in both cases, just double the size in the latter case.

To illustrate, take a look at this page: http://en.wikipedia.org/wiki/Image_scaling

I would want my sprites to be sized up like the TV on the left (nearest-neighbor scaling) as opposed to smoothed anti-aliased scaling. Can I accomplish this with 2D Toolkit?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Pixel perfect scaling for sharp retro-style pixel graphics?
« Reply #1 on: March 17, 2012, 09:52:27 am »
You can select hard edges (point sampling) as an option on the sprite collection.

You can either use the camera or other means (manual ortho size scaling) to get the different sizes you need. I'm not sure if Unity will detect the correct resolution on the new iPad though, but if it doesn't it will be an issue with Unity and not a problem with 2d toolkit.

theremin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Pixel perfect scaling for sharp retro-style pixel graphics?
« Reply #2 on: May 03, 2012, 11:25:48 pm »
Thanks for the response. I took the plunge and just purchased 2D Toolkit.

Unfortunately, I'm having trouble getting scaling to work correctly. I'm working with a 2dtkCamera and a 2dtk TextMesh/Font. My font is a pixel font, so it has sharp edges and no anti-aliasing. (Again, I'm going for a retro graphic style with sharp pixels.)

The font looks great at the default camera setting, but if I use Resolution Override on the 2dtkCamera and set the scale to 2 or 3, the font is blurry and unusable.



How can I get pixel perfect, sharp fonts at a variety of camera scales?

theremin

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Pixel perfect scaling for sharp retro-style pixel graphics?
« Reply #3 on: May 03, 2012, 11:30:25 pm »
Argh, of course right after I posted this question I figured it out! Sorry about that.

For posterity's sake, if anyone is curious:

Although the 2dtk Fonts don't seem to have a "hard edges" option, you can manually open the font texture in Unity (i.e., the .tga you generated in BMFont and imported into your project), and then change the Filter Mode for the texture to Point. Voila, hard edges!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Pixel perfect scaling for sharp retro-style pixel graphics?
« Reply #4 on: May 04, 2012, 09:12:26 am »
Glad its sorted :) I'll move this thread to FAQs.