I’m having a low FPS issue that affects only one portion of a scene. I’ve modified my game to sample FPS once a second and display it on the screen. For most parts of my game, FPS is acceptable. However, on one particular level, I’m seeing FPS 30, which is very low:
The game displays FPS(30) in the upper right. However, if I pan the level to another part of the scene, the FPS climbs to an acceptable 499 - 1500% better:
These are different portions of the same scene, in the same game, on the same PC (a reasonably beefy box with a good graphics card). The only difference between the top and bottom screenshots is the position of the camera. What could be causing this? What can I do to diagnose it?
Usually when you look in a certain direction and FPS gets worse, it can be that you are looking at the problem. Example: same prob in one of my scenes, every time i looked towards the north east (in one area) the FPS tanked, come to find out it was 3 models, one had bad mesh errors, and i forgot to LOD the other 2.
As mentioned, you should be checking the profiler, as you can narrow down a prob nicely by using it. But my gut feeling its something in the direction the camera is looking…
Your scene is composed by all those blocks, if those are independent gameobjects you will waste lots of time on rendering. Use static batch or even better combine all that geometry.
This has been very helpful, and I’ve found the problem. The base issue was that I was creating an irregularly shaped water area with multiple instances of Unity’s WaterProDaytime. This turns out to be very expensive, and manually optimizing the number of instances helped a lot. The Profiler (thanks arkano22!) and looking at what was in the camera’s view (thanks warthos3399!) was a great help in finding this.
I was also able to make further improvements by enabling dynamic batching (thanks marcoantap!) and now the FPS is over 100 throughout the scene.
I looked into static batching and I’m not sure I can use it. My game creates levels dynamically, and it’s not clear whether it’s possible to enable static batching after a level is created, and then entirely replace it when the player loads another level. I’ll continue to research this, as well as look into the possibility of combining the blocks, as also recommended by marcoantap.
But the original problem is now resolved. Thanks to all who replied.
Unity’s built in static batching won’t work for dynamic scenes. It is an edit-time construct. That bring said you can effectively do the same through a variety of means such as the above comment about combing meshes together at runtime or clever use of the newer graphics API tools for instancing. However, if you are hitting good framerates now and you don’t expect more to be added to your scenes then it’s probably not worth the hassle. On the other hand, if you expect to be generating far larger and more complex scene then I’d suggest testing that now because you don’t want to have to solve that problem late in your journey. It will need to be a part of your core design up front.