Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Tilemap Chunking - Already built in?

Discussion in '2D Experimental Preview' started by primitiveconcept, Jul 27, 2017.

  1. primitiveconcept

    primitiveconcept

    Joined:
    Feb 23, 2013
    Posts:
    8
    Hiya', hopefully this hasn't been asked before, as a quick search didn't turn up anything in the other forums.

    In the 2017.2 beta, I've been experimenting with a tilemap chunking system, and while researching possible approaches, I chanced upon a comment in the blog, where someone asked if tilemaps do any chunking/culling, and Johaness responded "Yes it does."
    https://blogs.unity3d.com/2016/06/13/2d-experimental-preview/#comment-330718

    I was curious if that's still currently the case, and if so, if perhaps someone could explain a few of the internals of how this is handled by the engine, best practices to ensure it's being done properly, etc?

    My initial approach was to keep a data structure containing tile ID's for subdivided sections of tilemaps (chunks), and then use a culling component to only place tiles in occupied chunks and a few adjacent chunks. Initially, I used a separate tilemap per chunk, then moved to using a single tilemap for all chunks, placing tiles in the relevant areas defined by chunk dimensions.

    After seeing that comment, I was wondering if there was any point to creating such a system, considering some form of chunking may already be built in to some extent.

    Any additional info would be greatly appreciated. Thanks!
     
  2. primitiveconcept

    primitiveconcept

    Joined:
    Feb 23, 2013
    Posts:
    8
    Ah, just turned on debug in the inspector, and found the chunking in the tilemap renderer. Well, that answers that question, at least with regard to culling on the rendering level.

    I am still curious about how the chunking is handled, though. Assuming tilemap renderer chunking only handles culling of tile rendering, would aliasing tile data with id's, and only loading in tiles for relevant chunks still be better for performance on really large maps, or does the chunking system already handle things in a similar way? That is, how much overhead remains per tile on the tiles not being rendered, and how are updates handled on the non-drawn tiles (if any)? I expect to have some pretty gigantic maps in future projects (not Terraria sized or anything, but still quite large), so I'd like to squeeze as much performance out of tilemaps early on before the maps get out of control.

    Thanks again!
     
  3. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    I know this thread is quite old. Since no one responded, did you ever find out more information about this? I need to know this exact information.
     
  4. primitiveconcept

    primitiveconcept

    Joined:
    Feb 23, 2013
    Posts:
    8
    I never did find an answer, but I'm pretty sure chunking only applies to render culling, meaning we'd need to implement our own chunking on the GameObject level to support really huge maps.
     
    CheekySparrow78 and JasonBricco like this.