Author Topic: Inconsistent Pixel Perfection between Odd-sized SD and Double-res HD Textures  (Read 3161 times)

David Foster

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
I have noticed that odd-sized sprites have their dimensions evened out when hitting 'Correct' or calling MakePixelPerfect(), so an underlying texture might be 39×39 pixels, but its sprite dimensions become 40×40. I see that this is deliberate, as this does indeed result in the sprite being pixel perfect.

However, these even dimensions do not result in pixel perfect sprites when the reference atlas is replaced with the HD atlas (with 0.5 pixel size). In this instance, an underlying HD texture might be 78×78 (i.e., 39 * 2), and its dimensions are 'corrected' to 40×40, but this is not pixel perfect. In fact, the dimensions which do result in a pixel perfect HD sprite are 39×39 – half of 78×78, as you'd expect.

How can I resolve this issue? It seems my options at present are to either sacrifice pixel perfection in HD or to manually correct dimensions and sacrifice pixel perfection in SD.

I have uploaded a very simple test case project with a README detailing steps to replicate. Please download here: https://www.dropbox.com/s/c1vfwoupcfi2lpq/NGUI%20Pixel%20Perfect%20Playground.zip. It is password protected, so you need not fear for unpaid users getting their hands on NGUI. Michael, I have PMd you the password to extract.

Your assistance on this would be hugely appreciated. I'm on a tight deadline and anything you can do to help might just save my life.
« Last Edit: November 14, 2013, 01:16:25 PM by David Foster »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Hmm... I will have a look into this, thanks -- but I suggest you keep the sprites with dimensions dividable by two in both cases.

David Foster

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Thanks Michael. Unfortunately there are a couple of reasons right now why I can't have all dimensions divisible by two:
  • I built the whole UI on the understanding that lowest res sprites can be odd, and I think that's a fair expectation. Changing the textures now will take literally tens of hours. My deadline is tomorrow.  :(
  • My source artwork is HD designed at 2048×1536 and is comprised of quite large individual textures, meaning for textures to resolve to even in SD, I need to round to nearest 4, 8, 12, etc. This will result in a lot of wasted texture space.
I am so sorry to be pushy but what are your are immediate thoughts on this? Do you think this could be fixable at the NGUI level?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
I am in Copenhagen attending Unity's Hack Week this week, so I can't be of much help until next week. Even if I did find the time to squeeze this in and investigate the issue though, I'd first put it into the Professional repository, and wouldn't release an update until the following weekend. Certainly not by tomorrow.

David Foster

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Okay, thanks. Well I just bought a Professional license ten minutes ago specifically to get access to another bug fix you posted today (atlas reference break on slice adjustment).