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

(Help Desparately Needed) Insane Amount of Batches on Large Environment Despite GPU Instancing

Discussion in 'World Building' started by TheBulldogTV, May 21, 2021.

  1. TheBulldogTV

    TheBulldogTV

    Joined:
    Feb 13, 2018
    Posts:
    9
    Me and my small team of developers are working on a game we would like to finance with a kickstarter campaign down the line. In order to have some good looking scenery for a trailer and maybe even show off some gameplay there, we spent a considerable amount of money to comission a map designer to build a level.

    However, upon delivery we noticed that the map has terrible performance ( 2-6 FPS depending on the view) and we don't really get any help from the map designer, since he supposedly gets decent performance using an RTX 2080 and claims the map was "not optimized for gameplay" and "to get high fidelity graphics for a trailer [this obscene amount of batches] is needed". I don't know a lot about graphics in unity, but still call BS on that - I don't see why excessive draw call overhead would give me nicer graphics.
    Here is a screenshot of how a part of the scene looks and the ludicrous amount of batches we have:
    upload_2021-5-21_23-5-39.png
    Now, I did some digging and found out that the largest part of the batches is caused by the main terrain, specifically by the trees placed on that terrain. Disabling the trees (and some bushes, grasses and rocks) knocks the batches down to a few thousand and gets us 70 FPS which we would be very happy with.
    I checked whether the SRP batcher is enabled (yes) whether GPU instancing is turned on for the materials used by the trees which is the case and also made sure a large proportion of the objects is marked as static - still, we never get even a single batch as "saved by batching".
    However, I noticed that turning OFF the SRP batcher in the HDRP asset settings does help a bit and enables some form of batching but still results in some 100,000+ batches.

    I should also inform you that the level designer used a bunch of high grade asset packages we did not own at the time - of course, without telling us despite the fact that i clearly instructed him to do so - so we had to bite the bullet and purchase them afterwards. These include:
    - Nature Renderer by Visual Design Cafe
    - Gaia 2 Terrain & Scene Generator by Procedural Worlds
    - Forest Environment by NatureManufacture
    - Meadow Environment by NatureManufacture
    - River Auto Material 2019 by NatureManufacture
    - MicroSplat Terrain Collection by Jason Booth

    We are quite desperate at this point and even after a few days of digging could not make any progress - we thought this would be a plug & play solution and we could simply port all the complex mechanics we designed in other projects into this scene and have a wonderful showcase; but now that we cannot get that scene to run properly, our entire project has come to a grinding halt.
    We would be immensely grateful if somebody could help us out with this issue.
     
  2. GanonM

    GanonM

    Joined:
    Nov 10, 2018
    Posts:
    10
    A few things pop to mind, although you'll need to investigate yourself to verify. Also, use the profiler to get empirical evidence of bottlenecks.

    - You mention they used Nature Renderer, presumably for grass/bushes. Have you correctly integrated this on your version of the environment? If not, It may be falling back to built in detail renderer which has significantly worse performance. You may also want to disable shadows for the details.
    - I notice there are 40k+ shadow casters according to the stats window. This seems absurdly high. Check your shadow cascade distances (and reduce them drastically). Check your shadow map sizes in quality settings (try lowering the resolution). IIRC there's a terrain setting to limit the number of shadow casting trees - try that. I'd maybe begin by disabling shadows altogether to verify if that is indeed the cause. You can consider using contact shadows as a cheaper alternative to distant 'real shadows'.
    - Are there any extremely expensive effects such as a realtime planar reflection probes? That will hammer your frame time.
    - If artistically feasible, you may want to ensure the highest (lowest quality) LOD for the trees is culled completely.

    Let me know if this helps.
     
  3. TheBulldogTV

    TheBulldogTV

    Joined:
    Feb 13, 2018
    Posts:
    9
    I made a few adjustments and managed to get some good performance boosts of about +400%, resulting in about 20 FPS. The main things that made a difference were:
    - reducing the resolution for the Punctual and Area Light Shadows by one step in the HDRP Quality Settings.
    - changing the "Cast Shadows" option on the main Terrain -> Basic Terrain Group from "Two Sided" to "On".
     
  4. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    594

    Other than the commissioning communication potentially being difficult or just the person hired doing a beginner job since their responses and excuses are pretty poor.

    Some of the things that you will really have to study is the environment setups mind.

    There is a lot to consider, but I highly advise really knuckling down on all the ins and outs and hold off your campaign first.

    GanonM covered a lot about too so I'm glad you've managed to make some saves.

    The rest would be look into the Vegetation Framework too.

    Like
    Trees that are static flagged in a dense forest cost an absurd amount of memory and might not be favourable in this instance.

    Nature renderer only affects grass details.
    Not rocks, trees or otherwise.
    (You will need to look at an additional Instancing solution to support the other kinds of detail and trees)

    Isolate your Objects too through scene checks and profiler to see their actual costs.


    3D Trees
    HDRP
    grass mesh over 600tris with alpha cutout
    Volumetric anisotropic fog
    Terrain with pixel error set to 1.
    Realtime reflection probes
    Shadows
    Raytracing

    These are just some of the biggest cost areas that each need some optimization solutions in place in your projects scope and scale.

    I hope this enables you to find more solutions.