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. Dismiss Notice

Any good resources for optimization strategies? (down to 30 fps, all in "rendering")

Discussion in '2D' started by Valynna, Mar 10, 2022.

  1. Valynna

    Valynna

    Joined:
    Apr 1, 2021
    Posts:
    39
    So I have this game I'm trying to optimize, but right now, with just this on the screen, it's freaking out.
    I have a bunch of hexagonal cells made up of 6 walls, with 3 line renderers on each (the inside, the white outline, and the black outline). Inside the cell, I have a bunch of squiggles on the ground, and some random plants scattered about. The squiggles and plants are both just sprites.

    Everything ran perfectly at 60 fps when I had a grid 1/4 this size (15x11) -- but switching to a larger grid at (30x21) I'm below 30 fps. I have a 3070 in my computer, and if mine can't run it, there will be problems elsewhere.

    As I start looking through the profiler, it's clear that I don't really understand what's happening, or what I might do to improve the situation.

    Can anyone give me a good idea of where to start? I know a little bit about the physics optimizations, but the rendering stuff is a mystery to me.

    upload_2022-3-10_8-9-30.png
    upload_2022-3-10_8-9-48.png
    upload_2022-3-10_8-9-14.png
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,533
    I'm not a rendering person but if you're going to show some profiler output for timing, by far the most important thing to actually show are the times which you've unfortunately cut-off in the image above.

    Those batch numbers look scary though. Looks like nothing is being batched.

    Maybe a tile-map might've been a better option here, not sure.
     
  3. Valynna

    Valynna

    Joined:
    Apr 1, 2021
    Posts:
    39
    -- Ah you're right! It seems like the times are like 26.xx ms, 19.xx ms, 19.xx ms 19.xx ms, 14.xx ms.

    If I can get them down below the double digits it might work! xD

    ... It's interesting. Static batching was the first thing I tried. I set all the objects which don't move in the scene (all of them right now), and made sure isStatic was turned on. I also went to make sure that static batching was turned on in the edit - project settings.

    I saw zero improvement / difference.
     
  4. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    put stuff on sprite atlas, use same material, same shader, no lighting
     
  5. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,467
    Fear your 30x21x3 Linerenderers are the issues (or is it actually 3 per wall, not per hexagon?!). That's just a lot and I bet it's not actually the GPU bottlenecking but the CPU. Try setting resolution to 720p - does that improve the FPS significantly?
    If not (vs 1080p), the CPU is the limit.

    Unfortunately this is tricky since I assume you want to keep this randomization of your cells.

    An idea comes to mind to eliminate the linerenderers:
    Generate every tile shape onto a render texture at game load and then turn that render texture into a sprite.
    To save memory and improve batching, you could limit the number of different cell shapes to 100 or so. Nobody will notice that it's not all 100% randomization.