Hello Guest

Author Topic: tilemap partition size  (Read 7563 times)

gabriel_ca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
tilemap partition size
« on: August 05, 2012, 11:23:38 pm »
I'm trying to figure out what this means exactly.  I thought it was the size of the tiles but that doesn't seem to be the case.  I figured if I got the width of the tilemap (which does seem to be in tile units) and multiplied it by partitionSizeX I'd get the width of the entire map in pixels (which is the unit I'm using for worldspace coords).  This doesn't seem to be the case.  My tiles in my little test program for exploring 2D toolkit are 64x64, but the partition sizes are 32x32.  If I try and change the partitionSize to 64x64 in the editor it just goes back to 32 (I checked the code and it looks like it definitely clamps it to the magic number 32).  Just wondering what it's supposed mean and what it's used for.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tilemap partition size
« Reply #1 on: August 06, 2012, 08:17:56 am »
Lets say your whole tilemap is 256x256. Creating the whole tilemap as one mesh would be very impractical and even if possible in Unity (it isn't, due to the 16bit index limit), it would be incredibly slow to render. What the partitionSize does is it splits the tilemap into smaller mesh chunks. So, a partition size of 32x32, will split up the tilemap into (256/32 = 8)x8 chunks. The 8x8 chunks will get rendered a lot more efficiently, as each chunk is about the right size for the GPU, and doesn't have ridiculous amounts of polygons in it.

So thats it really. It partitions the "world" into AxB sized chunks. In most cases, you shouldn't have to care about it.

gabriel_ca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: tilemap partition size
« Reply #2 on: August 06, 2012, 05:13:55 pm »
I see.  That makes sense.

So if your tilemap is smaller (like say 32x24) would a smaller partition size be more efficient or would it not really matter?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tilemap partition size
« Reply #3 on: August 06, 2012, 06:20:51 pm »
The default value (32x32) works really well in most cases, and produces 2k tris if fully occupied. Splitting that further could help, but would increase draw calls.
Whether on not that translates to a net win or loss depends on the tile size, how many are visible at a time, etc. Thankfully, you can experiment with this after you've built your game.

I say just keep it at 32x32 for now. If your tilemap is smaller, it will only create one at that size anyway. The partitionsize only kicks in when the tilemap exceeds that size. There is no overhead to having a smaller tilemap size to the partition size.

gabriel_ca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: tilemap partition size
« Reply #4 on: August 06, 2012, 07:37:24 pm »
Great :)  Thanks for the insight.  Something for the docs perhaps? (didn't see anything on this other than the bare bones interface in the script reference)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tilemap partition size
« Reply #5 on: August 06, 2012, 08:12:50 pm »
Absolutely. I keep putting off writing more detailed docs as I keep telling myself I need to rewrite the parts of the interface I dislike... I'll sort it out after 1.80