Hello Guest

Author Topic: Using sprite collection on a big group of assets?  (Read 4865 times)

wintermute

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Using sprite collection on a big group of assets?
« on: December 09, 2013, 10:34:19 am »
Hi,

I'm making a game which is akin to a Visual Novel. It's a kinda interactive dialogue thing w/c shows character sprites talking to each other.
See this sample (taken from Little Busters!):


As you can see there are two character sprites displayed on screen. The catch is, I have a lot of character sprites w/c are actually pretty big (800x800 or bigger) and each character also has a sprite w/ a different emotion face. I currently have 28 characters with 5-8 emotion variations each, and each emotion variation is also a 800x800 image.

Now the dialogue part isn't hard coded, in fact it's in an XML script w/c dictates what text to display and what sprites to display (or change).

My question is: Would it be practical to use a sprite collection w/ multi atlas enabled? So that whenever I want to switch sprites, I simply change the spriteID of the current/prefab sprite.

Or should I make a sprite collection for each sprite (or maybe group them to fit 2048x2048)? Doing so would be very cumbersome when the game is running because I will need a code to find the sprite collection of any sprite I would want to display.

Do all the atlases on a sprite collection get loaded once you use even 1 sprite from 1 atlas from that collection?

I don't think draw call will be a problem here because at the moment I have less than 10 in any given time during gameplay.
« Last Edit: December 09, 2013, 10:37:27 am by wintermute »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Using sprite collection on a big group of assets?
« Reply #1 on: December 10, 2013, 02:47:38 pm »
Multi atlas will work, but it will eventually break while generating the atlas when Unity runs out of memory. Unity is 32 bit, and loading an image in the editor has significant overhead. Its worth a go, but be prepared to create a more complicated solution when/if you run out of mem.

0angelic0

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Using sprite collection on a big group of assets?
« Reply #2 on: March 04, 2014, 05:43:15 am »
Hello,

Please answer the question that wintermute asked.

1. Do all the atlases on a sprite collection get loaded once you use even 1 sprite from 1 atlas from that collection?

And I also have some questions too.

2. How 2D Toolkit and/or Unity use memory for textures? I'm very confusing now. I have 20 character images that build into a sprite collection and experiment 4 cases: *Noted that my scene without a character use 50MB*
case 1. Uses multiple atlases with max size 1024 this generate 7 atlas images, when one character is display via tk2dSprite the VRAM usage is 77.6MB.
case 2. Uses multiple atlases with max size 2048 this generate 2 atlas images, when one character is display via tk2dSprite the VRAM usage is 89.2MB.
case 3. Uses sprite dicing and max size 2048 this generate 1 atlas image (2D toolkit seems limited to 1 atlas when use sprite dicing), when one character is display via tk2dSprite the VRAM usage is 89.2MB.
case 4. Uses max size 4096 this generate 1 atlas image, when one character is display via tk2dSprite the VRAM usage is 105.6MB.

This seems number of atlas images per a sprite collection doesn't affect the memory use (case 2. and case 3.) and low size atlas with several atlas images is better than high size atlas with just one atlas image.

Am I correct?

Thanks

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Using sprite collection on a big group of assets?
« Reply #3 on: March 04, 2014, 11:34:18 am »
1. Yes.
2. The size of the atlas is pretty much fixed in memory. 1024x1024 = 4MB. 2048x2048 = 16MB. 4096x4096 = 64MB without mipmaps. VRam usage counter in Unity is close to meaningless as it has a whole bunch of other things loaded. Click on the atlas texture to see the size. The number of atlases DOES affect use, but on PC the texture is only uploaded to vram when first used as far as I remember.