Search Unity

ECS ?

Discussion in 'General Discussion' started by InitusInteractive, Feb 11, 2020.

  1. InitusInteractive

    InitusInteractive

    Joined:
    Aug 16, 2018
    Posts:
    128
    Hi, I have a few thousand static environment objects in a scene (variation of 15 objects randomly distributed).

    They have colliders, LODs and the lighting has been baked.

    Someone mentioned I should look into ECS to see if I can get a performance improvement on this.

    Can ECS help in this particular case?

    If so, how can these objects maintain the baked lighting if they are dynamically instantiated via ECS at runtime?

    Is this even something I should be pursuing?

    thanks in advance
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,778
    Few thousand static objects and colliders, won't be an issue for classic OOP approach.

    Test it, profile it, bring results.
     
  3. kburkhart84

    kburkhart84

    Joined:
    Apr 28, 2012
    Posts:
    910
    I'm no expert, but Antypodish has a valid point, it isn't usually a good idea to pre-optimize.

    That said, I don't think you would be able to use baked lighting in this case, at least not for the objects you convert to ECS. But if these are static objects, it likely doesn't matter, especially if they are not running any code themselves.
     
  4. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    3,023
    ECS is great for when you have thousands of dynamic objects that need to move around at runtime. With static objects, ECS is not really needed. In fact, for static objects, you will probably be better off simply marking them as static.
     
  5. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    DOTS does enable a new technique one used by ECS sub scenes that can make scenes with tons of static stuff load really fast, but that entails fairly major refactoring, and for just a few thousand I'm thinking not at all worth it.

    Basically the approach is leverage native collections to save scene data via raw pointers to disk. So scene loading is load raw pointer data straight into ECS without any conversion/seralization needing to happen. It scales very well for huge scenes but a few thousand really isn't that much so the bang for buck likely just isn't there.