Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unique mesh per entity?

Discussion in 'Entity Component System' started by Hippohooman, May 14, 2020.

  1. Hippohooman

    Hippohooman

    Joined:
    May 10, 2020
    Posts:
    2
    I'm working on converting some code over to ECS and I had game objects that I want to port over, but whenever I add a Mesh to an entity, it seems to not work. I've looked on the forums for how to handle this, but it seems like most of the resources on here say to use instanced mesh rendering. I have my game objects editing their meshes at runtime so instancing meshes would ruin that.
    Any help or pointers to resources on how to add unique meshes to entities would be appreciated :D
     
  2. vildauget

    vildauget

    Joined:
    Mar 10, 2014
    Posts:
    120
  3. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    you'll be in for a tricky time when it comes to getting the best performance for what you're doing at large scales. the rendermesh component is a shared component which means entities with the same value for that component get put into the same chunks and entities with differing values get put into different chunks. so if you only have unity meshes, all your entities will be allocated in their own chunks. so that's 16kb allocated per entity with mostly empty space.

    ECS is fast because you can loop over many entities in the same chunk so you'll lose performance even in your non rendering related systems that have anything to do with those entities.

    At small scales this is fine but if you're aiming to reach 100,000 unique meshes you'll have a hard time.

    My tip would be to have two sets of entities, one set with just the meshes for rendering and a completely different set of entities with the additional data you want for those meshes. that way your loops over you data can still stay fast because all the data can stay in the same chunk while rendering chugs along at whatever pace it can manage.
     
    Antypodish likes this.