Author Topic: Fixed Size vs Pixel Perfect  (Read 8266 times)

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Fixed Size vs Pixel Perfect
« on: July 23, 2014, 07:55:23 AM »
Hi guys,

I'm doing a project and we've been wondering how to setup the UI: Fixed size or Pixel perfect. I understand the difference between the 2 and I know that pixel perfect might be a little fuzzy. But I encountered something strange with the fixed size:

Step 1 - While my uiRoot is in fixed size, I make it pixel perfect to properly align every asset underneath it. I looked at the appearance of the ui and it has a little fuzziness, even in the base resolution. I take a screenshot.
Step 2 - I then switch my uiRoot to pixel perfect and make it pixel perfect. Everything become neat and crispy. I take a screenshot.
Step 3 - I switch my uiRoot back to fixed size but I don't touch a thing. I take a screenshot.

I then compared all 3 screenshots and this is the weird part, screenshot 3 is less fuzzy than screenshot 1. Is there any reason to this?
Unity 4.5.3f
NGUI 3.7.0

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #1 on: July 23, 2014, 07:56:29 PM »
Fixed Size means NGUI is using virtual pixels, implying pixels don't line up 1 to 1. The UI will literally remain at fixed size, regardless of screen resolution. If something was taking 30% of the screen with 320x240, it will still take 30% of the screen with 1600x1200. Only Pixel Perfect mode maps pixels 1:1. I don't think you quite understood what the two options do...

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #2 on: July 23, 2014, 09:32:17 PM »
AFAIK, you can get crisp graphics with fixed size, but you need to set Manual Height to Screen.height / 2^X where X >= 0

If it's still fuzzy, then there's probably something weird going on (e.g. when you duplicate objects, the scale gets set to 1.0008 instead of 1).

I'm using "fixed size" mode for my project and was finally able to get crisp display after a bit of tinkering.

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #3 on: July 24, 2014, 07:37:13 AM »
ArenMook: I understand perfectly that FixedSize cannot guaranty a crisp look, what I don't understand is why making the UIRoot PixelPerfect while it's is FixedSize or PixelPerfect doesn't snap/resize the same way. Shouldn't making pixelperfect in FixedSize use the original size to snap/resize? I don't know if it's because I'm not understanding things correctly...

Wisteso: I'll have a look at this, but I found that long paragraphs will be crisp on certain lines while 2-3 lines lower they get all fuzzy.

I've got the feeling I'll have to switch to PixelPerfect for the whole UI, which might not be a bad thing ;) (but a lot more overtime)
Unity 4.5.3f
NGUI 3.7.0

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #4 on: July 25, 2014, 01:20:17 AM »
Quote
Shouldn't making pixelperfect in FixedSize
I don't understand what you mean. They are two completely different settings on the UIRoot. How can you use one in another? That makes no sense. Do you mean the MakePixelPerfect() function instead? All that does is resizes the sprite to its native size. It doesn't make things look crisp, it just resets the sprite's size. It's actually an old name, back from early days of NGUI. In inspector this functionality is called "Snap to pixels" now, and has been for a while. But again though -- virtual pixels that UIRoot uses, not on-screen pixels.

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #5 on: July 25, 2014, 07:40:07 AM »
Sorry about the naming convention, "Snap to pixel" is what I mean.

What I would like to understand is why there is such a big difference of quality between 2 UIRoot set at FixedSize.
* On the first one I set UIRoot to FixedSize and do a "Snap to Pixel" on it. The result stays a little blurry.
* On the second, I set UIRoot to PixelPerfect, do a "Snap to Pixel" on it and switch the UIRoot back to FixedSize.

At the end, both UI root are at FixedSize, but the quality of the "Snap to Pixel" is very different. Is it because the resolution to "Snap to Pixel" used by the FixedSize will take the resolution of my work window instead of the native resolution?
Unity 4.5.3f
NGUI 3.7.0

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #6 on: July 26, 2014, 12:31:35 AM »
As I explained twice in this thread already... "Fixed Size" means virtual pixels. Unless your resolution happens to match the Manual Height specified on the UIRoot, then the screen pixels will not line up with virtual pixels, resulting in a loss of clarity. "Snap to pixels" snaps to virtual pixels, not to screen pixels.

If you want clarity, use Pixel Perfect, not Fixed Size.

I'm not sure how else to explain it...

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #7 on: July 27, 2014, 09:20:41 AM »
It's a symptom of evolving names over time.

Like ArenMook says, FixedSize is in Virtual Pixels, which means you manually define a height and the screen is divided into the number of Virtual Pixels you define in manualHeight.

On a 1024x768 screen, you can for instance, define a manualHeight of 200 - then for NGUI, the screen is 200 vPixels high, and doing a snap to pixel, will snap to the virtual pixels. A 100x100 sprite, will take up half the screen height and obviously be fuzzy, because it's much bigger than a screen pixel. (It doesn't help that "Snap to Pixel" used to be called MakePixelPerfect :) )

UIRoot's PixelPerfect, means that NGUI is working with screen pixels. A 100x100px sprite will be exactly 100x100 on any screen, but be physically smaller or larger depending on the DPI of the device (a retina iphone will have a smaller sprite than a non-retina iphone).

Does this explain it clearly to you?

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #8 on: July 28, 2014, 07:43:28 AM »
Nicki: Thanks for the explanation. From what I understand, this means that doing a "Snap to Pixel" in while in "Fixed size" will not use the base resolution setting to calculate the snapping, but the actual window pixels to "Snap to pixel". This would explain the blurriness and why I get better result if I "Snap to pixel" on a UIRoot using "Pixel Perfect" and switch back to a UIRoot using "Fixed Size".

Does dynamic fonts get scaled down also or do they switch font size to fix the new resolution?
Unity 4.5.3f
NGUI 3.7.0

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #9 on: July 28, 2014, 02:26:20 PM »
It depends on the settings on the labels. The font won't as such be resized, unless the label requests it in a certain size. 30 is 30, no matter pixel perfect or FixedSize. Again, with fixed size, the physical size of that label may be different than what you would think, say if manualHeight is set to 30, then a letter would be as tall as the screen, but the resolution of the letter would still only be 30 pixels high, so you'd see a bunch of filtering.

You can fake it by forcing the label to have a higher resolution in its data and resizing that down - if the manualHeight is then lower than the actual height, it would still look good.

Some time in the future, I hope we can just get native vector fonts as everything would be easier. :)

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #10 on: July 28, 2014, 02:31:15 PM »
Amen to that. But that might require vector support by Unity no? (vector support would also be amazing!)
Unity 4.5.3f
NGUI 3.7.0

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Fixed Size vs Pixel Perfect
« Reply #11 on: July 29, 2014, 10:15:51 AM »
Yeah that would likely have to be supported by Unity. The issue right now is more of performance, because on a purely theoretical level one could totally do vector fonts now, they're just a bit heavy. :/