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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Performance of procedurally generated environments

Discussion in 'Graphics for ECS' started by Mockarutan, Jun 17, 2023.

  1. Mockarutan

    Mockarutan

    Joined:
    May 22, 2011
    Posts:
    158
    My world is completely generated in the loading screen. And I have not yet payed any attention to how different rendering entities are placing into chunks. I am pretty sure I've got a lot of entities in the same chunk that is not at all in proximity to each other on a map this is about 400x400 meters. There is about 225000 rendering entities with about 110 different materials. And it's HDRP, 2022.3, Entities 1.0.0-pre65 (Why I'm stuck on pre65 is a long story...)

    So two question someone might be able to shed some light on.
    1. Is this likely causing a significant performance cost? For example, there cannot possibly be any reasonable frustum culling done on a chunk basis, right? Is that something that is done and makes a performance difference in cases like this?

    2. In a normal scene with one or more sub scenes that is baked, like the primary case that Unity designed for, is there any sort of spatial fragmentation automatically done to help cluster rendering entities close to each other into the same chunks? And how does that work in that case? Any part of the baking code I should dive into?

    I'm not sure how much time I should spend on trying to cluster the entities that the generator spits out, maybe there close to no performance to squeeze out of this?

    Thanks in advance!
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,008
    1) This is rarely the bottleneck on the CPU side for rendering. If you got a profiler capture showing that it is a problem, I can maybe help you improve it. But otherwise don't worry about it.

    2) It does not do anything like this. One way I have seen people optimize is by using shared components for regions to help organize the entities. I don't know if it makes enough of a difference.
     
    Mockarutan likes this.
  3. Mockarutan

    Mockarutan

    Joined:
    May 22, 2011
    Posts:
    158
    Thanks for the answers! Here is a picture of the profiler when looking at a big part of the map:


    Do from this picture, any concerns?

    The shared component thing is exactly how I though I might reduce the problem. But I realized it can become complicated quite quickly with how big the clusters should be and so on.

    Edit, you can disregard the profiling screenshot. I realize there is probably nothing be figured out from a frame like that where I don't even know if there is a problem. I don't know why I posted it to be honest. I think you answered my questions! Maybe one day I'll try to some clustering of entities and se if there is any improvements.
     
    Last edited: Jun 18, 2023
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,008
    Culling is not the bottleneck in your project. Don't optimize for it until it is.
     
    Mockarutan likes this.