Why do 3D engines use triangles to draw object surfaces?

In the exciting era of video games, it is essential to understand the technology behind them. As computer graphics have enhanced, the need for efficient rendering techniques has become clear.
Various shapes have been used in the past, such as squares, rectangles, polygons, and bezier curves, to draw surfaces of objects. But triangles have emerged as the building blocks for creating 3D environments in popular game development engines like Unity and Unreal Engine.

Why triangles?

Triangles are widely used in 3D graphics due to the number of advantages they offer in various aspects of rendering.

Simplicity

Triangles are the most basic polygons that consist of only three vertices connected by straight edges.
The mathematical operations involved in transformations and rendering are simpler using triangles than polygons with more vertices. The algorithms used for meshTriangles arranged in 3D space to create the effect of a solid object. representation also become simpler by the use of triangles.

Planarity

Three non-collinearThe set of points that do not lie on the same plane. points always define a unique plane in a 3D space. It ensures that triangles are always flat, with all three vertices on the same plane.
The planarity of the triangle facilitates the execution of complex operations, such as texture mapping, shading, and lighting calculations, by easily calculating the normalA vector perpendicular to the plane of the triangle..

Efficiency

rendering engine is a software that generates a realistic view from the 3D models. 

It transforms 3D models into on-screen 2D coordinates for display by using the projection matrix. The fewer vertices a polygon has, the less computation is required for the transformations, which results in improved performances.

As triangles have a minimal vertex count, they are the most efficient polygons in terms of computational overhead. Triangles can also approximate curved shapes effectively with fewer vertices allowing for more efficient rendering.

Flexibility

Triangles provide a high level of flexibility in approximating complex 3D surfaces.
Any 3D surface can be decomposed into a mesh of triangles regardless of shape or complexity. Accurate approximations can be made using many smaller triangles, allowing for a realistic rendering of objects.

Hardware support

Graphical processing unitsSpecialized processor dedicated to rendering and displaying graphics. (GPUs) are optimized to work with triangles efficiently. The pipeline of a modern GPU is designed with the assumption that the 3D models will primarily consist of triangles.

GPUs contain hardware components, such as triangle rasterizersA block that tells what pixels a triangle cover and shadersA program that calculates the levels of light, darkness, and color during the rendering of a 3D scene, that are efficient at processing triangles. These components strengthen the preference for triangles as the standard polygon for 3D rendering of objects.

Comparison of squares and triangles

Curve drawing using squares vs triangles
Curve drawing using squares vs triangles

Explanation

  • If we look closely at the arc being drawn by the use of squares, we will see many empty spaces (marked with the arrows). These spaces result in bad image quality. Since a square has more vertices, more space will be required to store these. The loading of the images will take time, and the computation will be much more complex.

  • If we look at the arc being drawn with the help of triangles, we will hardly see any empty spaces. We can fit more triangles with fewer vertices, producing good-quality images. As triangles are the simplest polygons, the computation will be much faster and simpler.

Extra spaces when squares are used to draw an arc
Extra spaces when squares are used to draw an arc
  • The squares are eventually made up of two triangles. So, there are a lot of empty spaces on the other half sides of the squares. It takes much more memory for storage, which eventually drops the image quality compared to simpler shapes.

Conclusion

As game graphics have evolved, triangles have become the preferred choice for creating 3D environments. The simplicity, flexibility, and efficiency of triangles make them the best choice for rendering realistic and visually engaging game worlds.

In conclusion, game developers and 3D artists can deliver immersive and realistic experiences to users by efficiently using triangles to draw object surfaces.

Read more about triangles


Free Resources

Copyright ©2024 Educative, Inc. All rights reserved