Search Unity

Optimize Draw with Simpler meshes and tagging

Discussion in 'General Graphics' started by The_Nerd_Sherpa, May 30, 2019.

  1. The_Nerd_Sherpa

    The_Nerd_Sherpa

    Joined:
    Dec 11, 2018
    Posts:
    57
    I haven't been able to find a specific answer to this, so I'm hoping that someone here will have some insight.

    I'm going to use a simple cube shaped room as an example.

    If I tag a single mesh cube as a culling candidate, and I'm looking inside the room from the hallway, I can only see the wall to my right, the floor, and the ceiling. But the engine still has to draw the entire room because its one mesh?

    Instead of a single mesh cube to create the room, all four walls, the floor, and ceiling are separate meshes but using a single UV map (All combined into a single Prefab) so the engine will only draw the area of the room that is in view?
     
  2. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    375
    Possibly.

    Batching might merge everything. You should use the Frame Debugger to look at what draws are submitted when and why to understand your test cases.
     
  3. The_Nerd_Sherpa

    The_Nerd_Sherpa

    Joined:
    Dec 11, 2018
    Posts:
    57
    Thanks for the tip, I'll give that a try.

    By "Batching" do you mean combining all of my UV's into a single image? I don't think it will merge the objects. I've read that its a common optimization trick so multiple images don't need to be loaded into memory. The example the article used was Minecrafts texture map.

    I guess what I'm trying to figure out is what method was used by Unity to create Megacity? How do you pack that many objects into a scene without slowing it down to a crawl? If I want to build a city and have interiors for every building, My thought is I'll need to cull as much as I can.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    There's a bunch of talks Unity has where they go into this.

    Part of the answer is DOTS and ECS, their new data oriented programming systems which are much more efficient at handing large numbers of objects.

    Part of the answer is heavy reliance on custom culling, lod, and streaming systems.

    Part of the answer is modern GPUs are crazy fast, and a lot of the bottleneck in rendering a lot of geomerty is on the CPU side rather than the GPU. So smart/heavy use of instancing and optimized multi threaded rendering can get around that.
     
  5. The_Nerd_Sherpa

    The_Nerd_Sherpa

    Joined:
    Dec 11, 2018
    Posts:
    57
    Thanks for the info. I have watched a few of the videos on DOTS/ECS/Jobs and they're all high-level overviews. They basically go about as deep as you did into these systems.

    [QUOTE="Part of the answer is heavy reliance on custom culling, lod, and streaming systems./QUOTE]

    This is the aspect that I'm trying to understand. How granular is the culling?
    How do you setup streaming objects in a scene (is it a built-in functionality in Unity, or does it have to be done in code)?
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352