Search Unity

How does 2d Tilemaps Rendermode work under the hood?

Discussion in '2D' started by brigas, Jun 3, 2020.

  1. brigas

    brigas

    Joined:
    Oct 4, 2014
    Posts:
    522
    Technically what is changing under the hood when the renderer mode is changed from chunk to individual?
     
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
  3. brigas

    brigas

    Joined:
    Oct 4, 2014
    Posts:
    522
    Thank you very much!

    I have a question only for the normal Tilemap Individual mode, and if this isn't possible maybe you could consider this as a feature for the future?

    I am sorting my tiles by custom axis Z, and using individual mode.

    By reading this documentation it seems that every tile is batched separate, but in my case I only needed tiles with different Z to be separate.

    Because of this its not as optimized as it could be because every tile is individually batched instead of only the z planes.

    So for all tiles that have the same Z ( are on the z=10 plane, for example (x,y, 10) ) all those tiles would batch in chunk mode.

    So it would be a new render mode: chunk by axis( choice:x, y or z)

    Please let me know if this is already how it works or if you would consider this as a feature for the future, thank you again!
     
  4. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511
    In similar vein, I've noticed that Individual Mode for isometric tilemaps performs worse than GameObjects with SpriteRenderers. The last time I tested was 2019.2. I think this is from not really culling though I'm not sure (batches exceed visible tiles). This doesn't really make sense to me: I would expect the opposite. @ChuanXin should we expect that this performance gap will disappear as new optimizations come in? Are there planned improvements for Individual mode in particular? Chunked works wonderfully by the way.
     
  5. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    This would be something that we would have to think about, as the main purpose of the Individual mode would be to allow other Renderers to sort against the Tiles. This would become rather tricky to handle and debug cases where sorting of Renderers do not go right.

    I am not certain how it works for your case, but naively, would it be possible to use different Tilemaps for each Z-plane (unless they are Isometric Z as Y grids)? Sharing some details and screenshots of your use-case would help us understand the problem, thanks!
     
    Lo-renzo and brigas like this.
  6. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Yes, we are looking into improving this. The issue right now is that culling for Individual mode still works on a Chunk basis, where in the worst case, only a few Tiles need only be rendered individually. We will try to solve this and change other areas as well to improve the performance for this.
     
    Lo-renzo and brigas like this.
  7. brigas

    brigas

    Joined:
    Oct 4, 2014
    Posts:
    522
    yes using 1 tilemap for each Z plane works indeed in my case! That is the effect that I was hoping could be reproduced in a new feature.

    Because, since I have a big world, and each chunk is (36,22,22), it means each chunk has 22 Z units which means 22 tilemaps per chunk, I need to have minimun 3x3x3 chunks loaded at the same time, so this comes to 594 tilemaps in chunk mode which cause unplayable framerate, so in my case I cant use that method.

    I still use instead 1 tilemap per chunk, so 27 tilemaps in individual mode.

    here is a screen shot of my setup
    Untitled.png
     
    Last edited: Jun 5, 2020
  8. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Thanks for the example! This seems like an interesting situation. We will look into this suggestion as well as improve the performance of the TilemapRenderer.
     
    brigas likes this.