To make a beautiful game, we need to create beautiful 3D models. Sometimes these models can have tens of thousands of vertices, or sub-meshes. Luckily, Apple provides us a framework––Model/IO to do the heavy lifting.

However, if we have a model with 50,000 vertices––some German soldiers for example, we don’t want to pass all the vertex data to the GPU, because that will be a huge amount of data. Instead, we will do something called instancing. Instancing means we take vertices from one model, and make them into instances––like references, so that it’s easier for GPU to render. Here I will show some comparison before and after using instancing.

I have a human model which consists of 15,593 vertices and render 40 of these models onto the screen.

Before instancing:

Memory usage:

Screenshot 2018-06-18 at 5.37.39 PM.png

CPU usage:

Screenshot 2018-06-18 at 5.37.51 PM.png

FPS and Frame time:

Screenshot 2018-06-18 at 5.38.06 PM.png

After instancing:

Memory usage:

Screenshot 2018-06-18 at 6.04.21 PM.png

CPU usage:

Screenshot 2018-06-18 at 6.04.15 PM.png

FPS and Frame time:

Screenshot 2018-06-18 at 6.04.32 PM.png