Week 7 - Optimisation
My project finally starting hitting the breaking point of optimisation. I had never made a unreal engine project this big before so i didn't know the limits of the engine and how far I could go before it started to drop below an FPS that was optimal.
This didn't mean i had no awareness that 200K tris for a building was abnormally large. I was aware through the teachings i've received what should be expected of polygon count but without breaking the system my self i would never have known how far i can go and how far i should be going.
The most taxing part of my project so far was not even the polygon count it was more the amount of alpha planes the engine was trying to compute. But i'll break it all more down in the proceeding paragraphs.
List of assets that have been optimised -
Temple 207k Tris -> 99k Tris
150K Grass Plane Foliage -> 56.7K
Blossom 10k Tris -> 6k Tris
20 Tree Foliage Instances -> 14 Tree Foliage Instances
Baked shadows off on Blossom Trees
Static shadows on all objects from half dynamic
Cull range from 0 -> 5K on all grass foliage
Environment change for linear movement to reduce polycount
The temple.
The temple was exceedingly large on the polygon count. The polygon count reduces performance because of the amount of individual faces the engine has to calculate how the light responds the the normals and smoothing groups being applied to the model. The temple is made of approximately 52 individual models, majority of them are duplicates and varied in someway meaning I could easily then unwrap them and attach to share the same UV space.
This allowed me to combine the entirety of the 52 models down into a mere 12 static mesh instances. Each of these static mesh instances is it's own draw call. This is optimisation for the future when I move on to texturing.
The cel-shader depending on how its coded in the blue print can either allow for outlines around smoothing groups (or, and) around the geometry of the building. So I tried to keep the integrity of the shape as much as I could when cutting the Tri count down. I won't to greatly in detail of what parts of the temple were more or less efficient than others but I will outline the ones that were great or the ones that were terrible.
The walls of my temple were by far the least efficient. This is simply because I'm now focusing on only the outside environment I didn't need double sided meshes to block light from penetrating the walls. Meaning I could model simple plane geometry in the shape similar to the original. Just cutting the shape of the walls down meant removing approximately 16000 Tris.
Each polygonal instance of the roofs were around 5000 Tris. I managed to cut each instance down to around 2500 which meant around Half my Tri count was obliterated. The fences were 16000 Tris which is so ridiculously large that I just deleted them instead of trying to find a work around. I will most likely remodel a lower polygon version.
You can naturally tell a difference between the high poly and low poly in engine. However as I anticipated it's not anywhere near enough to justify keeping a static instances that doubles the lower poly. If in the near future I find a problem with my engine that was costing severe performance and fixed it and can in fact use the lower poly as a LOD and not as the mesh I will do so. And if I further need to optimise I will LOD the lowerpoly and use this aswell.
98k(not in scale) 207k
Foliage
I've never worked with foliage in unreal engine or even unity for that matter so it makes sense that I wouldn't know the limitations for quantity within an engine. Nothing surprised me immensely about how little or how much you could push it before you dipped below 60 fps. However I've learnt much more than I thought I would in terms of foliage within a game engine.
Firstly the blossom tree, I managed to cut it down from 10k to 6k. The trunk of the tree was roughly 2.1k which I then cut down to around 0.8k already taking off 1.3k Tris. The leaves were 8k Tris. I realised that the amount of planes within a fibermesh instance in zbrush does not dictate the amount of leaves. The amount of leaves is a variable decided on the alpha texture, this meant i could drastically decrease the polycount and even increase the quality of the tree.
Iv'e decided to keep both meshes but mostly use the 6k and then dot the 10k around for variation in colour and size. This all together cut down around 120k Tris from my scene.
I turned shadows off the blossom trees for now because calculating where light doesn't penetrate in an instance of 4K alpha planes is very taxing.
However I was a little surprised to find that the most taxing aspect of my FMP so far was indeed the grass planes. I expected the process of optimisation to maybe involve reducing the plane count but not so much on the use of lighting. However static shadows are essential for aesthetically pleasing foliage so I kept it on and simply reduced the amount of planes instead.
This is with the amount of planes reduced. As you can see the grass foliage is still "extremely bad" meaning I'll need to possibly increase the size of the grass on the texture to reduce the amount of light that can get through the plane, increasing performance.
Its also important to note I've decided to change my plan of the environment. Originally I was going to let the player run around the forest surrounding the temple. However because of the player perspective if i do this it means i cant reduce the grass planes on either side of the main path. However if they are forced down a linear path then because of their eye level its a lot harder to make out the grass plane count across the field as they are all parallaxing and its not been viewed from a top down perspective.
So far this is all the optimisation I've applied. I will find that I'll need to optimise more when I start bringing in textures with draw calls, more models, particle effects, animations, terrain instances and high resolution mountain textures for around the environment. But I will cross that bridge when I come to it.
So far I've managed to increase the FPS from 80 to 130 in a single day with very little loss of quality and an even cleaner temple build.