Hello Guest

Author Topic: Black lines and tiled sprites - again...  (Read 10320 times)

dbanfield

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Black lines and tiled sprites - again...
« on: August 14, 2013, 08:52:20 am »
Hi there!

I'm having trouble with black lines inbetween tiled sprites.

I've searched the form for "black lines" and noticed this is not something new ;) I've read every entry and taken advice, but still got nowhere.

  • Pad method set to "extend"
  • I'm using orthographic camera to test (although I first noticed this in my perspective camera game)
  • mip mapping is off
  • I've tried a padding of 1 and 2 pixels
  • All sprites are 1:1
  • bilinear filtering (although with point filtering I noticed the same)
  • Unity 4.1.f1
  • tk2d 2.1 + hot fix

My test project just creates a 64x64 yellow square as a flattened PNG in fireworks (72 pixels per inch resolution, attached), puts this one sprite into a collection, and then I create a load of sprites on the stage using the snapping tool.

I lay them out in a long horizontal line, around 5 sprites high and then pan the camera along the sprites in game mode. It basically manifests the same as this
http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1237.msg5895.html#msg5895
although the lines may not necessarily be the full height of the sprites.


Any ideas? Please help! This is driving me nuts  :'(

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #1 on: August 14, 2013, 11:44:30 am »
What platform are you testing on, and do you have MSAA turned on?

dbanfield

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #2 on: August 14, 2013, 09:57:58 pm »
I'm on Windows 7. Also deployed to android Nexus s (with my original project, not the test project).

Antialiasing is turned off in the quality settings inspector.

dbanfield

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #3 on: August 14, 2013, 10:05:47 pm »
aha! I just disabled shadows in the quality settings and things look okay now.

Does everyone have to do this? I haven't seen it mentioned in any other threads...

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #4 on: August 14, 2013, 10:10:22 pm »
Do you have any lights in the scene?

dbanfield

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #5 on: August 14, 2013, 10:14:07 pm »
 :'(
sorry false alarm.
I'm still getting the issue even with shadows turned off (and now anistropic  filtering turned off also).

FYI I did have a light in my game seen, but have removed that now.

The test scene that still had the issue (with the yellow square) does not have a light.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #6 on: August 14, 2013, 11:21:08 pm »
Can you set up a repro case for me to look at? I'm at a loss as to what to suggest.

dbanfield

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #7 on: August 14, 2013, 11:50:56 pm »
Sure, here is the test with the yellow square that recreates the problem. I've just zipped up the project directory. Not sure if there is a better way to share a unity project...

Thanks for having a look
« Last Edit: August 20, 2013, 06:27:14 pm by unikronsoftware »

dbanfield

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #8 on: August 20, 2013, 06:10:07 pm »
Any luck with this? I don't want to be wasting your time with a problem that's only recreatable locally, but the thing is, even deploying to my phone the problem occurs.

I should probably mention, with the project above use the left and right arrows to move the camera. Sometimes the problem doesn't occur for 4 or 5 flybys of the sprites. But sooner or later, sure enough I see the unsightly black line in between 2 columns of sprites. Interestingly, nothing ever happens horizontally.

Btw, just upgraded to Unity 4.2 and no change.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #9 on: August 20, 2013, 06:50:24 pm »
Apologies - I downloaded the file before and totally forgot about it!

I managed to see a flicker once or twice. The good news is it looks very much like a vertex alignment problem, where at a certain position one of the vertices is being snapped to different pixels. Basically there is a gap in your grid, which is visible when the camera is at a particular sub-pixel position.

Eg. Set the camera position to X: 272.99825
You see it permanently in game view.

If you select that sprite and keep zooming in all the way (set scene view to back and ortho mode), you'll eventually see a gap. That is the cause of the issue. If you select that sprite, use vertex snap mode in Unity to snap it to the one next to it the gap goes away... So fix the gaps and you fix the problem :)

dbanfield

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #10 on: August 20, 2013, 08:45:51 pm »
Hey!
Thanks for getting back to me  :)

That's great to at least know where the problem lies. No wonder all that fiddling with the tk2d settings wasn't changing anything  ::)

Strange though, I was using vertex snapping for every sprite placement, and would have expected everything to be aligned perfectly.

Perhaps a bug in unity?

Maybe one thing putting it off was "doubling up" the sprites when building up the blocks. i.e. place one sprite, duplicate it, vertex snap duplicate next to original, select both, duplicate, vertex snap the 2 next to the first 2, select the four, duplicate, vertex snap etc etc.

Anyway, will experiment. Thanks for the insight!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Black lines and tiled sprites - again...
« Reply #11 on: August 21, 2013, 11:25:11 am »
Quite possibly the doubling up. That is more likely to accumulated floating point errors, which is why you only see it further on.