I was recently learning about OpenGL and computer graphics development. I have a question regarding the usage of triangle as the basic building block, or basic shape to develop complex shapes. Is there a particular reason? Or just something that "stuck"?

  • 1
    $\begingroup$ Triangles are the basic building block in geometry (mathematics) as well because they are a simplex - the smallest number of points needed to make a shape in the given dimension. $\endgroup$ – Alan Wolfe Jul 7 '19 at 4:28
  • $\begingroup$ not only tris, pathtracing/raytracing techniques does not require triangles codepen.io/strangerintheq/pen/OKVVOW $\endgroup$ – Stranger in the Q Jul 22 '19 at 13:06

Triangles are always flat, unlike a quad which can be made in a way that is bent / not all vertices on the same plane.

If you were to interpolate say vertex normals across each scanline, on a 4-edge bent quad it will render with horizontal (scanline) artefacts. If you made that same bent quad out of triangles, it will render correctly as each triangle has a different normal slope.

That's one reason why triangles are preferable for scanline rasterising

| improve this answer | |
  • 2
    $\begingroup$ Non-planar quads would also be painful in that they can have 2 interection points per pixel, i.e. have an implicit silhouette edge. $\endgroup$ – Simon F Jul 10 '19 at 9:21

In computer graphics, people are interested in modelling the surface of the objects. And, since we are in the discrete world of computers, we need a discrete representation for surfaces, where we can easily check for stuff like intersections and angles, both vital for rendering.

The triangle makes it very easy to compute intersections and surface normals, but also has some useful features: it is always convex (if not degenerate), which means that the mathematics is a lot simplified. Being so basic, you can also split pretty much any shape in triangles.

But keep in mind that there are other basic shapes. Some hardware supports quads or nurbs, although it's much less common.

| improve this answer | |
  • $\begingroup$ Quads especially but (arbitrary) Polygons in general could be used in older versions (of OpenGL anyway). I am not exactly sure, but I think there also a hardware optimizations for the triangle related maths you do in rendering. $\endgroup$ – Tare Jul 3 '19 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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