Search Unity

Maximum size of a 2D only scene before performance it hurts performance

Discussion in '2D' started by NerdRageStudios, Aug 26, 2016.

  1. NerdRageStudios

    NerdRageStudios

    Joined:
    Nov 1, 2013
    Posts:
    167
    Hi all, I just wanted to throw out this question before I start on level design. My game is effectively one large map (a very large spaceship to be precise). I kind of figured that I could make one large scene as I am only using 32x32 2D sprites I should be able to get away with such a large scene as there would be very little geometry in memory, and Im only drawing what isnt being occluded.

    I am thinking that my max grid size will be around 600x600, which gives me the potential for a max of 360,000 tiles. Not all will be filled, probably less than 60% so I think 200,000 tiles is about right.

    Considering each tile is probably around 300 bytes in size, plus a 300 byte normal map, I can estimate that as around 120mb of texture memory, nothing special at all.

    I will also have a trigger radius around the player that turns on relevant monobehaviours on objects and enemies so that the whole game isnt running all the time.

    My questions to more experienced developers among you, are:

    1. Will I start to get performance issues in the editor when the map goes above a certain size?
    2. Will I get performance issues with one large scene? Should I use multiple additive sceness?

    I guess I base my assumption it will be ok, on the fact that I have seen large 3D scenes with hi res textures and complex geometry, and my 2D low res pixel game should consume sod all memory and resources... but its worth asking before I go too far!

    Apologies if its a dumb questions, but I just wanted to check!
     
  2. Pagi

    Pagi

    Joined:
    Dec 18, 2015
    Posts:
    132
    If your objects are aligned into grid, you can group them into chunks and display only those around player, or you can even combine the object into one big mesh.

    Generally the more objects and materials - the more drawcalls - the less performance. I had around 10,000 single gameobject tiles instantiated at once(not all on screen), they overlapped about by 1/4(creates overdraw - some pixels are unnecessarily rendered) and fps was still above 300fps. But if you plan on doing some dynamic shadows or other gpu demanding effects, the added performance of combining tiles into bigger meshes really helps.

    Are you building the scene in inspector? If yes, it will be hard to disable far objects without having them in some kind of array. Anyway for the start I recommend you to separate the map into chunks, and have instantiated only the chunks around player. I wouldn't recommend using multiple scenes as you have to constantly switch between them when editing, and you have to load and unload the ones around player anyway.
     
  3. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    You might get some slowdown if all the the object are separate game objects and if you zoom out enough that a large number of them are visible. I would look at some kind of mesh combiner script or something that can put groups of tiles into single meshes/chunks, which will then be much faster to cull. You'll have to try it to see if the thing slows down first.
     
  4. NerdRageStudios

    NerdRageStudios

    Joined:
    Nov 1, 2013
    Posts:
    167
    Thanks for the replies, apologies for delay in responding, i've been away. I am indeed building in the inspector using a custom editor I created for making tile based games. I guess, I can try mesh combining, but I'm not sure what effect that will have, but as I am using one sprite atlas, that could make a difference.

    I guess I am going to have to just try it and see what happens.
     
  5. dworm

    dworm

    Joined:
    Jun 17, 2015
    Posts:
    74
    if you just make a single mesh you have no problem at all, some aaa games mesh have much much more than millions of faces...

    the only problem you might have if you need to manipulate that mesh in real time but you can figure it out some way.
     
  6. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Breaking it up into multiple smaller meshes -but still having multiple sprites on each mesh, may work because because then if you need to update something you can just update the small mesh that is affected.