|
Which is the fastest models?; Triangles or Quads?
|
|
Topic Started: Jun 18 2008, 01:09 PM (645 Views)
|
|
slurpee123abc
|
Jun 18 2008, 01:09 PM
Post #1
|
- Posts:
- 57
- Group:
- Members
- Member
- #19
- Joined:
- 2-06-08
- Development Experience
- Programming
- Operating System
- Windows
- Favorite Programming Language
- Blender, Python, C++, GMC
|
I was wondering, does one quad take the same amount of computer resources as two triangles take? Should we try to make triangles when possible, instead of quads? I think quads are just two triangles.
|
|
|
| |
|
techwizrd
|
Jun 18 2008, 04:03 PM
Post #2
|
- Posts:
- 236
- Group:
- Admins
- Member
- #1
- Joined:
- 31-12-07
- Development Experience
- Jack-of-all-Trades
- Operating System
- Ubuntu 8.04, Slackware 12.1
- Favorite Programming Language
- Python, C, Lisp
- Favorite Desktop Environment
- Gnome 2.24
|
Triangles are harder to work with.
As for the efficiency of quads vs triangles, I would think that quads take less calculations. Every point exactly 3 edges connect to it, but logically connecting to all the points close to it might be a pain. So, I think quads might be better, but I have not taken a look at the underlying algorithms.
|
My DeviantArt user page Please comment and add me to your favorites!
|
| |
|
slurpee123abc
|
Jun 18 2008, 06:33 PM
Post #3
|
- Posts:
- 57
- Group:
- Members
- Member
- #19
- Joined:
- 2-06-08
- Development Experience
- Programming
- Operating System
- Windows
- Favorite Programming Language
- Blender, Python, C++, GMC
|
I always thought triangles would be faster, because three points automaticaly have only 3 possible edges to connect them. For quads, however, the computer has to know in which order the points connect to each other. Otherwise, you might see something like an hourglass figure. But I am just guessing.
|
|
|
| |
|
techwizrd
|
Jun 18 2008, 07:54 PM
Post #4
|
- Posts:
- 236
- Group:
- Admins
- Member
- #1
- Joined:
- 31-12-07
- Development Experience
- Jack-of-all-Trades
- Operating System
- Ubuntu 8.04, Slackware 12.1
- Favorite Programming Language
- Python, C, Lisp
- Favorite Desktop Environment
- Gnome 2.24
|
I don't know. Calculating the area for all those triangles seems harder...
Oh well. It does not matter. Quads are cooler...
|
My DeviantArt user page Please comment and add me to your favorites!
|
| |
|
slurpee123abc
|
Jun 18 2008, 09:23 PM
Post #5
|
- Posts:
- 57
- Group:
- Members
- Member
- #19
- Joined:
- 2-06-08
- Development Experience
- Programming
- Operating System
- Windows
- Favorite Programming Language
- Blender, Python, C++, GMC
|
http://forums.activeworlds.com/archive/index.php?t-5159.html
This is an amazing explanation. It talks all about quads and triangles and 3d factors. It also says that triangles render faster in many cases. Read it all.
Slurpee
Spoiler: click to toggle Recently I have exchanged some emails with a customer and AW citizen about low polygon modeling for real time rendering. So I thought I would post some comments here for any one who is interested.
For low polygon models: ----------------------- -- Design your geometry to use the lowest number of triangles. -- If triangles will never be seen by the camera then do not include them in the model. -- If a group of triangles appear to share the same vertex make sure that the coordinate values are the same and that the vertex is really a common vertex. -- if a texture is applied to a group of triangles at a common vertex, whenever possible, have the same UV coordinates for all the triangles. -- Count triangles. Do not count vertices, quads and polygons with more than 4 edges. -- If quads are used make sure they are flat and not bent. A quad or any polygon should have all its vertices in the same plane. -- Do not worry about things over which you have no control.
< pause >
Now that you have come down off the ceiling because I told you not to count vertices, I will give some points in very general terms.
What does a graphics card do? ----------------------------- (Note: Specifications are always changing so things once not done may be done now and this discussion is very general) -- It does clipping. Clipping determines whether all or part of a triangle is in the view volume which will be displayed on the computer screen. -- It does culling. For single sided rendering, if the visible side of the triangle does not face the camera, the triangle is culled or not rendered. -- It does lighting calculations. -- It draws or renders point clouds. Point clouds are just vertices that are not connected. By default, a point cloud vertex lights up one pixel. The graphics card can be told to make the vertex larger than one pixel. Point clouds render very quickly. -- It renders 2D lines. Lines are defined by the two vertices at either end of the line. By default the lines are 1 pixel thick and are solid from one vertex to the other. The thickness of the lines can be changed and the hatching pattern used can be changed. 2D lines render quickly but not as fast as point clouds. -- It renders polygons. Polygons render the slowest of all. Polygons are triangles, quads and polygons with 5 or more sides. The vertices are used to determine an outline for the polygon and then this outline is either filled with a solid color or a texture. The larger the triangle appears on the screen the longer it takes to render the polygon because more pixels have to be assigned some color value.
Which polygons are rendered by the graphics card? ------------------------------------------------- For your particular card, you will have to read the technical specifications for the card.
You will probably find that your card does not render polygons with 5 or more sides and that it does not render CSG models (solids created with Booleans and other fun things). This just means that the software sending commands to the graphics card must convert the objects into something acceptable to the graphics card.
You will probably find out that the card renders triangles and quads. Digging a little deeper you will probably find out that the GPU on the card only accepts triangles and that the software driver for the card uses your CPU and converts the quads into triangles and then only sends the triangles to the GPU.
Model data can be either cached or not cached for use by the GPU. If the data is not cached and the driver has to continually convert the quad to triangles every time the quad is rendered then your model will render slower using quads then if it used all triangles.
Note: You have no control over how the AW browser, the Renderware engine (that the browser uses) and the card driver handles quads, CSG solids and polygons with more than 4 sides. The only control you have is whether you use these things in your models.
Commands to control the graphics card ------------------------------------- There are several ways in DirectX and OpenGL to tell the graphics card how it should render the polygons.
One method in OpenGL to render a triangle on the graphics card. The triangle will be textured and use vertex normals for smooth rendering. Commands to set material properties and to load the texture are sent to the graphics card before you send the commands to render the triangles.
A triangle is described by the three vertices that make it up. Variables are needed to store the numbers.
// for vertex 1 // GLfloat nx1, ny1, nz1; // normal GLfloat u1, v1; // uv coordinates GLfloat x1, y1, z1; // vertex
// for vertex 2 // GLfloat nx2, ny2, nz2; // normal GLfloat u2, v2; // uv coordinates GLfloat x2, y2, z2; // vertex
// for vertex 3 // GLfloat nx3, ny3, nz3; // normal GLfloat u3, v3; // uv coordinates GLfloat x3, y3, z3; // vertex
// start of commands to tell OpenGL to render the triangle // glNormal3f(nx1, ny1, nz1); glTexCoord2f(u1, v1); glVertex3f(x1, y1, z1);
glNormal3f(nx2, ny2, nz2); glTexCoord2f(u2, v2); glVertex3f(x2, y2, z2);
glNormal3f(nx3, ny3, nz3); glTexCoord2f(u3, v3); glVertex3f(x3, y3, z3); // // end of commands to tell OpenGL to render the triangle // nine OpenGL functions were called to render the triangle.
To render 1000 triangles on the graphics card, the same set of 9 functions were called 1000 times with appropriate changes in the variables.
The rendered object could have come from RWX, COB or whatever file and it would not matter if the file had or did not have duplicate vertices as the same amount of data would be fed to the graphics card. If the file contains duplicate vertices and vertex - uv pairs, the AW browser has to allocate more RAM to hold the object but it does not have to send more data to the graphics card to render the same amount of triangles.
There are other methods of sending data to the graphics card. For these other methods, duplicate vertices, etc. mean that unnecessary data has to be sent to the card which uses up RAM on the card and takes extra time. One of these methods uses arrays of vertices, normals, uv coordinates and then indices stored in the triangle array reference the data in the other arrays. Another method called Vertex Buffer Objects runs very fast but is only available on the newer cards.
Note: You have no control over how the AW browser organizes the model data before sending it to the RenderWare engine and no control over how the RenderWare handles the data before it sends it on to either the DirectX or OpenGL drivers.
AW browser reading files ------------------------ I have no contact with AW and don't know what they are doing since they dropped their TechTalks.
The AW browser converts the RWX and COB files and puts the data into a format that is acceptable to the RenderWare engine.
RenderWare created the RWX file format and a DLL to read the files. They have now dropped all support for this. Roland had to write a conversion routine for the browser so that it could continue to read the RWX files.
Hamfon wrote his cobdump program to read COB files. I think that this code forms the basis for the COB conversion now used in the AW browser. If so, then the conversion you see done by cobdump is what you have inside the browser.
A lot of decisions have to be made when writing conversion programs and thus you see many varied results when you convert the same file with different programs.
Note: Vertex - uv pairs are stored in the RWX file but the RenderWare engine may want them in separate lists. What ever way they want them could change at any time and you have no control over this.
Note: You have no control over how AW browser converts files. How it handles Boolean objects. How it tessellates (divides into triangles) polygons. You do have control of only saving triangles to the file so you know what you will have when the file is converted.
Building Identical Objects -------------------------- You could take a collection of modeling programs: Wings3D, 3DCanvas, trueSpace, LightWave, 3DS Max, SoftImage XSI, Maya, etc. and build the identical model using textured and non textured triangles. You save the model to the native file format for each program. File sizes will vary because all the file formats are different. The zipped files will vary somewhat in size and thus take different amounts of time to transmit over the Internet.
Now assume the AW browser can read all known file formats and even those not yet invented (since we are assuming). The browser reads all the various file formats and converts the data to the format needed by the RenderWare engine. All the models are rendered and what do you know. They all rendered at the same speed because they were identical except for the size of the file they were stored in.
Summary ------- -- When rendering polygons, the vertices describing the polygon are rendered as part of the surface making up the triangle. -- To have a polygon model render faster reduce the number of polygons. Counting two triangles as one quad doesn't make it render faster. -- Keep the polygon count low and make sure common vertices are really identical and the vertex count will be whatever it is.
Time to end as this is getting kind of verbose.
Cheers] Wayne
|
|
|
| |
|
techwizrd
|
Jun 19 2008, 01:22 PM
Post #6
|
- Posts:
- 236
- Group:
- Admins
- Member
- #1
- Joined:
- 31-12-07
- Development Experience
- Jack-of-all-Trades
- Operating System
- Ubuntu 8.04, Slackware 12.1
- Favorite Programming Language
- Python, C, Lisp
- Favorite Desktop Environment
- Gnome 2.24
|
A quad would require less calls of a functions (although that depends on the algorithm).
Quads do have a few great advantages though. They allow for modeling techniques such as Box Modeling.These techniques save time, rendering resources, give good results, and almost always result in closed shapes.
|
My DeviantArt user page Please comment and add me to your favorites!
|
| |
|
slurpee123abc
|
Jun 28 2008, 04:14 PM
Post #7
|
- Posts:
- 57
- Group:
- Members
- Member
- #19
- Joined:
- 2-06-08
- Development Experience
- Programming
- Operating System
- Windows
- Favorite Programming Language
- Blender, Python, C++, GMC
|
One triangle does render faster than one quad. That is a fact, so use triangles when possible.
|
|
|
| |
|
techwizrd
|
Jun 29 2008, 12:59 PM
Post #8
|
- Posts:
- 236
- Group:
- Admins
- Member
- #1
- Joined:
- 31-12-07
- Development Experience
- Jack-of-all-Trades
- Operating System
- Ubuntu 8.04, Slackware 12.1
- Favorite Programming Language
- Python, C, Lisp
- Favorite Desktop Environment
- Gnome 2.24
|
- slurpee123abc
- Jun 28 2008, 04:14 PM
One triangle does render faster than one quad. That is a fact, so use triangles when possible. DO NOT use triangles when possible. Quads are far better for modeling and are easer to use when doing physics calculations. Quads, as I said before, save time and resources on modeling time. They are also easier to rig and animate.
|
My DeviantArt user page Please comment and add me to your favorites!
|
| |
|
slurpee123abc
|
Jul 4 2008, 07:28 PM
Post #9
|
- Posts:
- 57
- Group:
- Members
- Member
- #19
- Joined:
- 2-06-08
- Development Experience
- Programming
- Operating System
- Windows
- Favorite Programming Language
- Blender, Python, C++, GMC
|
Have you ever seen Runescape or World of Warcraft or Stronghold or Doom or any other game where the character is made of quads? I will tell you that you havn't, because there is no such game. Bottom line, quads take longer to compute. If you can achieve more or less the same results with triangles, use them. The character should be triangles, because it takes less power to display them. That way, we can make more background objects. Also, since the main character will be there a long time, it would not hurt to spend a bit of time on it. You can use quads if you think there is no other way, but bottom line is, one triangle renders faster than one quad. You can now give me various reasons why quads are better. They may be true. But they still do not say "quads render faster than triangles". Sure, they have their pros and cons, but render time is a big one. This is just a message to tell people, "if you can easily achieve the same result with a triangle instead of a quad, then use a triangle. But if a quad will save you lots of time modeling, then just use a quad.
Good Day,
Slurpee
|
|
|
| |
|
slurpee123abc
|
Jul 4 2008, 07:33 PM
Post #10
|
- Posts:
- 57
- Group:
- Members
- Member
- #19
- Joined:
- 2-06-08
- Development Experience
- Programming
- Operating System
- Windows
- Favorite Programming Language
- Blender, Python, C++, GMC
|
My opinion follows the example of every commercial 3d video game ever made. They DON'T use quads. They do not. We have to use quads because there is too few of us to only use triangles. It is harder to model with them.
But triangles have the advantage of speed, and speed is required.
Bye,
Slurpee
|
|
|
| |
|
techwizrd
|
Jul 7 2008, 10:24 PM
Post #11
|
- Posts:
- 236
- Group:
- Admins
- Member
- #1
- Joined:
- 31-12-07
- Development Experience
- Jack-of-all-Trades
- Operating System
- Ubuntu 8.04, Slackware 12.1
- Favorite Programming Language
- Python, C, Lisp
- Favorite Desktop Environment
- Gnome 2.24
|
- slurpee123abc
- Jul 4 2008, 07:33 PM
My opinion follows the example of every commercial 3d video game ever made. They DON'T use quads. They do not. We have to use quads because there is too few of us to only use triangles. It is harder to model with them.
But triangles have the advantage of speed, and speed is required.
Bye,
Slurpee Actually, video games do use quads. Especially all the new "hi-def" video games because they are easier to model very complex things. Quads are superior for modeling, and can be converted to triangles later.
|
My DeviantArt user page Please comment and add me to your favorites!
|
| |
|
slurpee123abc
|
Jul 8 2008, 07:43 PM
Post #12
|
- Posts:
- 57
- Group:
- Members
- Member
- #19
- Joined:
- 2-06-08
- Development Experience
- Programming
- Operating System
- Windows
- Favorite Programming Language
- Blender, Python, C++, GMC
|
Don't convert them. One quad counts as two triangles anyway.
|
|
|
| |
|
slurpee123abc
|
Jul 7 2009, 07:13 PM
Post #13
|
- Posts:
- 57
- Group:
- Members
- Member
- #19
- Joined:
- 2-06-08
- Development Experience
- Programming
- Operating System
- Windows
- Favorite Programming Language
- Blender, Python, C++, GMC
|
So, Techwizard. I saw your school science project. I was laughing very hard when I saw that it was a test to see which is faster: quads or triangles. Your science project said a triangle was faster. HA. Whoo hoo. He he.
No offense. I'm just saying.
Ok. You know I had to to say all this. It's just too perfect. Ta Ta,
Slurpee
|
|
|
| |
|
Deleted User
|
Sep 4 2009, 06:15 PM
Post #14
|
|
Deleted User
|
Lol man, triangles are WAY faster lol gtg.
FLARGLES
|
|
|
| |
| 1 user reading this topic (1 Guest and 0 Anonymous)
|