Difference between revisions of "Polygons"

From polycount
Jump to: navigation, search
(edited for accuracy and grammar. Included are several comments that should be looked at. I propose that this page become a more generalized euclidean geometry page.)
(added citations)
Line 9: Line 9:
 
== Polygon Storage Methods ==
 
== Polygon Storage Methods ==
  
[[Image:Polygons$tri_quad_hexagon.gif]]
+
{| border="1" cellpadding="2" cellspacing="0"
 +
|-
 +
|}
  
 
A [[triangle]], a [[quad]], and an [[n-gon]].
 
A [[triangle]], a [[quad]], and an [[n-gon]].
Line 29: Line 31:
 
== Non-Coplanar Quads ==
 
== Non-Coplanar Quads ==
  
[[Image:Polygons$ridge_valley.gif]]
+
{| border="1" cellpadding="2" cellspacing="0"
 +
|-
 +
|}
  
 
These two [[quads]] illustrate a problem that some [[engines]] have when a quad's [[vertices]] are not [[coplanar]] (on the same plane). Each quad has their vertices in the same shape. I put the quads inside grayed-out bounding boxes to make the perspective easier to see.
 
These two [[quads]] illustrate a problem that some [[engines]] have when a quad's [[vertices]] are not [[coplanar]] (on the same plane). Each quad has their vertices in the same shape. I put the quads inside grayed-out bounding boxes to make the perspective easier to see.
Line 41: Line 45:
 
== Concave Quads ==
 
== Concave Quads ==
  
[[Image:Polygons$concave.gif]]
+
{| border="1" cellpadding="2" cellspacing="0"
 +
|-
 +
|}
  
 
These are two [[quads]] that illustrate another problem, similar to the Non-Coplanar Quad. Each quad has their [[vertices]] in the same shape. The red lines are the interior edges between the two [[triangles]] that make up each quad. The darker triangle in the quad on the right is overlapping the quad's other triangle, which is larger.
 
These are two [[quads]] that illustrate another problem, similar to the Non-Coplanar Quad. Each quad has their [[vertices]] in the same shape. The red lines are the interior edges between the two [[triangles]] that make up each quad. The darker triangle in the quad on the right is overlapping the quad's other triangle, which is larger.

Revision as of 10:09, 11 August 2010


{{:OutOfDate}}

Polygons

Polygon Storage Methods

A triangle, a quad, and an n-gon.

All modern real-time 3D engines support triangles. Some of these support quads and/or n-gons, but all polygonal engines convert them down to triangles at render time, a step known as tessellation. The rare engines that support non-polygonal geometry, often use other methods to create objects, like voxels.

With a triangle-only engine, you can still use polygons with more than three sides, but the engine always sees them as tris because it either tessellates them at runtime, or on import. For each triangle, it stores three vertices that define the shape.

However, if you are able to use quads, the engine is then able to store them as only four vertices apiece, instead of the six that would be required to store the two triangles that make up the square shape. Engines that support quads usually support plain old triangles as well, for those difficult shapes where quads won't work. Quads save on the size of the geometry file, which saves memory, and it saves on the amount of calculations the engine has to do to transform the quads before rendering, which can ultimately speed up your frame rate. Every little bit helps.

The same holds true for n-gons, except they can save even more vertices. The hexagon, for example, is stored as only six vertices, instead of the twelve verts needed for plain triangles to describe the same shape. Remember, your engine must support quads or n-gons for this to work, and there are some restrictions-- see below.

The term "n-gon" does not always mean a polygon stored in this special vertex-saving way. There really isn't a specific term for this. You just have to spell it out anytime you refer to these special polygons. Which really isn't all that often, as most engines do not support them.

There are many ways to reduce vertex counts, like using strips and fans.

Non-Coplanar Quads

These two quads illustrate a problem that some engines have when a quad's vertices are not coplanar (on the same plane). Each quad has their vertices in the same shape. I put the quads inside grayed-out bounding boxes to make the perspective easier to see.

Some engines do not allow non-coplanar quads to exist-- instead they are automatically converted to triangles. However, if the engine allows non-coplaner quads, a problem can occur where both quads have their vertices in the same layout, and so the engine has to convert the quads to triangles before rendering. The problem is that it does not know how you want the quad divided, so it arbitrarily decides where to put that interior edge. The quad could either be a ridge (left) or a valley (right).

This leads to some ugly artifacts, like a character's shoulder looking cut-into instead of muscled. Another problem happens if you are animating the quad's vertices, like with morphing-- the engine converts the quad into triangles, and on each frame it arbitrarily decides where to put that interior edge, so it ends up constantly flashing between ridge and valley.

If your engine supports quads, make sure your quads' vertices are coplanar.

Concave Quads

These are two quads that illustrate another problem, similar to the Non-Coplanar Quad. Each quad has their vertices in the same shape. The red lines are the interior edges between the two triangles that make up each quad. The darker triangle in the quad on the right is overlapping the quad's other triangle, which is larger.

The vertices of these two quads are actually coplanar-- the problem is that they form a concave shape, but the engine still has to make the quad into two triangles at render time. It doesn't know that you want it to look like the one on the left, so it may create the one on the right.

What's so bad about that? Since the two triangles overlap in the same plane, the engine doesn't know which to draw in front of the other, so it flashes from one triangle to the other from frame to frame. Not very professional looking. If you need this shape, it's better to go with plain triangles.


Personal tools
Namespaces

Variants
Actions
Navigation
Tools