Search Unity

Implementing HLOD without GameObject conversion

Discussion in 'Entity Component System' started by charleshendry, Jul 12, 2019.

  1. charleshendry

    charleshendry

    Joined:
    Jan 7, 2018
    Posts:
    97
    Hi,

    I have some questions related to ECS rendering of a large static world. I'd like to implement a similar system to the HLOD and culling in the MegaCity demo.

    I guess the main difference is that I don't have any existing GameObjects in the scene that will be converted to Entities. I have several mesh "components" that are grouped together in C#. These mesh groups are then grouped again, building up a hierarchy. These use MeshLODComponent and also MeshLODGroupComponent where needed. For some groups I will likely be combining low LOD meshes to improve performance.

    So without adding any system to this, I get very high CPU load (40ms) whereas GPU is ok. So as I understand it, the rendering system is checking every single entity to see if it can be culled based on its WorldRenderBounds (or maybe each chunk with ChunkWorldRenderBounds).

    Anyway, I need something like the method used in OnBeforeCull within the HLOD script, which iterates through the LOD hierarchy and works out if the LOD should be changed and uses LODGroup.ForceLOD() to switch them and many groups will be set to last LOD which is often set to be culled. So as I understand it, there are lots of entities that the renderer then doesn't have to iterate through.

    So my question is: Is there something similar to the ForceLOD method that is being used in the MonoBehaviour HLOD script that can be used in ECS with the MeshLODGroupComponents? Presumably not, otherwise MegaCity would have used that approach? Does anyone have any advice on how this could be achieved without having GameObjects with LODGroups attached?

    Many thanks.