Hello Guest

Author Topic: Sprites with jumpy and shifting pixels when moving  (Read 5167 times)

rludlam

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Sprites with jumpy and shifting pixels when moving
« on: March 03, 2016, 12:43:07 pm »
Hi all,
I'm very new to 2dToolKit and while I've enjoyed getting to know it, I am frustrated that I can't seem to get my sprites to look right.  When moving, the pixels are always shifting / jumping, so in one frame a line that is 2px in width might look right, but be 4px in width when moved slightly to the left or right.  After extensive searching, I'm guessing that this is likely due to sub-pixel movement, but I haven't seen any indication as to the best way to deal with that when using 2dtoolkit.  Any help would be much appreciated!

For some further info:
 - all my sprites are set to use point filtering
 - I am using a TD2K camera set to 1px / meter (have tried other settings as well), orthographic
 - Camera override is set to "Pixel Perfect"
 - Have tried various native / preview resolutions without any apparent effect

I'm attaching 2 files that show the issue (using SMB2 sprites for testing).  One is taken from the editor, the other from the in-game shot.  You can clearly see the difference between them in the eyes of the character.

Ultroman

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Sprites with jumpy and shifting pixels when moving
« Reply #1 on: March 05, 2016, 05:51:26 pm »
Did you click this button on your sprite?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprites with jumpy and shifting pixels when moving
« Reply #2 on: March 07, 2016, 09:48:46 am »
This does look like a subpixel issue - however are you running at 1:1 to start with? If you're upscaling / downscaling the chances of this happening are way higher.

rludlam

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Sprites with jumpy and shifting pixels when moving
« Reply #3 on: March 07, 2016, 01:23:07 pm »
Hi guys, thanks for the responses.  @Ultroman: yes, I've clicked 1:1, and the sprites look good in the editor.  The issue is really only apparent in the game window. 

@unikronsoftware : what is the recommendation for handling subpixel issues like this with 2dtoolkit?  Do you have an example of how this might be handled in script when sprites are moving using float values?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprites with jumpy and shifting pixels when moving
« Reply #4 on: March 09, 2016, 11:23:39 am »
For subpixel issues in the past we've just had the positioning script separate to the graphics script. Its a bit of a pain but gives you full control over subpixel positioning. Another thing we've done is to have the sprite as a child of the main control script and snap to pixel every frame, likewise with the camera - we've only ever had to do this once ever, most of our clients didn't really care about it.

rludlam

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Sprites with jumpy and shifting pixels when moving
« Reply #5 on: March 14, 2016, 05:44:26 pm »
Ok, thanks -- any chance you could share the code that performs this kind of snapping? It's hard to believe that it's not asked for more often as it does create pretty ugly rendering of pixel images.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprites with jumpy and shifting pixels when moving
« Reply #6 on: March 14, 2016, 11:14:50 pm »
I'll take a look - please drop me an email at support just so it doesn't get forgotten.