- Home /
256x256 sprites grid render optimization
I'm learning Unity and as a part of learning process I implemented Conway's Game of Life. It works fine and I'm able to render and simulate grids of cells up to 256x256, but that's where I hit performance issue.
I generate 256x256 (65000+) GameObjects, each has SpriteRenderer with a sprite that changes color based on the cell state. I use 1x1px png as a sprite image. It gives me ~17 FPS even when simulation is paused. I don't think number of GameObjects is the problem because if I remove SpriteRenderer component from GameObjects it gives me 100+ FPS while simulation is running.
I used profiler and rendering 1 frame takes about 60ms of CPU time. At the same time, since I use same sprite for every GameObject, Unity uses dynamic batching for sprites, so I have "saved by batching: 65543". There are only 17 draw calls per frame, which doesn't sound high.
If draw calls are so low and sprites rendering is optimized, why rendering takes so long? Can sprite rendering be optimized further or it's just not a realistic expectation to have 65000+ (same) sprites in the scene with good performance?
Answer by ShadyProductions · Jun 18, 2020 at 07:11 AM
Why don't you just use unity's Tilemap system, it is made for what you are trying to do and it is optimized. https://docs.unity3d.com/Manual/class-Tilemap.html
Thanks, I implemented it with Tilemap and now can run same grid with 100 FPS!
Your answer

Follow this Question
Related Questions
What Resolution to draw sprites for Mobile game?? 1 Answer
Keeping track of which areas remain unexplored 1 Answer
Instantiate vs CreatePrimitive 1 Answer
2d sprite Memory Issue. 1 Answer