Hello Guest

Author Topic: Sprite distortion in pixel perfect setup  (Read 4610 times)

Trigve

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Sprite distortion in pixel perfect setup
« on: October 01, 2014, 08:34:00 am »
Hi,
I have a scene with tk2dCamera with PixelsToUnit set to 1 (It was set to 100 but I changed it to the 1 to rule out floating-point precision errors). I have 12 frame animation with sprites which are NPOT and the dimensions of the each sprite could vary. Each sprite has anchor point set. The camera position is aligned to the pixel. The GO with the sprite animator is aligned to the pixel. If I start player, the one exact frame in the middle of the animation, is always "distorted". That is, it looks like it was stretched 1 pixel right. I can PM you some demo project so you can try it for yourself. If I set the position of the GO of the sprite to sub-pixel value, i.e. 0.5, then distortion doesn't occurs. I also see this distortion on this exact frame in the tk2d animation editor when playing/stepping the animation.

Also when viewing this single sprite in the tk2d sprite editor (or in the image editor like gimp) it looks ok.

It looks like some sub-pixel error somewhere but could not find where it cam from.

Thank you

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite distortion in pixel perfect setup
« Reply #1 on: October 01, 2014, 11:18:33 am »
Are you on Windows, and is this in DX11 mode? Try DX9 mode to see if it goes away - theres a known issue in DX11 mode that should be fixed in the next beta / final version of 2.5

Edit: If it isn't that, send me an email with the repro case (support at unikronsoftware dot com) and I'll take a look.

Trigve

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Sprite distortion in pixel perfect setup
« Reply #2 on: October 01, 2014, 12:03:19 pm »
Hi,
thanks for the quick reply. Yes I'm on the windows. I have tested it (on the launch break in the work) and in DX9 mode it is not doing it (sprite distortion), BUT there is another problem - the sprite is cut on the last bottom line of the pixels (this wasn't happening in DX11 mode). The openGL mode is behaving as DX11 mode.

I'll post you the sample project after the work.

Thank you

Trigve

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Sprite distortion in pixel perfect setup
« Reply #3 on: October 01, 2014, 04:28:34 pm »
While trying to reproduce the described behaviour in the sample project, I've also updated the unity to 4.5.4 (from 4.5.3) and reimported the original project. After reimporting the project the issue is gone. So maybe there were some cached data that were doing something bad.

But the issue with DX9 I've described in the previous post (that the last line from the sprite is cut/anti-aliased(?)) still apply (it does also apply if I build the player, while in DX11 mode, and run the generated .exe).

I've sent you the project to the address you've provided.

Thank you

Trigve

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Sprite distortion in pixel perfect setup
« Reply #4 on: October 02, 2014, 08:24:37 am »
So I've been playing with it once more and found the in DX9 it's actually working fine IF the screen resolution is even (which is logical, because otherwise rounding errors could happen). Also I've noticed that even the editor was in DX9 mode, the player was generated in DX11 mode and the bug was persistent in the player. After setting the player to the !DX11 (DX9?) mode it is working also in the player.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite distortion in pixel perfect setup
« Reply #5 on: October 02, 2014, 11:12:40 am »
Yeah thats exepcted - there is an issue with DX11 (in editor and in player) mode. It should be fixed in the next 2.5 release.
« Last Edit: October 02, 2014, 11:22:31 am by unikronsoftware »