Hello Guest

Author Topic: How to lose border around sprite?  (Read 13588 times)

GamezFactory

  • Newbie
  • *
  • Posts: 8
    • View Profile
How to lose border around sprite?
« on: May 25, 2012, 09:49:20 am »
Hey everybody!

First of all thank you guys for this awesome extension! It is really a great, great addition to Unity3D for those who target the 2d dev!
Keep up the awesome work :)

Here is my problem:

I am using a simple sprite from a semi-transparent .png file.
The png looks nice and with clean borders if viewed in photoshop, and even in Unity in your Sprite Collection window (check ps1.png)

However, after inserting in Unity scene the sprite has a very thin dark border around it and this is kind of not good for my scene :) check ps2.png
The sprite is that semi transparent rectangle and you can clearly see the thin border line around it. I use the 1:1 button since I need the pixel perfect thing.

I've also attached the source png directly from unity, it seems ok to me, no border in the png file.

Any workarounds / suggestions ? I am not skilled in importing and handling textures in Unity, so it could be something in my side :)

Thank you!
O.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to lose border around sprite?
« Reply #1 on: May 25, 2012, 11:51:31 am »
This looks like a bilinear interpolation artefact. One thing worth trying here is to enable premultiplied alpha.
1. Open up the sprite collection editor for this sprite collection, settings, and tick Premultiplied Alpha & commit.
2. Double click on the material in the settings tab to select it in the inspector, and switch material to tk2d/Premul...

Let me know if that doesn't fix it and we'll investigate it further

GamezFactory

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: How to lose border around sprite?
« Reply #2 on: May 25, 2012, 12:02:32 pm »
Yes! That worked just fine! Awesome and thank you!!


Another question if I may? :)
I've noticed that the sprites are not affected by any kind of lights? Is there any way to make this happen?

Thank you again for your great extension :)

O.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How to lose border around sprite?
« Reply #3 on: May 25, 2012, 12:13:39 pm »
If you'd like the sprites to be affected by light, simply switch to one of the tk2d/Lit... shaders. Keep in mind that the draw calls can easily go out of control with this, which is why its not enabled by default. It'll probably be fine on PC, but you'd have to take a lot more care on iOS/Android to keep draw calls sane.

Glad you like 2D Toolkit :)

GamezFactory

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: How to lose border around sprite?
« Reply #4 on: May 25, 2012, 02:39:22 pm »
Will try that! Thank you for your quick answers !!
Will keep you posted!