Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've worked using maya for animation and more film orientated projects however I am also focusing on my studies on video game development (eventually want to be either programmer or some sort of TD with programming and 3D skills). Anyways, I was talking with one of my professor and we couldn't figure out why all game engines (that I know of) convert to triangles. Anyone happen to know why game engines convert to triangles compared to leaving the models as four sided polygons? Also what are the pros and cons (if any) of doing this?

share|improve this question
1  
Somewhat related, The NVidia NV1 used quadtratic texture mapping (which uses quads), instead of triangles/polygons. It was not big hit, to say the least. See en.wikipedia.org/wiki/NV1. –  Macke Mar 9 '11 at 15:23
4  
@Macke: Quadratic as in "quadratic equation", not quadratic as in "quadrilateral". It doesn't use quads but rather a quadratic curve defined by 9 points. stason.org/TULARC/pc/3d-graphics-cards-faq/… –  user744 Mar 9 '11 at 16:49
3  
+1 for your question but a big -1 to your professor. This is basic stuff that he should have known as well as he knows the back of his own hand, and a sign that he's a little out of touch with developments over the past 15-odd years. –  Jimmy Shelter Dec 20 '11 at 17:56
    
Well in my professors defense he isn't on the game dev side he is more of an animator/modeler. He knew that it did convert to tris but didn't know the math reason as to why for rendering. But yes he probably should have known. –  Grant Feb 11 '12 at 6:02
add comment

8 Answers 8

up vote 46 down vote accepted

The bottom line is Triangle Rasterization, which is how computers render objects to the screen. Though others say it more elquently than I:

All 3D objects that we see on the computer screen are actually made of tiny little geometrical objects often called primitives. Quadrilaterals, triangles, n-gons etc. are example of primitives. We will concentrate on triangles mostly because of one main reason: every object can be split into triangles but a triangle cannot be split into anything else than triangles. Because of this, drawing triangles is a lot simpler than drawing polygons of higher order; less things to deal with. This is why those triangles are so commonly used in computer graphics.

Emphasis mine. Source: http://www.devmaster.net/articles/software-rendering/part3.php

share|improve this answer
1  
Awesome! That makes a lot of sense when you think about it. Thanks for the answer! –  Grant Mar 9 '11 at 1:25
1  
In OpenGL ES, as part of the effort to simplify the API, quads and polygons aren't even supported. So a practical reason to use triangles is because you don't have any other choice. But the reason a streamlined API like ES avoids other primitive types is due to reasons outlined in this and other answers. –  Suboptimus Dec 20 '11 at 23:39
5  
+1 Because is an answer I can safely use as reference when somebody ask me the same thing, to my bookmarks. Only say that, I always have thought that the reason triangles are the small possible primitive is because with the imprecision of float point arithmetic, tris are the only safe polygon you can guarantee to be planar in all cases, with quads you cannot guarantee they will be planar all the time. Modeling software probably show objects as quads or n-gons as convenience to the modeler but apply transforms/render dividing polygons as two or more triangles. –  Hatoru Hansou Jan 29 '13 at 22:53
add comment

Three points (a triangle) ALWAYS define a flat plane. In other words, given any three points, you can always create a flat plane that can cut through all three points. However the same is not always true of four points. You can have four points all on a plane, but you can also have four points that aren't on a plane.

share|improve this answer
1  
In fact 4 random points are more likely to be not on a plane so you'll have to triangulate anyway. –  ChrisF Mar 9 '11 at 8:39
    
This is only true if the points are not coincident. –  stephelton Dec 20 '11 at 5:21
1  
Even if the points are coincident, they are coplanar on an infinite number of planes. –  David Lively Dec 20 '11 at 17:34
    
Being coplanar doesn’t “ALWAYS define a flat plane”. –  Sam Hocevar Mar 20 '13 at 9:31
add comment

It's not "game engines" that do this - all the 3D software you use does this. It just doesn't tell you about it, and your professor seems fairly under-qualified if he doesn't know this. They exist in the computer's memory even if the software is hiding them from you. All 3D programs have an option that will make the triangles visible. They will also have an option that splits them into editable edges, so you can play with them. But they were always there to begin with and it's naive of your proffessor to be teaching this subject and still wondering "what triangles are for".

A triangle is the only way to arrange verts and guarantee a flat surface. When you have a quad, you can arrange the verts in a way that it must bend. But it's already made of triangles and it's those triangles that allow the bend.

share|improve this answer
add comment

A triangle is the simplest primitive that can be described in isolation because it has three points, fewer than which do not describe a surface in 3D.

Because a triangle can be considered in isolation, it is possible to make a piece of code or silicon that is capable of rendering only a single triangle, which via the power of repetition can render any surface at all.

Therefore, the first computer system which succeeded at rendering "any surface at all" naturally did so by rendering many triangles independently.

If one thinks of triangles and quads as "primitives" (i.e. as completely isolated bits of geometry with no context) the triangle is the more primitive, and so it will tend to "win."

However, once entertainment-grade computers exceeded a certain level of sophistication in the 1980s, the simplicity of considering "primitives" in isolation became less important. If graphics are to be mass-produced, then economies of scale favor processing groups of related vertices, much as they favor assembling a hundred near-identical cars at once.

This is why in the 1980s, movies adopted the "quad," which is a misnomer because it refers to a 2D grid of vertices in 3D space, and not an isolated quadrilateral.

The same shift from triangles to "quads" has not happened yet in the realm of interactive entertainment, but it is likely to happen, fairly soon, and for the same reasons it happened in the movie business.

share|improve this answer
add comment

If we assume that getting 4 points to be co-planar is not a problem (it is, as the others have pointed out, but bear with me) then you find that rendering an arbitrary trapezium (which is what a quadrilateral will usually look like when transformed into screen space) is not particularly different from rendering a triangle - in fact, it pretty much works out the same once you perform clipping as that can introduce extra vertices. (At least in a software model - hardware may well have a simpler brute force way of doing the clipping.)

The remaining issue therefore is one of representational efficiency. - you can easily represent a quad with 2 triangles, and without any extra vertices if you use a triangle strip (3 verts for the 1st triangle, then an extra vert for the 2nd triangle). On the other hand, if you try and represent a triangle with a quad, you need to use 4 vertices and have a degenerate one that is identical to another. This is not ideal in terms of efficiency.

share|improve this answer
add comment

As long as the triangle is defined by three non-colinear vertices (read: none of the angles are exactly Pi), then the vertices define a unique plane.

A quad is, of course defined by four vertices. It's perfectly possible for those vertices to be non-coplanar. In that case, your quad would really be two triangles divided by a diagonal on the quad. That's two planes, two sets of surface normals, etc.

Every available modeling tool, every algorithm for texturing, lighting, etc all assume that a model is made of plane segments, and every formula we have (cross products for normal calculation is the first one we have) use the absolute minimum input dataset - three vertices define a plane, and the plane is what we need to do all of the fancy stuff.

You could certainly write an engine to work with quads, but you'd find yourself ignoring the forth vertex in just about every case, except for when you (frequently) would need to make sure it's coplanar with the other three that define the quad. And, the most logical solution to the case where it is not coplanar would be to split the quad into two triangles. So, why not just do that to start with?

What on earth would be the point of working with quads?

If you want a quad, put two triangles together.

share|improve this answer
add comment

There's only one way to triangulate a triangle vs. 'n - 2' ways for an n sided polygon. So, triangles are ultimately the least ambiguous way to define a polyhedral shape. Also, as other posters have indicated, there are lots of ways to accelerate triangle (rather than quad or higher) rasterization (constant z is one of my favourites). Also, it's easier to optimize ray-triangle intersection tests than it is for ray-arbitrary polygon intersection tests. In fact, many operations on n-sided polygons benefit from having a triangulated representation to hand. That isn't to say that n-sided polygon representations are 'bad' - they are very useful but ultimately, you're going to want to work with triangles for many mesh operations.

share|improve this answer
add comment

Triangles have many properties that make them easier, and therefore faster, to draw.

Four points or more may not be on the same plane, but three points always are (ignoring degenerate cases). This has the interesting property that scalar values vary linearly over the surface of the triangle. Even when the triangle is projected on the screen, scalar values still vary linearly respect to x'/z and y'/z.

This, in turn, means most if not all of what's needed to shade, texture map, and depth filter a triangle can be calculated using linear interpolation which can be done extremely fast in specialized hardware.

tl;dr: triangles are the simplest primitive, so algorithms dealing with triangles can be heavily optimized.

share|improve this answer
10  
+1. I think the fact that a triangle is always planar is one of the main reasons. Non-planar polygons make stuff much more complicated. –  bummzack Mar 9 '11 at 8:11
1  
+1. I think triangles being the only polygon you can guarantee to be planar is the main technical reason to make apis and hardware that requires triangles. Modeling software probably show meshes as quads as convenience to the modeler. –  Hatoru Hansou Jan 29 '13 at 22:46
    
A nice non-planar analogy I use... A three-legged stool can stand on the ground only one way, its feet being like the corners of a triangle. But a four-legged stool can stand on the ground two ways, and wobbles from one position to another if one leg is shorter than the others. –  ChrisC Feb 1 '13 at 23:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.