3 ms·
Triangles in 3D euclidean space have the advantage of being uniquely defined by 3 vertices that have the nice property of always sitting on a single plane. Ther
by st_goliath 4y ago
Triangles in 3D euclidean space have the advantage of being uniquely defined by 3 vertices that have the nice property of always sitting on a single plane. There's no linear transformation you could apply that results in something other than a well-defined, planar triangle. The worst that might happen is collapsing it into a line or a point.
The same cannot be said for quads. If you e.g. have 4 vertices where 3 are sitting on the same plane, but the 4th isn't, there are 2 different, possible ways to subdivide this into triangles. In addition to all the possible non-linear surfaces one might image occupying that space.
Old OpenGL and Direct3D versions did have quad and arbitrary polygon rendering support. IIRC from vague memory, the above scenario was something you were supposed to avoid and results varied between graphics card vendors.
On a side note: If we are talking purely 2D, some old 2D software rendering systems used trapezoids as basic primitives, defined by their top and bottom edges. For instance, the X11 XRender API explicitly supports drawing trapezoids. They are easy to rasterize, interpolate across and quite flexible. Many other 2D shapes can be conveniently composed from them, including screen space triangles, if you were to implement a software rasterizer.
- ttoinou 4y agoOf course you're right but I was thinking about a subset of features for quads for this kind of use case. But yeah for all features triangles are better !
- Jasper_ 4y agoThe OpenGL specification basically had no explanation of what a "Quad" was, it didn't say anything about how to render quads, interpolate quads, etc. Pretty much every driver implemented quads as a funky way of spelling "two triangles". Much like tristrips/trifans/etc., index buffers give you all of the benefits with none of the drawbacks. > For instance, the X11 XRender API explicitly supports drawing trapezoids. It should be said XRender trapezoids have extra constraints: the top and bottom edges of the trapezoid must be completely straight (go exactly left to right). So it's basically a rectangle with sloped left/right sides. This makes it extremely easily to software rasterize, while you can still break each trapezoid into two triangles for 3D hardware.
- lmm 4y ago> It should be said XRender trapezoids have extra constraints: the top and bottom edges of the trapezoid must be completely straight (go exactly left to right). So it's basically a rectangle with sloped left/right sides. Isn't that just the definition of a trapezoid? Do you mean the top and bottom have to be parallel with the x axis or something?
- mananaysiempre 4y ago> Old OpenGL and Direct3D versions did have quad and arbitrary polygon rendering support. I vaguely recall that at different times people tried to build both PC and phone graphics hardware around quads and basically failed, but I don’t know why that didn’t work (aside from the issues of geometry that you mention).
- Keyframe 4y agoSega Saturn being a notable example.
- djmips 4y agoAnd Nvidia's first chip the NV1
- mrguyorama 4y agoImportantly, the sega saturn kind of wasn't a true 3D engine that had quads as it's primitive, but rather a stamp/sprite based system that allowed to you skew, warp, and transform those rectangular images in very powerful ways, mostly being able to reproduce 3D scenes but with certain caveats about the "polygons" that caused some limitations. One good example was that the system has no concept of UV maps. Each polygon is exactly the whole texture, linearly warped. This means you can't do, for example, environment mapping natively https://www.youtube.com/watch?v=WDJgeuoaSvQ https://www.youtube.com/watch?v=WDJgeuoaSvQ