Author Topic: 1 Pixel Gap on some Aspect Ratios  (Read 3979 times)

Charriu84

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 9
    • View Profile
1 Pixel Gap on some Aspect Ratios
« on: February 09, 2017, 07:11:04 AM »
Hi,

I noticed that my sprites have strange offsets (1 pixel gaps) on some aspect ratios (3:2) as you can see here:



This is a simple scene with just an 8x8 pixel sprite in it. The actual image behind it has the same dimensions. Notice how the pivot is at the bottom right of the rectangle, but the actual image is offset by some pixels. These are the settings


https://www.pic-upload.de/view-32650266/ScreenShot2017-02-09at12.52.58.png.html

I don't understand what causes this gap. Can anybody explain this to me? I'm using NGUI 3.9.6

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 1 Pixel Gap on some Aspect Ratios
« Reply #1 on: February 13, 2017, 11:30:05 AM »
Just google DirectX9 half pixel offset.

It's nothing you have to concern yourself with, and is something that will go away if you update your Unity and NGUI.

Charriu84

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: 1 Pixel Gap on some Aspect Ratios
« Reply #2 on: March 07, 2017, 03:49:31 AM »
I've updated to Unity 5.5.1 and NGUI 3.11.2. I've tested it in an otherwise empty project and the problem still occurs. Am I missing something? Also I'm on macOS Sierra 10.12.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 1 Pixel Gap on some Aspect Ratios
« Reply #3 on: March 10, 2017, 11:08:20 AM »
Oh, on a Mac there is no pixel offset, but there may be an alignment offset if your game window's dimensions are not dividable by two.

Check your game view size.

Charriu84

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: 1 Pixel Gap on some Aspect Ratios
« Reply #4 on: March 14, 2017, 07:33:00 AM »
I did some more tests and it's not the gameview size. I've put the gameview to a fixed 960x640.

I have my UIRoot set to
Scaling Style = Constrained
Content Width = 2048 Fit = True
Content Height = 1536 Fit = False

My Camera is set to perspective and everythings fine. But when I switch the camera to Orthographic I see the gap.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 1 Pixel Gap on some Aspect Ratios
« Reply #5 on: March 15, 2017, 01:25:23 PM »
Your content size is larger than your game view, so yeah there's bound to be some inconsistencies. 1 pixel according to NGUI (content size) is not the same as 1 pixel of your game view. If you make the game view match the UIRoot size, there won't be any gaps or padding. Anyway all of this is pointless anyway, assuming your target device is 2048x1536 (iPad?) -- as the downscaling to 960x640 is going to happen only in the editor.

Charriu84

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: 1 Pixel Gap on some Aspect Ratios
« Reply #6 on: March 16, 2017, 08:19:31 AM »
Ah ok. It's not that pointless as my target device include all iOS devices. I used the constrained UIRoot because I wanted my UI to be in the correct scale corresponding to the aspect ratio of the device. Maybe I missunderstood this setting. But thanks for explaining.