Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - siroosec

Pages: [1]
1
Support / Region on texture that sprite is extracted from.
« on: January 13, 2014, 10:40:36 am »
Hi!

I'm trying to write a shader based on normal sprite shader, but with addition of another texture to use its alpha to cut out the sprite.
I think it would be quite easy if we know where on texture has the sprite been extracted from. Using a simple math formula in shader, we can calculate uvs on alpha texture using uvs on main texture. But I have 2 questions :

a) Do all sprites have a rectangular extract region on atlas? If not, is there any easy way to get some equivalent?
b) How can I get that region in my sprite class? Since I don't want to keep a reference to collectionData in sprite just to pass its region to the shader.

2
Hi!
I recently started using 2D Toolkit, and before anything else, I must say it's awesome! Thanks a lot!  :)

Currently I'm working on a card game, and I came across few issues.
The game is intended for retina iPad has 400 cards. So lots of 2048x2048 atlases will be used for them, and I'm almost certain current devices can't handle that easily and that's just our cards! Since we will have 40 cards in scene which can be of any combination, many atlases may be loaded in ram and vram only for 1 or 2 cards so huge amount of memory will be wasted that just isn't acceptable.

We initially thought we have to use planes for them and load card texture with Resources.Load(). But then we saw tk2dSpriteCollectionData.CreateFromTexture and tk2dBaseSprite.CreateFromTexture< T >. So here are my questions.

1. Is there any way to use 2D Toolkit's atlas generation in runtime? And will it have same performance as collections created in editor?
I think we could salvage the code used in editor atlas generator but that would be a last resort. It's kind of over the edge even as a last resort.
(If yes, I also like to know can I make it async or do it partially in coroutines so I can have a loading screen?)

2. If no, does a sprite have any overhead? I mean which one has better performance? A sprite created by tk2dBaseSprite.CreateFromTexture< T > or simple plane?
(Since we are going to have 40 cards and each one has a separate texture.)

3. If sprite is still better, is using tk2dBaseSprite.CreateFromTexture< T > code to create a method that replaces current sprite component with a new one instead of creating a new GameObject ok? Or it may cause problems?

Pages: [1]