I'm curious to know which is better for games: quads or triangles? Wouldn't quads be better for rendering performances and smoothing out tessellation?
Answer
Triangles, the reason is triangles' ratesrization algorithm is faster, and also natively supported in hardware. So it would be faster to convert one quad into two triangles and do the rasterization. Actually that is what happens when you draw a quad on modern graphics hardware.
So the question is what makes it faster ?
There are certain characteristics in the triangle that makes working with it simpler and faster:
- Any three non colinear points form a triangle.
- Every triangle forms a unique plane. Triangle points cannot be part of two planes at the same time, unlike a quads, which save us the trouble from dealing with degenerate cases like this: Notice how the top quad in the middle vertices don't lay entirely in the same plane.
- Any shape can be broken down into triangles, and triangles can only be broken down into triangles(not counting the degenerate cases).
- "Point in triangle test" is much simpler and faster than "point in polygon test" ( also called odd even test). The point in triangle test is done using the Barycentric coordinates which is the main reason why triangles are faster to rasterize. Which brings us to the next point.
- Barycentric coordinates are not only useful for point in triangle test, but also for other interpolation operations, which are so common in computer graphics, color and texture coordinates to name few.
But I am still not convinced, quads ftw! We still need them..
Well, yes! It makes a lot of sense for artists to use quads. (I am not artist myself, but I did study arts- and I suck at it, weird?) Dealing with quads is more intuitive when modeling a 3D shape, providing texture coordinates is also much easier, but this doesn't deny the fact that you only need to deal with quads at the assets creation level, games and 3d engines usually need every bit of performance, so it would some kind of naivety to provide a sub-optimal structure of geometry to the GPU when it's doesn't really have any direct advantage, why use sub-optimal structure when we can take the best of each worlds? Quads at the assets creation level, and triangles at the engine level!
No comments:
Post a Comment