Hello Guest

Author Topic: sprite shimmering after upgrading from unity 4.7 to unity 2017  (Read 17741 times)

nachobeard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
sprite shimmering after upgrading from unity 4.7 to unity 2017
« on: September 05, 2017, 11:48:59 pm »
hello

I just spent a little while upgrading my project from unity 4.7 (using 2dtk 2.5.6) to unity 5 (using 2dtk 2.5.8.6).

so far the transition is going fine except that I get this weird shimmering pixels on sprites.

I've attached two GIFs where you can see what I mean.  in both GIFs the camera is locked to the main character, and the main character is moving vertically (shimering2.gif is just a zoomed-in version of the first).  It seems that having the camera locked to the main character and then having the main character move vertically makes it more noticeable.

the sprite doesn't have any weird scaling or anything like that.  it was literally working 100% ok in 2.5.6

any suggestions as to what might be causing this?

thanks.
« Last Edit: September 06, 2017, 12:32:49 am by nachobeard »

nachobeard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #1 on: September 06, 2017, 12:11:30 am »
I took a screenshot of the old project running on the old version and compared to the new one.

you'll need to open the image and zoom in a little but you can easily see that in the new project the feet are misaligned wrt the shadow and the platform (where the pink arrows are pointing).

as you can see in the old version everything aligned perfectly.

nachobeard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #2 on: September 06, 2017, 01:07:32 am »
and here's another comparison shot of what the screen output looks like with x1 zooming, before and after.
for this one you'll really need to download the image and zoom in in photoshop or whatever, you'll see there's something's going on with the main character sprite in the chin and feet (compare to the left, which is correct).  it seems to be skipping some rows and duplicating others.

there's also something going on with the platform buttons, an entire row of pixels has disappared and one of the other rows has been duplicated.

incidentally I should mention I'm the guy who you sent some code to fix pixel seams in between tiles.  it was a while back.
anyway adding these code modifications doesn't seem to have any effect.  thought I should mention it just in case.

regards.
« Last Edit: September 06, 2017, 01:09:47 am by nachobeard »

nachobeard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #3 on: September 07, 2017, 10:02:26 am »
hello again

seems this is something related to needHalfTexelOffset in line 664 of tk2dCamera.cs

Code: [Select]
// Only need the half texel offset on PC/D3D, when not running in d3d11 mode
bool isWebPlayer = false;
#if !UNITY_5_4_OR_NEWER
isWebPlayer = Application.platform == RuntimePlatform.WindowsWebPlayer;
#endif

bool needHalfTexelOffset = (Application.platform == RuntimePlatform.WindowsPlayer ||
isWebPlayer ||
Application.platform == RuntimePlatform.WindowsEditor);

it seems the texel offset is being applied on D3D9, which according to your own comment in the code it shouldn't be.
(switching to D3D11 gets rid of the shimmering)

could you do an official fix for this?

thanks

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #4 on: September 07, 2017, 12:47:58 pm »
Hi,

Sorry for the delay - I am waiting to get back to my office so I can test this on a windows computer. But yes, it should be testing if its in DX11 - I thought that change had already been made, but perhaps never got merged... I shall investigate.

nachobeard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #5 on: September 08, 2017, 12:04:51 am »
ok! glad I could help a little bit

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #6 on: September 10, 2017, 09:35:55 pm »
Hi,

I've been investigating this and I'm getting a bit confused. Old unity, in dx9 NEEDs the 0.5 texel offset. DX11 on the same version didn't. I am going to start digging up older versions to try to get to the bottom of this, so I can create an appropriate workaround that works on different versions.

Do you have a temporary fix for your current version now?

nachobeard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #7 on: September 13, 2017, 12:18:12 am »
Hi

I have a temporary fixed, but there are a few platforms and hw combinations I can't test, so an official fix would be welcome.

Thanks

nachobeard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #8 on: September 25, 2017, 11:24:47 am »
hello

is this still giving you trouble or did you manage to solve it?
thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #9 on: September 25, 2017, 11:36:40 pm »
Hi,

I have a solution thats more or less tested, but I am travelling until this weekend. I would very much like to run some final tests before releasing this, it could have huge repercussions to lots of people if I make any mistakes. Hopefully this weekend.

Apologies for the inconvenience.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #10 on: October 04, 2017, 11:51:51 pm »
Apologies for the delays but I have released an update with this issue fixed and tested with all the combinations of supported Unity versions (5.5+) and permutations. Let me know if it works for you

nachobeard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #11 on: November 11, 2017, 12:53:27 am »
ah, I missed this somehow, will test asap!
thanks for taking a look at it.

nachobeard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #12 on: November 22, 2017, 11:41:15 am »
hello,  I just updated to the new version of 2d toolkit, here are my findings.

I've tried running from the editor and also the windows standalone player (unity 2017.2.0f3).  here are the results:

-using d3d9: still get shimmering (if I just set halfTexel to 0 in the code, the shimmering goes away and it looks correct)
-using d3d11: no shimmering

it would seem d3d9 doesn't need the half texel offset, at least in my version of unity.
maybe old unity needs it like you were saying in a previous post.

do you think this issue might also appear in iOS? I can't check easily.

ty

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #13 on: November 24, 2017, 01:09:05 am »
Hi,

This won't be an issue in iOS as far as I am aware. Its a d3d9 issue to be specific.
Its weird that you can still see issues with the version submitted here, it was 100% reproducible on mine and behaved as I expected it (I had / still have a test case that demonstrates this).

I will look in 2017.2 and see what it does in there...

nachobeard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: sprite shimmering after upgrading from unity 4.7 to unity 2017
« Reply #14 on: January 14, 2018, 10:48:02 pm »
hello!

was this something you were able to look at in the new release?
I looked at the notes but couldn't tell.

many thanks