2D Toolkit Forum

2D Toolkit => Support => Topic started by: darvy on November 16, 2014, 08:11:23 am

Title: Runtime Atlasing using RenderTexture
Post by: darvy on November 16, 2014, 08:11:23 am
I am in the middle of implementing Runtime Atlasing through the RenderTexture method described in this thread ( http://2dtoolkit.com/forum/index.php?topic=4219.0 ). However, I am having trouble with the part where the sprites need to be packed into the view of a camera. Namely,

1) In what way should the sprites be rendered? Is it through Texture2D?
2) How do I pack the sprites into efficient positions?

I am sorry if these questions are obvious, but I have been stuck on this problem for quite a while and even implemented the feature through Texture2D.PackTextures, however its performance is simply not efficient enough for what I need.
Title: Re: Runtime Atlasing using RenderTexture
Post by: unikronsoftware on November 16, 2014, 11:49:46 pm
This method is completely out of scope for 2D Toolkit, but some info nonetheless -

1. You'll need to draw the sprites as quads, using GL.Begin / GL.End, or as runtime meshes (using runtime sprite collections on the source textures) with a second camera, etc.
2. You have the source to tk2d, you can get the algorithms tk2d uses to pack these textures. tk2dAtlasBuilder.cs and friends.
Title: Re: Runtime Atlasing using RenderTexture
Post by: darvy on November 17, 2014, 03:59:54 pm
Thank you very much for your help. Hopefully this feature will be added into tk2d soon ( it is already on the roadmap ). With all the games that include character customization out there, this feature would really put tk2d above other frameworks.