3
$\begingroup$

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"?

$\endgroup$
2
  • 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
    Commented Jul 7, 2019 at 4:28
  • $\begingroup$ not only tris, pathtracing/raytracing techniques does not require triangles codepen.io/strangerintheq/pen/OKVVOW $\endgroup$ Commented Jul 22, 2019 at 13:06

2 Answers 2

7
$\begingroup$

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

$\endgroup$
1
  • 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
    Commented Jul 10, 2019 at 9:21
5
$\begingroup$

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.

$\endgroup$
1
  • $\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
    Commented Jul 3, 2019 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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