Author Topic: UISprite: 1 pixel borders flicker when object is moved  (Read 6308 times)

whisp

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
UISprite: 1 pixel borders flicker when object is moved
« on: December 07, 2014, 05:32:47 PM »
Hi,

I'm moving a prefab made from a couple of UISprites by script: Basically a frame, marking a moving object in the game. Unfortunately the borders of that frame are flickering when the prefab is moving.

Basically the prefab is made from 3 sprites: One with a background texture, one with colored corners, one with differently colored borders. Both, the colored corners as well as the colored borders, are 1 pixel wide. The textures are all at a size of a power of two (and are imported in original size into the atlas). The problem doesn't occure when the borders are wider than 1 pixel.

Can i do something to fix that problem (other than making wider borders)?

Thanks for any hints,
whisp

Agent_007

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 5
  • Posts: 27
    • View Profile
Re: UISprite: 1 pixel borders flicker when object is moved
« Reply #1 on: December 08, 2014, 02:20:23 AM »
Can you limit your sprite positions to integer values?
http://www.reddit.com/r/Unity2D/comments/2eeo4n/pixel_perfection_in_2d_xpost_from_unity3d/ (3. Sprite transforms)

whisp

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UISprite: 1 pixel borders flicker when object is moved
« Reply #2 on: December 08, 2014, 08:41:04 AM »
Thank you!

Rounding to integers works, there's no flickering anymore and in general it looks better than the flickering borders. However, it is choppy instead: it's clearly visible that it is moving pixel wise, i wouldn't have expected it to be so noticeable, since actually everything is moving pixel-wise. This must be the color-interpolation magic my sprites miss now.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISprite: 1 pixel borders flicker when object is moved
« Reply #3 on: December 09, 2014, 01:39:11 PM »
You either get crispness of sticking to integers (pixels) like Agent_007 suggested, or you lose this crispness but gain smooth movement by using floats. There is no middle ground. This is how all graphics work.