2D Toolkit Forum
2D Toolkit => Support => Topic started by: MetalGreg on May 20, 2012, 03:29:29 pm
-
Hello, 2D ToolKit is an awesome addon to Unity, great work !
I had some alpha transparency troubles at the bounds of some of my sprites, so i decided to go for a premultiplied alpha atlas, wich saves me a lot of time rather than playing with Photoshop export for hours.
It works great in 960*640, however i noticed that my sprites get blurry in 480*320.
It seem sprites need specific sprite positioning sometimes its depending on where they are on the screen, to not get blurry.
For example:
- My Sprite_A(1) at X200 Y200 is blurry.
- My Sprite_A(2) at X200.7f Y200.7f is ok.
- Somewhere else on the screen you could get the opposite result.
It also does the same inside and outside of the tk2d camera.
Do you know how i can prevent that to happen ?
-
Do you 1/2 the size of sprites in 480x320? (Using the resolution override thing?)
-
Yes, and i use to stay in the tk2dCamera.
[Resolution Overide]
Size: 1
Element 0
X: 480
Y: 320
Scale: 0.5
-
Updates:
- Sprite width and height are made of even numbers.
- Quality Setting is set to maximum and the result is the same, even when i build and run the game
- This result is actually the same with non premultiplied alpha textures
- I usually set my altla is set to [overide Standalone] -2048 -TrueColor to avoid artefacts
- Figured out that my sprites get blury when position.x or position.y are even numbers.
So in this case i shall use intergers odds numbers to position my sprites, to get them pixel perfect - This actually depend on the sprite size, but there is definitly something with positioning with evens and odds numbers
-
I just figured out my lake of logic on this little "problem" ; )
-
Sorry I must've missed your other posts to this thread. Glad you managed to figure it out.
The reason it has something to do with even / odd numbers is this:
When at full resolution, each full world position = 1 pixel, everything positioned on a round world unit draws correctly.
When at half resolution, each full world position = 0.5 pixel, so everything which is positioned on an odd number will be positioned at a 0.5 pixel boundary, i.e. will appear blurry.
-
Could you tell us more about Premultiplied Alpha atlas ?
What is it designed for ? When to use it ?
What would be the difference regarding performance on the iPhone?
-
Could you tell us more about Premultiplied Alpha atlas ?
What is it designed for ? When to use it ?
What would be the difference regarding performance on the iPhone?
Here is a good article about premultiplied alpha
http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx
One thing it conveniently works around is artefacts from upscaling badly alpha-ed images. The color channel in an alpha cutout image should be dilated, otherwise you white / black bleeding in, and premultipled alpha gets rid of a lot of these artefacts.
Anther bonus is the ability to do alpha blend + additive in the same draw call. 2D Toolkit lets you tag a sprite as being additive in the editor when premultiplied alpha is enabled.
The article doesn't go through the downsides to it - the main downside being reduced color precision in blended regions. In most cases, it really doesn't make any visible difference. It will if you have a lot of semi-transparent areas in your images, so take care when using it in that kind of scenario.
There is no performance difference on iPhone.