Scene Kit Performance with cube test Scene Kit Performance with cube test swift swift

Scene Kit Performance with cube test


As you mentionned Minecraft, I think it's worth looking at how it works.

I have no technical details or code sample for you, but everything should be pretty straightfoward:

Have you ever played minecraft online, and the terrain is not loading allowing you to see through? That's because there is no geometry inside.

let's assume I have a 2x2x2 array of cubes. That makes 2*2*2*6*2 = 96 triangles.

However, if you test and draw only the polygons on the visible from the camera point of view, maybe by testing the normals (easy since it's cubes), this number goes down to 48 triangles.

If you find a way to see which faces are occluded by other ones (which shouldn't be too hard either considering you're working with flat, quared, grid based faces) you can only draw these. that way, we're drawing between 8 and 24 triangleS. That's up to 90% optimisation.

If you want to get really deep, you can even combine faces, to make a single N-gon out of the visible, flat faces. You can do that if you create a new way to generate the geometry on the fly that combines the two previous methods and test for adgacent visible faces on the same plane.

If you succeed, we're talking 2 to 6 polygons instead of 96, to render 8 cubes.

Note that the last method only works if your blocks are touching each other.

There is probably a ton of Minecraft-like renderer papers, a few googles will help you figure it out!