Triangles and Polygons Usage
Be savvy with number of triangles used
Use the least amount triangles possible (just enough to get the quality required)
- Fewer triangles helps boost performance.
- This should be one of the first things to keep in mind when creating content for a mobile platform.
- This is because fewer triangles mean fewer vertices to be processed by the GPU.
- Processing vertices is expensive, the fewer the number of vertices that get processed the better it is for overall performance.
- Having fewer triangles will enable the release of the game on more devices, not just the latest devices that have the most powerful GPUs.
- This is due to GPU support for 32 bit indices is not guaranteed on all platforms; for example Android devices with Mali-400 GPU do not support them. When we go beyond this number, the mesh will not render.
View/test game on target device instead of PC monitor screen.
- Some of the details that are created (with lots of triangles) might not even be visible on the phone.
Use more triangles on foreground object (closer to camera) and less on background.
- A game with a static camera POV (point of view) will benefit more by implementing this.
There are no hard numbers for maximum triangle count per model, as this depends on many factors.
- An example of this is the number of objects visible at a time in game. Many objects means the need to have a lower triangle count, if there are only 2 or 3 objects at a time we can go higher number. The example below shows characters from two demos. The Circuit VR demo only has 1 robot character, so we can go with a higher polycount, while the Armies demo has hundreds of soldiers in 1 frame so it is clear that it needs to be very low poly.
- The target device also matters. Newer phones such as the newest Samsung Galaxy S series will be able to handle more complex geometry that an older mobile device.
- The target device also matters. Newer phone such as Galaxy S9, S10 will be able to handle more geometry that an S5.
Below is an example number of triangles on our tech demo. This is not meant to be a hard number guidelines as it entirely depends on type of game and target device.
- The Armies demo (64 bit mobile tech demo built in Unity), the camera is static with lots of animated characters. In total, each frame render around 210K triangles and this triangle count enable the demo to run at ~30 FPS stably.
- The largest object in the scene, the cannon tower is ~3000 triangles each as they are occupy big portion of the screen.
- Characters only use around 360 triangles, this is because there are so many of them and they are only going to be seen from a distance. From the users camera POV, they look fine.
Distribute triangles in areas that matter
Place triangles in areas that matter the most.
- Polygons (vertices) are very expensive on mobile platforms. By placing them in area that really contributes to visual quality of the game, we will not waste processing budget.
- Many small triangle details on a 3D object will not actually be visible on the games final screen, due to combination of a small phone screen size and placement of these 3D objects in the game level. This needs to be taken into consideration when creating details.
Focus on big shapes and forms that contribute to silhouette of the object instead of detail
- Use fewer triangles on the areas that are not seen very often from the camera POV. An example of this would be a bottom of a car or the back of a wardrobe.
- Avoid modelling small details using high density triangle meshes (use textures and normal maps for fine detail)
- The images below show the same mesh with and without normal map.
- Delete the back/bottom part of an object that will never be seen by the camera POV.
- This needs to be done carefully as it might limit re-usability of the scene. For example, if we delete the bottom part of a table mesh as we think it will never be seen by the end user, this mean we can't ever place it upside down.
Micro triangles are bad
Micro triangles are very small triangles which do not contribute much to the final scene in terms of the visual of an object/scene.
All 3D objects with many polygon count will have micro triangles problem when they are moved further away from the camera. There is no scientific definition for micro triangles, but it's usually addressed as triangles that smaller than 1-10 pixel in the final image (on phone screen). Micro triangles are bad because the GPU will need to do all the processing on all these triangles while they are not actually contributing much to the final image (as they are too small). Vertices are expensive to process and very small triangles mean a lot more vertices.
Micro triangles can be caused by 2 things
- Details that are too small and consist of many triangles
- Objects further from camera with lots of triangles
What to do to mitigate this?
- For an object further from camera use level of detail (LOD). This will reduce complexity of an object, making them simpler and causing them to have less dense triangles.
- Avoid modelling details using many polygons (use textures and normal maps for this type of fine detail).
- Merge vertices/triangles detail that are too small and not contributing much to final image.
- Rule of thumb: Aim to keep triangles above 10 pixels in area.
- The GPU will need to process all these triangles/vertices while they are not actually contributing much to the final image as they are too small.
- This will also affect memory bandwidth as there is a lot more data that needs to be sent to the GPU.
- On a mobile device all this processing will affect battery life, meaning the end user can't play the game for as long.
Long thin triangles are bad
These are triangles that when rendered in final image are smaller than 10 pixel and span along the screen. Long thin triangles are bad because it's generally more expensive to process compared with normal (non long thin) triangles.
Example of long thin triangles - bevel on this pillar when viewed from a distance. These bevels are not a problem if seen close up.
What to do to mitigate this?
- Remove long thin triangle on an object if possible. There will be situations where this is not possible but the best solution for this problem is by removing it completely.
- Avoid having shiny material on an object with long thin triangles as this will cause flickering.
- Use LOD and remove long thin triangles when they are further away
- On a more technical side it will be ideal to keep triangle close to equilateral. So it have more inside area and less edges.
- A technical explanation of this can be found here - http://www.humus.name/index.php?page=News&ID=228
Why are they bad?
- Objects with long thin triangles combined with shiny material will look shimmering/flickering from distance.
- Because the triangle is very thin, when the camera moved slightly it will make the triangle sometimes touch the sampling point and sometimes missed, resulting the fragment sometimes get rendered sometimes not. This will appear flickering in the final image.
- Long thin triangles perform worse compared to bigger triangles in general.