2

I am attempting to render 40,000 sprites: a grid of 200x200 with each grid node having a sprite renderer. All the way zoomed out I get about ~20 frames per second.

What would be the best way to optimize this? Eventually I want to have an even larger grid. The grid has to be changeable — I need to be able to change the ground/floor for that specific grid node.

Screen shot of me frames/grid

Vaillancourt
  • 16,325
  • 17
  • 55
  • 61
Timo
  • 23
  • 1
  • 5

3 Answers3

1

You will have to generate and manage your own tile grid mesh(es) by putting all your tile graphics into one large texture (atlas) and updating the UV coordinates in the generated meshes when those tiles have to change.

You'll want to split your map into smaller tilemap meshes to allow Unity to do Frustum Culling on groups of tiles while not having to process frustum culling over 40,000 objects.

For example, creating meshes of 50x50 tile subsections will reduce the number of objects Unity has to check for frustum culling down to 16 (4x4, * 50x50 = 200x200) instead of 40,000 individual objects.

Addendum: Unity team has been working on a TileMap feature for about 2 years now. If and when this becomes available in non-beta it may be a better solution than rolling your own. But as of today it is not available for production use.

Stephane Hockenhull
  • 11,962
  • 1
  • 25
  • 44
0

Modern graphics APIs allow you to use a technique called instanced rendering. This is the go-to technique when you want to render a lot of the same thing. You basically tell the GPU to render something x amount of times and use a shader to decide where and what to do with them.

You can access this in Unity too: https://docs.unity3d.com/Manual/GPUInstancing.html

Bálint
  • 14,887
  • 2
  • 34
  • 55
-1

Try setting it to a really low resolution and applying a lot of anti-aliasing on a recursive way, so having several layers of anti-aliasing concatenated. I usually do that when I do audio reactive visuals on limited CPU and graphics card power on my MacBook.

Vaillancourt
  • 16,325
  • 17
  • 55
  • 61