When we first time dragged the new models we now have to the scene, we had huge issues with them. The scene you have seen the most used to have FPS of glorious 15 frames per second, all the time. This very same thing happened with old models as well, that we had in past. If you have been following the game more than a year, you know what models i'm talking about. Eventually, we thought that the scene & models are just too much for today's PC's OR Unity engine just cant cope with them well enough, when we checked the Statistics though.. Well, we figured out what was going on.
In the Statistics, we can see few things. First of, the "Tris" amount is 1.5 Million just looking at that direction in image. We also have 1006 "Shadow Casters", so that's also a lot. The "Tris" value is because of the models, which are high poly from start, the shadow casters are from lights and the objects that cast shadows.
Now, first thing we did was to change the rendering pipeline. We got custom Shadows shader, that which looked better and also is perfomance wise better. (The links for the asset is in the end of this blog.)
We went from Forward Shading -> Deferred Shading, and as for Color Space, Gamma -> Linear. Doing this already boosted up the FPS of the scene to new heights, as Deferred Shading is generally better for scenes that has lot's of light sources. As for Color Space, the colors simply look better & more realistic with Linear.
Next thing is Shaders. We don't use the Standard Shader that Unity has, but a boosted up version of it called "Uber". Now as for perfomance, we dont really know how much this shader affects it. Not much probably, but we get nicer looking graphics & textures.
And now comes the LOD, Level of Detail. Every single mesh in scene has LOD.
In every mesh, there are four LOD levels. Each LOD level has ideally an model that has less detail, and plus for that we also made the texture resolution go lower the further you are away from the model. When you are for example standing right next to one, the resolution of the Texture is usually 4096x4096. But say you are about 4 meters away from it, the resolution goes as down to 256x256. Now what makes LOD System great is the fact that you barely see it functioning in background, but the FPS it saves made the said scene run over 60 fps at all times, so this was the final nail to the optimization part. Apart from previous optimization, we also have the basics Static Batching, and Occlusion Culling in the background. The Lights & Reflection Probes of the scene are also set as Static, and set in "Baked" mode, to keep things running fluid.
After we got the Optimization done, we went on to create the look the scene has in images today. That said scene runs perfectly now, always over 60 FPS and also manages to look glorious. Optimization is key, that is something you cant forget.
So that's it for the blog this time. Hope you enjoyed reading this, even a little :)
Here's the link for the custom Shadows Shader.