Search Unity

Resolved What to use instead of Tilemap for tile render

Discussion in 'Graphics for ECS' started by Klusimo, Jan 11, 2021.

  1. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
    Hi, its me again with another question. I asked not-so-long-ago if using default unity tilemap to render tiles with entities would be good, the answer I got was "try it if it will work its ok", but it didn´t, causing massive lag because I had to .Run() it on main thread, so here I am asking another question what to use instead of it?
     
    Last edited: Jan 11, 2021
  2. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
  3. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
    I took look at that, it is interesting. However.... "few" questions incoming...

    What are all the things it can do? How exactly does it work if you know? If I were to "instal it" how am I to do, especially with the resource folder, when I have my own, wont it cause problems to have 2 resource folders? (Resources.load) or should I merge them? Will it be actively updated? Given DOTS are in very active development etc.

    Just tell me as much as you can/want, I am the type of person who wants to know how it all works just in case:D (other suggestions, ideas etc. are still welcomed tho)
     
    Last edited: Jan 11, 2021
  4. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    This uses drawmeshinstancedindirect, you can look it up in the unity manual, works well with dots but also without. We don’t know enough about your use case and tile map functionality requirements
     
  5. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
    Well I have one entity for 1x1 tile of world, it has component that updates with noises to create specific "type" of tile that then proceeds to update its tile in tilemap, or at least that was my approach, but yeah, lag.
     
  6. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Not sure how this lags? How many tiles are visible on screen at once?

    2D? Tiles static or animated? Layered?
     
  7. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
    The problem isnt in the entities, but in the entities.foreach accesing every one of these entities and then based on its data placing tile and the tilemap tiles are:

    animated, 50 000 and I lowered the number.

    Yeah I think I can see now where the problem is...

    But there is bigger problem, I want there to be multiplayer, so with enough players there can be such extreme numbers. That of course is just speculation that that will happen, but still I want to be sure. Also I will lower the number of loaded world even more as now its just for testing, so there will be less tiles needed, but that is just per-player. So I seriously dont know what to do.
     
    Last edited: Jan 12, 2021
  8. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
    Sorry for such a late response. I'm not the creator of this tool. For more info, you'll need to read that thread of look into a git project. I've just tested it and I'm planning to use it in the future. It's fairly simple to use and fills the need for animated tile sprites do I've linked it.
     
  9. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    You can also check this thread - multiple solutions and discussion (basis for the other thread linked above). I have not been active in a year or so, but I recall that there were some API improvements providing a native ptr to compute buffer, which should allow eliminate the double buffer in memory and further speed up.

    https://forum.unity.com/threads/200k-dynamic-animated-sprites-at-80fps.695809/page-2#post-5024381

    I still don’t get why you have 50k tiles rendered at once.
     
  10. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
    Just 256x256 map has 65536 tiles. So it's easy.
     
  11. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    ;) I do not question the map size but how much is rendered on screen. OP can check if the links can be a solution...
     
  12. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
    Thanks so much for answers, I dont have time right now, but I will tests it ASAP and write the result here. :D
     
    Krajca likes this.
  13. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
    So I added it to my folder, but I am having hard time, because I am using much newer Unity version and I get errors like IJobForEach is obsolete etc. just bunch of old stuff conflicting with the new stuff.

    What to do? How do you fix these, do I have to try and fix every script?
     
    Last edited: Jan 14, 2021
  14. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    I am afraid so. It’s worth checking if any of the different solutions were maintained.

    If not, I used IJobChunk, which should not have changed much. You would have to update to system base...it’s somewhat involved.
     
  15. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
    So I tried fixing it and oh boy was that something. I ended up completely messing it up so I had to download it again and I dont think I have enough time and will-power to update it so for now I´ll try to make some sort of render distance where textures are rendered that is smaller than the actual loaded world.

    Still massive thanks if nothing I at least learned a lot more about dots so thanks.
     
    Krajca likes this.
  16. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    :(

    Let’s see, another relevant thread was necroed by coincidence and if I get a good answer there, I might download unity again and update this.
     
  17. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
  18. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
    I downloaded it and I get this unusual error: Assets\SpriteSheetRenderer\Scripts\SpriteSheetManager.cs(114,13): error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'

    As well as this warning:
    There are inconsistent line endings in the 'Assets/SpriteSheetRenderer/Components/MatrixBuffer.cs' script. Some are Mac OS X (UNIX) and some are Windows.
    This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.

    I´ll look at it and see what can I do, thanks for posting, didnt know there were forks of the original project.
     
  19. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
  20. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
    So yeah that somehow didnt work, still a great lesson though... I guess...
     
  21. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    @Klusimo So I downloaded Unity and will probably get 0.17 next weekend depending on the forum feedback.

    I still do not get your use case but if you still try to render 1000's of sprites for a tilemap, PM me and I can send you a simple demo (does not need ECS but lends itself to it, just needs a burst job to update data + drawmeshinstancedindirect)
     
  22. Klusimo

    Klusimo

    Joined:
    May 7, 2019
    Posts:
    76
    I ended up creating render distance, so I dont have to render everything at once so for now its ok.