Search Unity

Noob Question, how can I fix my game's performance issues?

Discussion in 'General Graphics' started by ChillPalace, May 25, 2021.

  1. ChillPalace

    ChillPalace

    Joined:
    Jun 19, 2020
    Posts:
    7
    Hey all, I'm a bit new to Unity, and I'm trying to fix an issue that's cropped up with my game's performance.

    I have a worldspace that I'm currently working on, and I've been using this grass asset to make it look stylized and nice- https://assetstore.unity.com/packages/3d/vegetation/plants/stylized-grass-wind-194396

    I used Prefab Brush to copy and paste a selection of grass prefabs (about 5 variations) across the terrain. At first it was going really well, but now that I've covered the entire terrain, Unity is having trouble processing all the grass.

    It's gotten to the point to where I can barely move in the editor without turning it into a slideshow, and if I try to delete a game object I get slapped with an infinite loading screen.

    Naturally this is getting in the way of continuing work on the project, so I started looking into solutions to make the game perform better. I've already made every grass prefab static, and while that helped some I still get the infinite loading screen when trying to remove objects, and a low framerate in denser parts of the terrain.

    What are some ways I can go about fixing this?

    (Not sure if it's useful in this situation, but I do have Microsplat and Aura).
     
  2. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,876
  3. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,755
    Ok, first of all, you havent provided enough information for us to clearly help (screenshots, video, unity version, etc.) of said problem. So with the little info you did give, heres a few things i hear and notice.

    Stylized Grass + Wind: is URP only, and even if your using URP, notice that theres 0 reviews for that asset. You need to investigate better assets that have better performance. Also if you are trying to use a high density of grass, (per patch) thats going to cost you on the performance side.

    AURA, a great asset, but again a resource hog. IMHO can only be used in a workflow that has alot of FPS/MS overhead.

    Note that this problem ONLY occured, after you completed the grass. The grass you use, the density count, and optimization dictates alot. Honestly, you are using 2 resource hogging assets, no good can come from that...
     
  4. StephanieSy

    StephanieSy

    Joined:
    May 5, 2021
    Posts:
    3
    Have you tried using the veryfast preset on OBS? Going to slower encoding speeds is really taxing on the CPU.
     
  5. ChillPalace

    ChillPalace

    Joined:
    Jun 19, 2020
    Posts:
    7
    Sorry if this is a dumb question, but what is the OBS?
     
  6. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    I love optimizing performance. Checking the profiler, frankly -- I do it more often than actual game development.
    First, you should open up the profiler and learn how to use it. It's extremely simple -- a few minutes of reading and messing around with it is literally enough to know to get most of the info you need.

    2. For grass, you have multiple choices, the two I like are:

    - Mesh combining, you can do this manually or use a package. You can find one in github, basic mesh combiner. A much better one is Mesh Combine Studio. It combines meshes into cells, so you still get LODS & Culling perf gains which is huge. Although, if your grass has wind -- if it depends on manipulating pivots, wind will be messed up.

    2. Use Indirect instancing: BIG performance gains are next to guaranteed for grass. It's best for small things that are very dense, and grass is exactly that. You can do this manually or use something like Vegetation Studio or GPU-instancer, both are paid assets. A Bit annoying to do manually if you're a beginner.

    If you use Vegetation Studio, you'll have to make very simple additions to the grass shader to support instanced Indirect, you can easily do this manually or use another asset called Vegetation Shaders (one of the BEST assets for vegetation, ever) which will give all your vegetations a uniformal shader that will support Vegetation Studio Indirect instancing instantly, and a billion other features.


    In the end, there's a ton of other way to increase performance. Even when using instanced Indirect, you can push it even further if you cluster the grass into a few meshes combined, (which will break the wind if you use pivot), which reduces the load and drawcalls even more while adding more density.

    For example, look at this:


    running at 65 FPS in the editor, a build will be even better performance. Grass shadows disabled, FPS instantly jumps to 110. There's a ton of settings I can decrease for easy FPS gains, the video uses ultra-settings. I will soon test in build to see the difference. Using vegetation studio.
    It's also using Vegetation Engine shader, which is not light and has a ton of features. The grass in the gif has high quality wind, and visual wind that moves across all the grass.

    Using indirect instancing and without any grass clustering, so each piece of grass is a single mesh. All of this at 256 draw calls. (The majority of the draw calls are caused by the light). It's not straight-forward to bake light when using indirect instancing, but in VS I believe there's a way to do it. Will look into it eventually.


    NOTE: i'm using built-in/legacy pipeline, URP is even faster. But the assets might not be as well supported, depending on each asset.
     
    Last edited: May 26, 2021
    ChillPalace and warthos3399 like this.
  7. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    Also: placing grass as prefabs is actually my prefered way of doing things, BUT:
    once things get big, it slows the hell out of unity, and moving them to a folder or deleting them will start taking minutes if not much more. It becomes really messed up on a big scale. Using VSP/GPU-i details is better & faster editor + time to get in game on play.

    VSP/GPU also offer frustum culling out of the box automatically for your grass.
    Both have pros and cons, overall for serious project I prefer VSP. GPU is easier to get started with though and has a prefab converter so it's not just vegetation you can instance, it's any prefab. VSP has a lot more spawn features and an overall will handle all vegetation from spawning to rendering. Lacks LOD cross-fading, coming in next version though.

    Both use same instance Indirect API so speed shouldn't be too different.
     
    Last edited: May 26, 2021
    warthos3399 likes this.
  8. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,755
    +1 vote for VSP, best performance, and looks great...
     
  9. ChillPalace

    ChillPalace

    Joined:
    Jun 19, 2020
    Posts:
    7

    This is an incredibly concise answer! Thank you very much for taking the time! I'll go ahead and give your suggestions a try, and report back with how it goes.