This topic is regarding work for the challenge in Lecture 16 - Non-Player Characters 2/2.
The following is what I could recall of the optimisation methods:
- Polygon count - CPU: No, GPU: Yes, Rule of thumb: 300-1500 mobile, 1500-4000 desktop
- Fewer materials - CPU: Yes, GPU: No, Rule of thumb: 2 or less per mesh
- Fewer bones - CPU: Yes, GPU: Yes, Rule of thumb: 15-30 mobile, 15-60 desktop
- Separate Forward and Inverse Kinematics - CPU: Yes, GPU: No
- Single Skinned Mesh Renderer - CPU: Yes, GPU: No
Explanations for methods:
Reducing the polygon count per character reduces the amount of work the GPU has to do to render the scene.
Using fewer materials on each mesh reduces the number of calls the CPU has to make to the GPU (one per material), which reduces the preparation that the CPU has to do.
Using less bones reduces the mesh deforming that the CPU has to calculate, which in turn reduces the GPU’s work rendering it.
Separate Forward and Inverse Kinematics:
Animation software sometimes uses inverse kinematics to determine where limbs, etc. should be to get from one place to another.
Unity only uses forward kinematics, so keeping everything as forward kinematics in Unity avoids it having to perform its own translation to forward kinematics.
This reduces load on the CPU.
Single Skinned Mesh Renderer:
Using multiple mesh renderers for a single character can prevent Unity from performing certain optimisations, such as avoiding rendering a part of the character that is blocked from view
by another mesh renderer on the character.
These calculations are sometimes done on the CPU and sometimes on the GPU, so it could reduce load on either of them.
I’m pretty pleased with what I could remember, though I think a couple of my explanations are a bit off. I’ll go and check them now. I also had the rule of thumb for polygon count wrong (30-1500 for mobile, rather than 300-1500) but that was the only correction I made to the list.
Turns out that the part about calculations possibly being performed on either the CPU or GPU was in regards to the fewer bones optimisation, rather than the Single Skinned Mesh Renderer one. The game may choose to calculate where the polygons are on the deformed meshes on either the CPU or the GPU, so it could reduce load on either of them.
For the Single Skinned Mesh Renderer method of optimisation, the culling optimisation that Unity performs reduces the number of polygons and hence reduces GPU load, and the CPU also doesn’t need to calculate as much for the deforming of the meshes.
_I also had the explanation for Separate Forward and Inverse Kinematics slightly wrong. You can only create forward kinematics in Unity, so it has various optimisations that it can perform for them. Getting the animation software to “bake” or produce forward kinematics versions of the animation, allows Unity to do these optimisations and not use it’s own inverse kinematics, which are not as optimised (if at all).