PDA

View Full Version : why are used triangles and not quads?



miroslav_karpis
12-03-2008, 03:27 AM
I know,...VERY noob question, but would like to understand it.

Is it only to save space? 3 is less than 4, or is there some deeper reason?

thanks in advance....

_NK47
12-03-2008, 03:35 AM
its that hardware is optimized ONLY for rendering triangles. in case of other geometry the driver splits up everything in triangles. about saving space its a strange question. if you want a quad you need 4 vertices anyways rendered with TRIANGLE_STRIP as best solution. so apparently you cant draw a quad with 3 vertices right?

miroslav_karpis
12-03-2008, 03:42 AM
its that hardware is optimized ONLY for rendering triangles. in case of other geometry the driver splits up everything in triangles.

wow...this I didn't know. So for example if I make a simple quad (4 vertices) it is presented to hardware as 2 triangles.

But why then in for example 'human face' modeling we should avoid using triangles and in gaming we should use only triangles? (I quess that in 'human face' case the triangle can cause a problem in case we are going to subdivide the model)

_NK47
12-03-2008, 04:54 AM
any geometry can be represented with triangles. even triangles can be split up into infinite amount of triangles (tesselation). when modeling faces you only see them as quads. check f.e. this image (http://www.mpi-inf.mpg.de/resources/atrium/hab/chapter_7/atrium/images/tbt_wireframe.jpg). triangles everywhere.

"So for example if I make a simple quad (4 vertices) it is presented to hardware as 2 triangles."
2 triangles with 4 vertices! aka triangle strip or triangle fan.

miroslav_karpis
12-03-2008, 05:38 AM
now I see - MANY thanks!

_NK47
12-03-2008, 05:40 AM
welcome. btw, OpenGL supportes many primitives. Direct3D on the onther side can only operate on triangles (besides points and lines), no quads, no quad strips, no polygons.

MarkS
12-03-2008, 06:47 AM
There is a good reason for this. The vertices defining a triangle can only be co-planar. Not so with quads. This can effect lighting and texturing. Triangles are also easier to scan convert and making an efficient and quick triangle scan converter is a trivial matter.

There are several legitimate reasons, none of which are to make the developer's life hard. ;)

zeoverlord
12-03-2008, 10:02 AM
But why then in for example 'human face' modeling we should avoid using triangles and in gaming we should use only triangles? (I quess that in 'human face' case the triangle can cause a problem in case we are going to subdivide the model)

Yea, it has more to do with the modeling software itself, for faces you normally uses something called nurbs, it's basically quads that can be subdivided at any level, triangles used to subdivide less than optimally compared to quads and in the case of faces also less uniformly too, and that could cause rendering problems.
However most modern subdiv algorithms are built to get around this, in either case these quads are later converted to triangles at render time or when exporting to a game.

Nighthawk
12-03-2008, 01:41 PM
There is a good reason for this. The vertices defining a triangle can only be co-planar. Not so with quads.
This is the most important reason, i think.

Another problem is unclear interpolation. Imagine the rasterization of a quad with tex coords:

0.0---1.0
| ? |
0.5---0.2
Has the central fragment the tex coords 0.75 or 0.1, or (0.75+0.1)/2?
(There was a nvidia slide about custom interpolation in the geometry shader, but i can't find it right now).

Ilian Dinev
12-03-2008, 05:02 PM
(I quess that in 'human face' case the triangle can cause a problem in case we are going to subdivide the model)
Yes, when you try to subdivide a face model, at triangles you get nasty artifacts and it's hard/impossible to fix them.
In software and hardware rasterizers, triangles are a few orders faster/easier to calculate. Funny thing is that software rasterizers (and maybe HW ones) internally split triangles in two triangles.

MarkS
12-04-2008, 10:17 AM
[quote=miroslav_karpis] Funny thing is that software rasterizers (and maybe HW ones) internally split triangles in two triangles.

Yep. The easiest and fastest triangle to scan convert is one with a horizontal edge. Since that is rarely the case, the rasterizer makes it so. In most cases, splitting a triangle as such and rasterizing two triangles is actually faster than rasterizing the original triangle.