Search Unity

Render & Sim World Approach

Discussion in 'Data Oriented Technology Stack' started by Shinyclef, May 6, 2019.

  1. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    Hello. I've decided to try separating simulation from rendering via multiple worlds. I have an idea on how it might work but wanted to get some feedback.

    I imagine that each sim entity I create would of course have no render components, they would have everything they need for the sim plus one component called, say, PresentationLink. PresentationLink would contain an int PrefabID, a reference to a render entity prefab that contains the render components plus some lerping components used to achieve the smooth 60fps look.

    As the camera moves, a simulation world system would be responsible for tagging 'visible' entities. These would have render world doppelgangers created with Entity references to their simulation world counterparts with some system or two keeping them in sync.

    The authoring workflow would typically involve sim world GameObjects and render world GameObjects.


    What do you think? Is this a good path? Have any advice or see any pitfalls?

    Thanks!
     
    Last edited: May 6, 2019
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    1,721
    This must be the 5th time I've seen this idea come up on the forums and I don't get why people think they need separate worlds for this?

    They already built default groups for this exact purpose.

    SimulationSystemGroup
    PresentationSystemGroup

    That run in separate phases (currently not their intended fixed vs update but should be changed back at some point once issue is resolved).
     
    Shinyclef and eizenhorn like this.
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,522
    Same things. Why this guys want this? It's unnecessary complication.
     
  4. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    I didn't realise unity was doing this already. I just remember seeing a unite talk about this possibility, looked at the entity debugger and figured all systems tick down in a row. Didn't see it mentioned in the manual either... perhaps I missed it.

    Well, that makes thing easier for sure. Cheers.
     
    Last edited: May 6, 2019
  5. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    Performance.
     
    siggigg likes this.
  6. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,522
    Which performance? It's not give you any performance with comparsion of current groups approach. Especially when they returns sim group to fixed timestamp.
     
  7. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    The premise of the original post was the separation of simulation and rendering with different tick rates on the assumption that the default world had one single tick rate, as the documentation states:
    - SimulationSystemGroup (updated at the end of the Update phase of the player loop)
    - PresentationSystemGroup (updated at the end of the PreLateUpdate phase of the player loop)

    Given this assumption, wanting the decoupling of rending and simulation means fewer simulation ticks can occur, while more render ticks can occur with smoothing. This allows many more entities to be processed in the simulation while still maintaining 60 FPS rendering.

    tertle has stated that what I am desiring is (or will be) handled by unity by default.
     
  8. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    1,721
    When they first introduced Simultation/Presentation groups they were implemented as

    However, due to issues they changed it in the next version

    As far as I'm aware, they still intend to revert this back at some point.

    You can read the discussion / reasoning here from the developer in charge of this : https://forum.unity.com/threads/why-is-simulation-the-default-system-group.639058/#post-4289911
     
    Shinyclef likes this.
  9. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,522
    If you had use forum search in this branch before post this, this topic would not even have arisen ;)
    https://forum.unity.com/threads/why-is-simulation-the-default-system-group.639058/#post-4289911
     
  10. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,522
  11. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    364
    Thank you for your responses tertle.
     
  12. siggigg

    siggigg

    Joined:
    Apr 11, 2018
    Posts:
    131
    I too see benefits in being able to run different system at different tick rates. For example for VR games you might run gameplay logic at 60Hz while rendering runs at 120Hz.

    This can be somewhat achieved by running all systems at the highest rates and simply skipping processing some frames (early exit) on lower tickrate systems. I've actually done that in the past to save perf, like only ticking some particle systems at half rate.
     
    Shinyclef likes this.
  13. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,522
    It's obvious, my point was:
    You not take peforance gains with other World (as OP described), in comparsion with different timestep in one World in different groups or with manual timestep manipulation. On the contrary, this is an unnecessary complication to synchronize the data necessary for rendering between worlds.
     
    siggigg likes this.
  14. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    333
    Just out of curiosity, what is the use of separate worlds now? I believe separating the simulation from the presentation was their original purpose.
     
  15. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,522
    For example you can create entities in other world with ExclusiveEntityTransaction without main thread block. It's how sub scenes streaming works in Megacity.
     
  16. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    333
    So it's used primarily now for streaming data in. Like procedurally generated content, right?
     
  17. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,522
    Not just procedural. Sub scenes prepared before.
     
  18. e199

    e199

    Joined:
    Mar 24, 2015
    Posts:
    98
    I used it to test both server and client at the same time inside editor