Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

3d

People also ask

Why are triangles used for graphics?

Computer graphics uses flat triangles to approximate smooth surfaces, but if you're willing to allow triangles to bend a bit, then you can build any surface by gluing enough of them together. This is equivalent to saying that you can cut any surface into curved triangular pieces.

What are triangles in 3D modeling?

When modeling in 3D with polygons, it is important to construct all of your models using quads and triangles. A triangular polygon is referred to as a tri or triangle, and is a simple three-sided polygon. It has exactly 3 vertices at its corners and 3 edges connecting those points.

Why are meshes made up of triangles?

Many graphics software packages and hardware devices can operate more efficiently on triangles that are grouped into meshes than on a similar number of triangles that are presented individually. This is typically because computer graphics do operations on the vertices at the corners of triangles.

Why are there triangles instead of quads?

The reason for this is that triangles are guaranteed to be a flat surface unlike quads which can have bent surfaces. In general, having a guaranteed flat surface makes the process of rendering triangles simpler than rendering quads and quicker as well which is why most game engines will just triangulate the meshes.


Triangles can never be non-planar; anything with more than 3 points can be non-planar and thus un-renderable unless converted to triangles.

For example: A square is two triangles that are on the same plane, if all the points that make up the square are co-planar. It takes a lot of calculations to make sure all the points are co-planar, thus all polygons that are greater than 3 points are pre-calculated by decimating them into triangles and tested to make sure all the points are co-planar once, instead of on every frame that gets rendered.

Here is good reference about polygon meshes.

Planar Mesh


(source: softimage.com)

Non-Planar Mesh


(source: softimage.com)

and one more example that might make it clearer


(source: autodesk.com)

The non-planar mesh is degenerate and can't be sorted or rendered correctly in any sane manner. Triangles don't have this problem.

Efficiency

Triangles also are very memory efficient and can be sorted, and rendered extremely fast when using Triangle Strips which only need 1 point to be stored for each additional triangle after the first.

http://upload.wikimedia.org/wikipedia/en/0/03/Triangle_Strip.png

and Triangle Fans which is a special case of a Triangle Strip.


(source: codesampler.com)


Since 3 points are the minimum necessary to define a planar surface any shape can be simulated using many triangles, and efficient algorithms exist to rapidly paint triangles onto the screen.


Basically any complex (surface) structure can be represented as a bunch of triangles. The triangle is the most atomic and primitive geometry. Hence it is used as base for almost anything. Nevertheless most 3D engines provide you with more complex primitives like spheres, cones, cylinders, donuts, whatnot. Check your libraries documentation.