Triangle and polygon usage

To optimize the performance of your game, you must be aware of the number of triangles that are on-screen at any given time.

Use the minimum number of triangles to get the correct balance between the intended quality of your 3D objects, or models, and delivering consistent performance.

We recommend that you try the following tips:

  • Using fewer triangles results in increased performance.
    • It is essential to consider the triangle count when creating content for a mobile platform.
    • Fewer triangles mean fewer vertices for the GPU to process.
    • Processing vertices is computationally expensive. Fewer vertices to process results in better overall performance.
  • Using fewer triangles enables the release of the game on more devices, and not just the latest devices with the most powerful GPUs.

The following image shows a comparison between two 3D objects. One object uses 584 triangles, and the other object uses 704 triangles. Both objects look the same in shaded mode. This shows that you can remove any edges in your models that do not contribute to the silhouette.

In Unity, the format of the mesh index buffer dictates the maximum number of vertices that each 3D object can use:

  • A 16-bit index buffer supports up to 65,535 vertices
  • A 32-bit index buffer supports up to 4 billion vertices

Some older GPUs, including Android devices using the Mali-400, only support 16-bit index buffers. These devices do not render 3D objects with more than 65,535 vertices. For maximum cross-platform compatibility, use 16-bit index buffers and keep the number of vertices in a single mesh under the limit.

It is essential to view or test the game on as many target devices as possible. Testing your game on just a computer screen does not give you the information that you need for optimization.

Keep in mind that mobile device screens are smaller than the average computer monitor. Therefore, any details that are created using lots of triangles may not even be visible on a mobile device.

Use more triangles on 3D objects that are in the foreground and therefore closer to the camera. Use fewer triangles on 3D objects that are further away in the background. A game that uses a static camera Point-of-View (POV) benefits more from this technique.

The following image shows an example where 3D models are used in the foreground, but lower quality 3D models are baked into the 2D background:

While there are no fixed numbers for the maximum on-screen triangle count, the more 3D objects that are on-screen at the same time, the fewer triangles you can use per object. However, if you are displaying fewer 3D objects on-screen, then you can use more triangles per object.

The target device also matters. Newer phones are able to handle more complex geometry than older mobile devices.

The following example image shows characters from two demos:

  • The Circuit VR demo only has one robot character, so a model with a higher polygon count can be used as shown on the left.
  • The Armies demo has hundreds of soldiers in one frame, so it needs a much smaller per-object polygon count, as shown on the right.

The Armies demo is a 64-bit mobile device demo that was built in Unity. In this demo, the camera is static with lots of animated characters. Each frame renders approximately 210,000 triangles in total. This triangle count enables the demo to run smoothly at approximately 30 Frames Per Second (FPS).

Note: The number of triangles to use depends on both the type of game that is being created, and the specifications of the target devices.

The following example shows the total number of triangles that were used in the Armies demo:

The largest objects in the scene, the cannon towers, are approximately 3000 triangles each. This is because they occupy a large portion of the screen.

Characters only use approximately 360 triangles. This is because there are many characters, and they are only seen from a distance. From the camera point-of-view, the characters look fine on screen.

Triangle distribution triangles in areas that matter

Both polygons and vertices are computationally expensive on mobile platforms. By placing polygons in areas that really contribute to the visual quality of the game, we are not wasting the processing budget.

Due to the small screen size on most devices and the location of 3D objects in your game, many small triangle details on a 3D object might not be visible in-game. This means that you should focus on large shapes and parts that contribute to the silhouette of the object, rather than small details that might not be visible. The following image highlights the object silhouette in red, to show how the different shapes contribute to it.

Use fewer triangles on the areas that are not often shown on-screen. Examples include the bottom of a car, or the back of a wardrobe.

Avoid using high-density triangle meshes for modeling small details. Instead, use textures and normal maps for fine detail.

Note: A normal map is a texture map that stores the surface direction at each pixel.

The following images show the same mesh with and without normal map:

Consider deleting the back, or bottom, part of an object that is never seen from the camera POV.

However, deleting object parts needs to be done carefully, because it might limit the re-usability of the scene. For example, you might delete the bottom part of a table mesh, because you think that it is never seen by the end user. Doing this would mean that you could no longer place that model upside down, or reuse that model in another game where the underside of the object would be seen.

Why you should avoid micro triangles

Micro triangles are tiny triangles that do not contribute much to the final look of an object or scene.

When a 3D object with a large polygon count is moved further away from the camera, a micro triangles problem occurs. Micro triangles are triangles on a device that are between one and ten pixels in size.

Micro triangles reduce performance because the GPU must process all of these triangles, even though they are too small to see in the final image. Remember that vertices are computationally expensive to process, and more triangles on-screen at the same time means more vertices to process.

The following two approaches cause micro triangles:

  • Details that are too small and consist of many triangles
  • Objects with many triangles that are further from the camera

The following image shows the number of triangles that are used when a 3D object is both nearer to, and further from, the camera. The gray images on the left use fewer triangles. The gray and red images on the right uses a normal map to display the same amount of visible detail:

In the following image, most of the triangles in the highlighted area are too small to be visible on a mobile device. Therefore, they do not contribute much to the final look of the image:

How to minimize the micro triangle problem

Here are a few steps that you can take to mitigate problems with micro triangles:

  • For an object that changes its distance from the camera, use Level of Detail (LOD). Using the correct LOD simplifies an object when it is further away, and the object uses fewer triangles.
  • Use fewer triangles on background objects.
  • Avoid using polygons to create the finer details in a mode. Instead, use a combination of textures and a normal map instead.
  • Merge any vertices or triangles that are either too small to see on-screen, or are not adding much value to the final image.
  • Try to keep triangles above ten pixels in area.
Minimizing the use of micro triangles

There are several reasons to minimize the use of micro triangles:

  • The GPU must process all triangles and vertices, even when they do not add any value to the final scene on-screen.
  • Memory bandwidth is negatively affected, because more data must be sent to the GPU for processing.
  • The amount of processing that is required directly impacts the battery life of a mobile device. Therefore, the more data that the GPU must process, the less time the battery lasts.
Why long and thin triangles can cause problems

Long, thin triangles are vertices that, when rendered in the final image, are smaller than ten pixels. Long, thin triangles can cause issues because they are more expensive for the GPU to process when compared with normal triangles. This is because GPUs process pixels in square blocks. Long, thin triangles can mean that the GPU has to perform calculations for many square blocks, even though the actual number of pixels that the thin triangle occupies is relatively small. This situation results in wasted computations.

The following screenshot shows an example of a long, thin triangle in use. The screenshot highlights the bevel on the pillar when it is viewed from a distance. However, the bevels are not a problem when seen close up:

Minimize the long thin triangle problem

Here are a few steps that you can take to mitigate issues with long, thin triangles:

  • Remove any long, thin triangles that you see from all objects when possible. The best solution is to remove the long, thin triangles completely, although there can be situations where this is not possible.
  • Avoid using shiny materials on an object with long, thin triangles, because this causes flickering.
  • Use Level of Detail (LOD) and remove the long, thin triangles when they are further away on-screen.
  • Try and keep triangles close to equilateral. Ensure that the triangles have more inside area when compared to the edges.
  • A more detailed explanation of this problem can be found here.
Previous Next