Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

What is better for fps - a lot of prefabs or one big level?

Discussion in 'Scripting' started by CTPEJIOK22, Jan 9, 2021.

  1. CTPEJIOK22

    CTPEJIOK22

    Joined:
    Sep 4, 2013
    Posts:
    85
    Good day, im working at racing project at unity and now optimising a game. Game running at psvita, also at nintendo switch, xbox one and pc. A made few optimizations - static meshes with one material (with atlases), skinned mesh with one material for cars, now game runs at 60-90 fps at ps vita with ~30 batches, i can optimize it more, but i have other question.

    Now i have a big level, its around 1000 similar prefabs and camera clipping, all works at stable fps. But im thinking - maybe its better to merge prefabs to one mesh at startup? Like did Mesh Combine Studio at other? Or, maybe, even did a big one scene? But how to work with culling? So, if anyone can explain this thing - it could be grat.

    And here is my preview build:
     
    Lars-Steenhoff likes this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    If you don't have a performance problem, you are wasting your time and damaging your codebase.

    There is only one place to answer this question: try it out and analyze with the Profiler, available from Window -> Analysis -> Profiler.

    Each platform is likely to give you a slightly-different answer.
     
    CTPEJIOK22 likes this.
  3. CTPEJIOK22

    CTPEJIOK22

    Joined:
    Sep 4, 2013
    Posts:
    85
    thanks. i dont have a problem at test level with simple prefabs. but im dreaming about semi-openworld game and trying to understand and find a better way.
     
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    1,996
    Those prefabs - you do have them marked as static ?
    This should do the trick.
     
  5. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    823
    I wouldn't worry about it so much. Create prefabs in a way that makes them easy to use for development.

    On a more direct note - One massive mesh isn't a good idea as there is no way for the renderer to cull at the per-object level and thus the whole thing would have to be processed all of the time. If you're looking to make a massive world you'll want to looking into some kind of data streaming for chunks of your world as the player comes near them. Even then you might want to deactivate or LoD certain objects that are beyond a visible distance but still close enough to be loaded in. All of this will rely on using smaller, more module sets of objects.

    Of course there is a tiny bit of overhead for each gameobject but I've personally used hundreds of thousands of them in some of my projects and never had any drastic issues.
     
    CTPEJIOK22 likes this.
  6. CTPEJIOK22

    CTPEJIOK22

    Joined:
    Sep 4, 2013
    Posts:
    85
    yes, ps vita can make only static batching, so, i marked all roads and object as static and i have not many dc.
     
  7. CTPEJIOK22

    CTPEJIOK22

    Joined:
    Sep 4, 2013
    Posts:
    85
    ok, thanks a lot, i understand, that i need to make a big part of level and try to test it. im making in right now via fbx exporter and seems, that at my lowpoly style there are no difference between big model and a lot of small. and about "data streaming" - can you suggest any tool? i seen free versions at assetstore, but maybe you name any good?
     
  8. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    823
    I can't say from experience all the tools that are available or what practices are recommended but I can think of two ways off the top of my head. The first would involve using Scenes and the LoadAsync scene API. The other possibility is to use your own custom file format to store scene-like lists of prefabs and where they belong and then load a few of these prefabs in at a time using a Coroutine so as not to completely block the game executing. I'd probably opt for the first option myself, esepcially now that we can work with multiple scenes in the editor at the same time so it would in theory be easy to line everything up between each seam.
     
    CTPEJIOK22 likes this.
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    AsyncAdditiveLoads FTW in my book.

    I imagine either making the scene chunks manually, or else making an editor tool to rip apart your single massive master scene and chop it into temporary scenes at build time, then keep a 2x2 or 3x3 grid of them going, whatever is appropriate.
     
    CTPEJIOK22 likes this.
  10. CTPEJIOK22

    CTPEJIOK22

    Joined:
    Sep 4, 2013
    Posts:
    85
    thanks a lot for the explanation, i will test it after few days. now im making big part of level - racing lap with decorations and then will try to merge them and load async.